0

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'

Lukas
  • 3
  • 2
  • `libboost_log-vc143-mt-gd-x64-1_81.lib` does that exact filename exist? – drescherjm Dec 23 '22 at 16:11
  • No. And that is what I am curious about. I have only the file `libboost_log-vc143-mt-s-x64-1_81.lib`. From my understanding `mt-s` means multithreaded statically link. So I do not need the `mt-gd` version and I also have no Idea where the `libboost_log-vc143-mt-gd-x64-1_81.lib` comes from. – Lukas Dec 23 '22 at 18:17
  • This may help decode the library naming: [https://stackoverflow.com/questions/2715164/how-can-i-decode-the-boost-library-naming](https://stackoverflow.com/questions/2715164/how-can-i-decode-the-boost-library-naming) – drescherjm Dec 23 '22 at 18:19
  • @drescherjm Thank you. I think I understand it now `mt-s` just means /MT Runtime Library setting of MSVC. After changing the configuration of the sln build. I Just get `Error LNK1104 cannot open file 'libboost_log-vc143-mt-s-x64-1_81.lib'` XD – Lukas Dec 23 '22 at 19:08
  • btw I do have the file `boost_log-vc143-mt-s-x64-1_81.lib` XD – Lukas Dec 23 '22 at 19:09
  • This may add some more info: [https://stackoverflow.com/questions/41193447/why-is-boost-looking-for-libboost-lib-instead-of-boost-lib](https://stackoverflow.com/questions/41193447/why-is-boost-looking-for-libboost-lib-instead-of-boost-lib) – drescherjm Dec 23 '22 at 19:27
  • Thank you. I think I could move a step forward. Now I am getting the same linking error like the cmake build: ` 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 ` – Lukas Dec 23 '22 at 22:13
  • Are you sure you installed Boost with the same configuration that you are using to build. In the output of the ``conan install`` you should have the full profile used for dependencies, which should match your current configuration. Posting that profile here might help, otherwise, consider posting the question for support in https://github.com/conan-io/conan/issues – drodri Dec 24 '22 at 16:20
  • Thank you. I will ask for support in github.com/conan-io/conan/issues – Lukas Dec 25 '22 at 11:47

0 Answers0