나는 stackoverflow 및 다른 포럼에서 검색했지만 아무 소용이없는 cmake-baed 부스트 링크 문제로 고민하고 있습니다.cmake를 사용하여 부스터 라이브러리를 연결하는 경우 2.8.8
Boost가 이미 설치된 클러스터에서 C++ 프로그램 모음 (Boost 외에도 다른 라이브러리에 따라 다름)을 컴파일 중입니다. 전체 경로를 알고 있습니다. 컴파일하는 동안 cmake로 부스트하는 이상한 링크 에러를 얻은 후, 나는 문제를 해결하기 위해 아주 간단한 boost-cmake 예제를 먼저 컴파일하는 것을 고려했다.
코드는 아래와 같습니다.
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/option.hpp>
using namespace std;
#include <iostream>
namespace po = boost::program_options;
int main(int argc, char** argv) {
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
;
return 0;
}
다음 CMakeLists.txt 파일을 사용하여 제작하고 있습니다. 내가 cmake를 사용하여 컴파일 할 때
cmake_minimum_required(VERSION 2.8)
set(Boost_INCLUDE_DIR /software/apps/boost/1.55.0/build06/include)
set(Boost_LIBRARY_DIR /software/apps/boost/1.55.0/build06/lib)
find_package(Boost COMPONENTS program_options REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR})
message("Boost include dir is ${Boost_INCLUDE_DIR}")
message("Boost library dir is ${Boost_LIBRARY_DIR}")
message("Boost libraries are at ${Boost_LIBRARIES}")
add_executable(main main.cpp)
target_link_libraries(main ${Boost_LIBRARIES})
, 나는 문제가 아래로 내가 코드를 "할"때 오는 다음과 같은 출력
[email protected] build]$ emacs ../CMakeLists.txt
Display localhost:39.0 unavailable, simulating -nw
[[email protected] build]$ rm -rf *
[[email protected] build]$ cmake ..
-- The C compiler identification is GNU 4.7.2
-- The CXX compiler identification is GNU 4.7.2
-- Check for working C compiler: /software/apps/comp_wrapper/gnu/gcc
-- Check for working C compiler: /software/apps/comp_wrapper/gnu/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /software/apps/comp_wrapper/gnu/c++
-- Check for working CXX compiler: /software/apps/comp_wrapper/gnu/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Boost found.
Found Boost components:
program_options
Boost include dir is /usr/include
Boost library dir is /software/apps/boost/1.55.0/build06/lib
Boost libraries are at optimized;boost_program_options-mt-shared;debug;boost_program_options-mt-shared-debug
-- Configuring done
-- Generating done
-- Build files have been written to: /home/x_ikrul/Downloads/boost_example/build
를 얻을. 당신이 볼 수있는 바와 같이 CMake가 이상하게 시간을 연결에서 /software/apps/boost/1.55.0/build06/lib 수 부스트의 lib 디렉토리를 보여주고 있지만
[email protected] build]$make
Scanning dependencies of target main
[100%] Building CXX object CMakeFiles/main.dir/main.cpp.o
make[2]: *** No rule to make target `/usr/lib64/lib64/libboost_program_options-mt.so.5', needed by `main'. Stop.
make[1]: *** [CMakeFiles/main.dir/all] Error 2
make: *** [all] Error 2
, 그것은 다른 비 참조한다 exiting 디렉토리.
아무도 이런 오류가 발생 했습니까? 클러스터는 CentOS 릴리스 6.5, 부스트 (내가 가리키는 곳)가 1.55.0이고 사용중인 cmake가 2.8.8입니다.
귀하의 부스트 포함 dir도 정확하게 발견되지 않았습니까? 'Boost include dir is/usr/include' – fileoffset
맞습니다. 실제로이 예제를 cmake/boost의 같은 버전으로 다른 클러스터에서 시도했을 때 모든 것이 원활하게 진행되지만 현재 컴퓨터에서는 이상한 오류가 발생합니다. – Ikram