2016-03-24 10 views
0

Buna benzemeyen pek çok soru görüyorum ama aynı değil.Cmake.txt (Clion Ide) için Boost kitaplıklarını eklemeye çalışıyorum

Cmake kullanarak Clma'nın tanınmasını/çalışmasını artırma konusunda bir sorun yaşıyorum Clion ile devam eden en üstteki şablon da dahil olmak üzere bir çok yolu denedim.

CKağıt versiyonu yukarıda bahsettiğim incboost üretilen oto var 3.4 Boost versiyonu 1.60.0

find_package(Boost) 
    if (Boost_FOUND) 
    include_directories(${Boost_INCLUDE_DIR}) 
endif() 

Bu sonuç üretir.

İkinci denemesi aşağıdaki

set(Boost_Dir "C:\\Program Files (x86)\\boost_1_60_0\\") 
find_package(Boost 1.60.0 COMPONENTS filesystem) 
include_directories(${Boost_Dir}) 

CmakeFiles\Svp.dir/objects.a(main.cpp.obj): 
In function`_static_initialization_and_destruction_0': 

C:/PROGRA~2/BOOST_~1/boost/system/error_code.hpp:221: undefined reference 
to `boost::system::generic_category()' 

C:/PROGRA~2/BOOST_~1/boost/system/error_code.hpp:222: undefined 
reference to `boost::system::generic_category()' 

C:/PROGRA~2/BOOST_~1/boost/system/error_code.hpp:223: undefined 
reference to `boost::system::system_category()' 

collect2.exe: error: ld returned 1 exit status 

mingw32-make.exe[3]: *** [Svp.exe] Error 1 

CMakeFiles\Svp.dir\build.make:96: recipe for target 'Svp.exe' failed 

CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/Svp.dir/all' failed 

mingw32-make.exe[2]: *** [CMakeFiles/Svp.dir/all] Error 2 

CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/Svp.dir/rule' failed 

mingw32-make.exe[1]: *** [CMakeFiles/Svp.dir/rule] Error 2 

Makefile:117: recipe for target 'Svp' failed 

mingw32-make.exe: *** [Svp] Error 2 

Benim Üçüncü girişimi bu

set(boost "C:\\Program Files (x86)\\boost_1_60_0\\boost\\") 
INCLUDE_DIRECTORIES(${boost}) 

fatal error: boost/filesystem/config.hpp: No such file or directory 
# include <boost/filesystem/config.hpp> 
            ^
compilation terminated. 
mingw32-make.exe[3]: *** [CMakeFiles/Svp.dir/main.cpp.obj] Error 1 
mingw32-make.exe[2]: *** [CMakeFiles/Svp.dir/all] Error 2 
mingw32-make.exe[1]: *** [CMakeFiles/Svp.dir/rule] Error 2 

Ve nihayet hata çıktı değişmemiştir burada How do you add boost libraries in CMakeLists.txt verilen çözümler üretir olduğunu. Burada

+0

Ayrıca farklı derleyiciler kullanarak çeşitli diğer projelerde destek kurulumumu kullandığımı ve sadece iyi çalıştığını açıklığa kavuşturmama izin verin. Cmake.txt – Afflicted

+0

içinde nasıl bulunduğuna dair bir sorun olduğunu biliyorum. ? –

+0

Bu noktada sadece g ++ – Afflicted

cevap

1

benim projelerde, taşınabilir bir şekilde, bunları nasıl kullandığımız açıklanmıştır:

if (WIN32) 
    set(BOOST_ROOT "C:/Program Files (x86)/boost_1_60_0/") 
    set(Boost_USE_STATIC_LIBS ON) 
    set(Boost_USE_MULTITHREAD ON) 

    include_directories(${BOOST_ROOT}) 
    link_directories(${BOOST_ROOT}/stage/lib) # add this before add_executable() 
endif() 

# Here call your add_executable method 
# add_executable(TARGET_NAME ...) 

if(NOT MSVC) 
    find_package(Boost REQUIRED COMPONENTS date_time filesystem wserialization system serialization thread regex) 

    if (Boost_FOUND) 
     include_directories(${Boost_INCLUDE_DIRS}) 
     target_link_libraries(TARGET_NAME ${Boost_LIBRARIES}) 
    endif() 
endif() 

Bir ara Boost_USE_STATIC_LIBS ve Boost_USE_MULTITHREAD değişkenleri belirlemek için gerekli desteği bulmak find_package yardımcı olmak.

Ayrıca, kitaplığı set(BOOST_ROOT, $path) ile artırmak için doğru yolu belirtin. Ayrıca, find_package'da ihtiyacınız olan takviye paketlerini belirtin.

find_package(Boost REQUIRED COMPONENTS date_time filesystem thread regex)

Mesela

için eğer sadece eğer çalışırsa bana bildirin ya senin için değil date_time filesystem thread regex paketleri

gerekir.

+0

Evet, sadece kalkıp test ettiğim için üzgünüm :) Yardımlarınız için teşekkürler! – Afflicted