#Boost Linker Error

1 messages · Page 1 of 1 (latest)

white valley
#

I am trying to add boost::thread to my application, but I get this link error. I have the proper include path in the compiler, and I have -pthread specified in the linker. I am not sure what I am doing wrong.

CMake Error at CMakeLists.txt:52 (target_link_libraries):
  Target "boost_thread" links to:

    Boost::assert

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

CMake Generate step failed.  Build files cannot be regenerated correctly.    CMakeLists.txt    /thread    MhError    CMake Problem

I am already including boost::assert's includes into my project and have them specified in the project's include path.

solemn heraldBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

drifting pecan
#

the error message is saying that one of boost_thread's dependencies cannot be found.

Target "boost_thread" links to:
Boost::assert
but the target was not found.
so the target "boost_thread" links to the target "boost::assert" and it could not be found

white valley
#

Let me amend my original post to include that information

drifting pecan
#

and have them specified in the project's include path
its the cmake target boost_thread that cannot find boost_assert. not your project

#

ok, i dont use cmake much. just install it via vcpkg and all works.

what does your cmakelists look like? are you using find_package(Boost REQUIRED COMPONENTS thread system) or the like?

#

all you should need in your cmakelists file is something like the following:

find_package(Boost_Thread REQUIRED)
add_executable (blah "blah.cpp" "blah.h")
target_link_libraries(blah Boost::thread)
(depending on how you have set things up)

white valley
white valley
#

!solved