[CMake] [Boost-users] link error in Visual Studio when using boost from CMake

Mourad Boufarguine mourad at boufarguine.name
Mon Apr 30 18:20:58 EDT 2012


Hi,

add this :

link_directories(${Boost_LIBRARY_DIRS})

after the include_directories command.

Cheers,
Mourad
*
*


On Mon, Apr 30, 2012 at 10:26 PM, Hui Wang <huiwang8921 at gmail.com> wrote:

> Yes, I tried with find_package( Boost COMPONENTS thread ) and
> target_link_libraries( ShowEngine ${Boost_LIBRARIES}), and that works.
> Thank you so much!
>
> On Mon, Apr 30, 2012 at 3:27 PM, Alain Leblanc <aalebl at gmail.com> wrote:
>
>> Don't have much experience with boost in combination with cmake, but
>> don't you still need to add the boost libraries in a
>> target_link_libraries() command? (Or whatever command is usedbto indicate
>> the libraries to link with).
>>
>> A
>>  On Apr 30, 2012 2:49 PM, "Hui Wang" <huiwang8921 at gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I'm using CMake generated Visual Studio solution, and I added boost with
>>> find_package(Boost),
>>> before that I used commands: set(Boost_USE_STATIC_LIBS
>>> ON) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF)
>>> after that I used
>>> commands: include_directories(${Boost_INCLUDE_DIR}) add_executable(
>>> MyProject src/main.cpp)
>>>
>>> Because automatic linking is used on Visual Studio when including Boost,
>>> and it typically use static libraries, I try not to conflict with that. But
>>> I get the error:
>>> LINK : fatal error LNK1104: cannot open file
>>> 'libboost_thread-vc100-mt-gd-1_47.lib'
>>>
>>> I installed pre-compiled binary Boost with the installer provided by
>>> BoostPro Computing, and I checked to find that I do have
>>> libboost_thread-vc100-mt-gd-1_47.lib, libboost_thread-vc100-mt-s-1_47.lib
>>> libboost_thread-vc100-mt-sgd-1_47.lib libboost_thread-vc100-mt-1_47.lib
>>> in C:\Program Files\boost\boost_1_47\lib
>>>
>>> I also output messages to find that
>>> Boost_FOUND=TRUE Boost_LIBRARY_DIRS=C:/Program
>>> Files/boost/boost_1_47/lib Boost_INCLUDE_DIRS=C:/Program
>>> Files/boost/boost_1_47
>>>
>>> So I'm confused why it has the link error. I tried with dynamically
>>> linking too, it can't find the .dll files at runtime either, but again they
>>> exist right there in the directory I installed boost. Could anyone help me
>>> understand where the problem is?
>>>
>>> Thanks!
>>> --
>>> Sophie Wang
>>> www.sophiehuiwang.com
>>>
>>>
>>> --
>>>
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the CMake FAQ at:
>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>>>
>>
>> _______________________________________________
>> Boost-users mailing list
>> Boost-users at lists.boost.org
>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>
>
>
>
> --
> Sophie Wang
> www.sophiehuiwang.com
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120501/9c8adb1c/attachment.htm>


More information about the CMake mailing list