2022-12-24

Boost static linking to custom library somehow broken (Windows)

I am trying to build a Library (MyLib) that has a static dependency to boost. However, when I am trying link MyLib to an Application I will get linking erorrs saying that boost functions cannot be found.

I did used the pointer to implementation idiom. Conan installed the static lib of boost (I checked that). The plattform is windows.

Does anyone has an idea what I am doing wrong?

Here is the CMakeLists.txt

cmake_minimum_required(VERSION 3.24)

set(TARGET_NAME MyLib)
project(${TARGET_NAME}Project)

include(${CMAKE_CURRENT_LIST_DIR}/build/conanbuildinfo.cmake)
conan_basic_setup()


set(
    SRC_FILES
    src/FileA.cpp
    src/FileB.cpp
    src/FileC.cpp
)

add_library(${TARGET_NAME} ${SRC_FILES})
target_include_directories(
    ${TARGET_NAME} 
    PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include/public 
    PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include/private
)

target_link_libraries(${TARGET_NAME} PRIVATE ${CONAN_LIBS_STATIC})
set_property(TARGET ${TARGET_NAME} PROPERTY CXX_STANDARD 17)

install(TARGETS ${TARGET_NAME} DESTINATION lib)

This is the erorr I am getting:

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2001 unresolved external symbol "public: class boost::log::v2s_mt_nt6::attribute_value_set::const_iterator __cdecl boost::log::v2s_mt_nt6::attribute_value_set::end(void)const " (?end@attribute_value_set@v2s_mt_nt6@log@boost@@QEBA?AVconst_iterator@1234@XZ)  Main    C:\dev\TestProjects\VSLog\Main\CppLogLib.lib(ConsoleLogWrapper.obj) 1   

Many thanks in advance.

I tried with CMake setting like set(Boost_USE_STATIC_LIBS ON) or set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS "OPT:NOREF") but it did not help.

I also try to build MyLib using sln (and Boost downloaded from boost.org) and here I also get a linking error:

Error LNK1104 cannot open file 'libboost_log-vc143-mt-gd-x64-1_81.lib'



No comments:

Post a Comment