Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Fri May 16, 2025 7:50 pm

Hello, I wanted to try SpireDocCpp using Clang(msys2) and CLion. The only problem is the "undefined reference to" error.

Error messages:
Code: Select all
C:/Users/sizeoftrickster/CLionProjects/Jopa/main.cpp:13:(.text+0x73): undefined reference to `Spire::Doc::Document::Document()'
C:/msys64/mingw64/bin/ld: C:/Users/sizeoftrickster/CLionProjects/Jopa/main.cpp:27:(.text+0x133): undefined reference to `Spire::Doc::Document::Close()'
C:/msys64/mingw64/bin/ld: CMakeFiles/Jopa.dir/main.cpp.obj: in function `Spire::Doc::Single::~Single()':
C:/Users/sizeoftrickster/CLionProjects/Jopa/include/common/h/Single.h:23:(.text$_ZN5Spire3Doc6SingleD1Ev[_ZN5Spire3Doc6SingleD1Ev]+0x29): undefined reference to `Spire::Doc::Object::~Object()'
C:/msys64/mingw64/bin/ld: CMakeFiles/Jopa.dir/main.cpp.obj: in function `Spire::Doc::Int16::~Int16()':
C:/Users/sizeoftrickster/CLionProjects/Jopa/include/common/h/Int16.h:23:(.text$_ZN5Spire3Doc5Int16D1Ev[_ZN5Spire3Doc5Int16D1Ev]+0x29): undefined reference to `Spire::Doc::Object::~Object()'
C:/msys64/mingw64/bin/ld: CMakeFiles/Jopa.dir/main.cpp.obj: in function `Spire::Doc::Int32::~Int32()':
C:/Users/sizeoftrickster/CLionProjects/Jopa/include/common/h/Int32.h:23:(.text$_ZN5Spire3Doc5Int32D1Ev[_ZN5Spire3Doc5Int32D1Ev]+0x29): undefined reference to `Spire::Doc::Object::~Object()'
C:/msys64/mingw64/bin/ld: CMakeFiles/Jopa.dir/main.cpp.obj: in function `Spire::Doc::Int64::~Int64()':
C:/Users/sizeoftrickster/CLionProjects/Jopa/include/common/h/Int64.h:23:(.text$_ZN5Spire3Doc5Int64D1Ev[_ZN5Spire3Doc5Int64D1Ev]+0x29): undefined reference to `Spire::Doc::Object::~Object()'
C:/msys64/mingw64/bin/ld: CMakeFiles/Jopa.dir/main.cpp.obj: in function `Spire::Doc::UInt16::~UInt16()':


Project Tree:
Code: Select all
└── MyProject/
    ├── cmake-build-debug
    ├── include/
    │   ├── boost
    │   ├── common
    │   ├── doc
    │   └── Spire.Doc.o.h
    ├── lib/
    │   └── x64/
    │       ├── libSkiaSharp.dll
    │       ├── Spire.Doc.Base.dll
    │       ├── Spire.Doc.Cpp.dll
    │       └── Spire.Doc.Cpp.lib
    ├── CMakeLists.txt
    └── main.cpp


CMakeLists.txt:
Code: Select all
cmake_minimum_required(VERSION 3.28)
project(Jopa)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

find_package(Boost QUIET REQUIRED COMPONENTS program_options)

add_executable(${PROJECT_NAME} main.cpp)

target_include_directories(${PROJECT_NAME} PUBLIC ${Boost_INCLUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::program_options "${CMAKE_CURRENT_SOURCE_DIR}/lib/x64/debug/Spire.Doc.Cpp.lib")


main.cpp:
Code: Select all
#include <iostream>
#include <string>
#include "include/Spire.Doc.o.h"

using namespace Spire::Doc;

int main()
{
    std::wstring output_path = L"../";
    std::wstring outputFile = output_path + L"HelloWorld.docx";

    //Create word document
    intrusive_ptr<Document> document = new Document();

    //Create a new section
    intrusive_ptr<Section> section = document->AddSection();

    //Create a new paragraph
    intrusive_ptr<Paragraph> paragraph = section->AddParagraph();

    //Append Text
    paragraph->AppendText(L"Hello World!");

    //Save doc file.
    document->SaveToFile(outputFile.c_str(), FileFormat::Docx);

    document->Close();
}


clang ver:
Code: Select all
C:\Users\sizeoftrickster>clang --version
clang version 20.1.3
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/msys64/mingw64/bin

danilpogodaev
 
Posts: 1
Joined: Tue May 13, 2025 4:33 am

Mon May 19, 2025 9:51 am

Hello,

Thanks for your inquiry.
Based on the information you provided, I understand that you are using the MinGW compiler. We apologize that there is currently an issue with using MinGW to compile Spire.Doc. I have reported this problem to our dev team for repair and will notify you promptly once it is resolved. Sorry for the inconvenience caused to you!

Sincerely,
Tommy
E-iceblue support team
User avatar

Tommy.Tang
 
Posts: 85
Joined: Mon Apr 21, 2025 7:05 am

Return to Spire.Doc