2016-06-29 4 views
2
나는 다음과 같은 오류가 점점 오전

: 나는 다음 CMakeLists.txt 사용하여 단순한 안녕하세요 프로그램을 컴파일 할 때Clion MongoDB의 종속성 설정

--Configuring incomplete, errors occurred! 
CMake Error: The following variables are used in this project, but they are set to NOTFOUND. 
See also "C:/Users/GyuriX/.CLion2016.1/system/cmake/generated/Projects-33418280/33418280/Debug/CMakeFiles/CMakeOutput.log". 
Please set them or make sure they are set and tested correctly in the CMake files: 
BSON_LIBRARY 
    linked by target "Projects" in directory D:/DEV/C/Projects 
MONGODB_LIBRARY 
    linked by target "Projects" in directory D:/DEV/C/Projects 

Makefile:443: recipe for target 'cmake_check_build_system' failed 
mingw32-make.exe: *** [cmake_check_build_system] Error 1 

가 :

cmake_minimum_required(VERSION 2.8) 
project(Projects) 

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 
set(SOURCE_FILES main.cpp) 

include_directories(C:/mongo-c-driver/lib) 

find_library(MONGODB_LIBRARY mongoc-1.0) 
find_library(BSON_LIBRARY bson-1.0) 

add_executable(Projects ${SOURCE_FILES}) 
target_link_libraries(Projects ${MONGODB_LIBRARY} ${BSON_LIBRARY}) 

내가 컴파일 한 mongodb 위키가 말한 것에 기반한 라이브러리가 필요합니다. 따라서 라이브러리 파일을 가지고 있습니다 : The files I have compiled

그래서 제가 뭘하고있는 것은 wro입니다. n CLO에서 mongodb를 사용할 수 있으려면 어떻게해야합니까?

답변

3

오류 메시지는 find_library이 요청 된 라이브러리를 찾지 못한다는 것을 의미합니다.

라이브러리를 기본이 아닌 디렉토리에 설치하면 (스크린 샷에 따르면 C:\mongo-c-driver\bin), 검색해야 할 곳인 find_library()에 대한 힌트가 필요합니다. , find_library에 힌트를위한 다른 방법이 있습니다

set(CMAKE_LIBRARY_PATH "C:\\mongo-c-driver\\bin") 
# Now find_library should be able to find libraries 
find_library(MONGODB_LIBRARY mongoc-1.0) 
find_library(BSON_LIBRARY bson-1.0) 

이 사용하는 검색 알고리즘에 대한 its documentation를 참조하십시오

한 가지 가능한 방법은 CMake 변수 CMAKE_LIBRARY_PATH을 설정하는 것입니다.

+1

C 가이에게만이 아니라 저를 도왔습니다 답변을 주셔서 대단히 감사합니다 :) – gyurix