Zohar Levi
Zohar Levi

Reputation: 769

clang: undefined symbol boost::archive::archive_exception

I'm building the demo from the tutorial

https://www.boost.org/doc/libs/1_85_0/libs/serialization/doc/tutorial.html

I created the project using cmake for VS22 with clang-cl.exe, and the cmakefile.txt has

find_package( Boost REQUIRED COMPONENTS serialization )
if(Boost_FOUND)
    message( "Boost found: ${Boost_INCLUDE_DIRS}" )
    target_include_directories( ${PROJECT_NAME} PRIVATE ${Boost_INCLUDE_DIRS} )
    target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
endif()

and I verified that the project is linked against ..\vcpkg_installed\x64-windows\debug\lib\boost_serialization-vc143-mt-gd-x64-1_85.lib.

I get two linker errors:

lld-link : error : undefined symbol: __declspec(dllimport) public: void __cdecl boost::archive::archive_exception::`vbase dtor'(void)
lld-link : error : undefined symbol: public: void __cdecl boost::archive::archive_exception::`vbase dtor'(void)

When building with cl.exe, there are no errors.


EDIT

I opened issues as suggested:

https://github.com/llvm/llvm-project/issues/111889 https://github.com/boostorg/serialization/issues/321

Upvotes: 0

Views: 54

Answers (1)

Zohar Levi
Zohar Levi

Reputation: 769

Until they fix it(...), delete the word virtual from the inheritance definition of the class archive_exception.

Location: boost\archive\archive_exception.hpp, line 43.

class BOOST_SYMBOL_VISIBLE archive_exception :
    public virtual std::exception

Upvotes: 0

Related Questions