CMake and Boost

后端 未结 2 1227
[愿得一人]
[愿得一人] 2020-12-29 15:57

I\'ve searched and found out that a lot of people have the same problem, but no solution exists.

I\'m using CMake to generate Makefiles for MinGW and when compiling

2条回答
  •  青春惊慌失措
    2020-12-29 16:59

    In my opinion, this question is similar to this question and this one. My best guess would be that you need the same resolution as in my answer to the first question.

    I would strongly recommend the use of find_package (Boost ) and take care with the auto-linking:

    project(boosttest)
    cmake_minimum_required(VERSION 2.6)
    
    # Play with the following defines
    # Disable auto-linking. 
    add_definition( -DBOOST_ALL_NO_LIB )
    # In case of a Shared Boost install (dlls), you should then enable this
    # add_definitions( -DBOOST_ALL_DYN_LINK )
    
    # Explicitly tell find-package to search for Static Boost libs (if needed)
    set( Boost_USE_STATIC_LIBS ON ) 
    find_package( Boost REQUIRED COMPONENTS thread )
    
    include_directories( ${Boost_INCLUDE_DIRS} )
    
    file(GLOB_RECURSE cppFiles src/*.cpp)
    
    add_executable(boosttest ${cppFiles})
    
    target_link_libraries(boosttest ${Boost_LIBRARIES} )
    

提交回复
热议问题