簡體   English   中英

make mongo-cxx-driver找不到包含

[英]make mongo-cxx-driver cannot find includes

我一直在嘗試在OSX 10.10上為C ++ 11編譯mongo-cxx-driver,但是我遇到了一些麻煩。 libbson和mongo-c-driver都已成功構建和安裝,庫到/ usr / local / lib,以及/usr/local/include/libbson-1.0和/usr/local/include/libmongoc-1.0的頭文件分別。 我從mongo-cxx-driver / build目錄成功運行了cmake,這是shell的整個輸出:

~/code/cpp/mongo-cxx-driver/build  ((r3.0.1)) $> cmake -DLIBBSON_DIR=/usr/local/include/libbson-1.0 -DLIBMONGOC_DIR=/usr/local/include/libmongoc-1.0 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/user/code/cpp/mongo-cxx-driver

當我運行make form mongo-cxx-driver目錄時,我收到以下錯誤:

...
[  4%] Building CXX object src/bsoncxx/CMakeFiles/bsoncxx.dir/array/view.cpp.o
/Users/user/code/cpp/mongo-cxx-driver/src/bsoncxx/array/view.cpp:21:10: fatal error: 'bson.h' file not
  found
#include <bson.h>
         ^
1 error generated.

顯然編譯器無法找到那些包括......但為什么呢? 是不是在cmake命令行中設置了LIBBSON_DIR和LIBMONGOC_DIR?

編輯:我使用cmake從他們的git源構建了C驅動程序和libbson; 使; sudo make install。 今天我從頭開始創建mongo-cxx驅動程序,記錄所有問題。 輸出后生成的mongo-cxx-driver / build中的cmake:

~/code/cpp/mongo-cxx-driver/build  (master) $> cmake ..
-- The CXX compiler identification is AppleClang 7.3.0.7030031
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- No build type selected, default is Release
-- The C compiler identification is AppleClang 7.3.0.7030031
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at cmake/FindLibBSON.cmake:38 (message):
  Don't know how to find libbson; please set LIBBSON_DIR to the prefix
   directory with which libbson was configured.
Call Stack (most recent call first):
   src/bsoncxx/CMakeLists.txt:67 (find_package)


-- Configuring incomplete, errors occurred!
See also "/Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/CMakeOutput.log".

來自/mongo-cxx-driver/build/CMakeFiles/CMakeOutput.log中cmake的日志包含(僅顯示C ++ 11相關的嚴重性行):

The system is: Darwin - 15.6.0 - x86_64
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: /Library/Developer/CommandLineTools/usr/bin/c++ 
Build flags: 
Id flags: 

The output was:
0


Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"

The CXX compiler identification is AppleClang, found in "/Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/3.6.2/CompilerIdCXX/a.out"

Determining if the CXX compiler works passed with the following output:
Change Dir: /Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_1ae1a/fast"
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_1ae1a.dir/build.make CMakeFiles/cmTC_1ae1a.dir/build
Building CXX object CMakeFiles/cmTC_1ae1a.dir/testCXXCompiler.cxx.o
/Library/Developer/CommandLineTools/usr/bin/c++      -o CMakeFiles/cmTC_1ae1a.dir/testCXXCompiler.cxx.o -c /Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTC_1ae1a
/usr/local/Cellar/cmake/3.6.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1ae1a.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/c++     -Wl,-search_paths_first -Wl,-headerpad_max_install_names   CMakeFiles/cmTC_1ae1a.dir/testCXXCompiler.cxx.o  -o cmTC_1ae1a  


Detecting CXX compiler ABI info compiled with the following output:
Change Dir: /Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_34702/fast"
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_34702.dir/build.make CMakeFiles/cmTC_34702.dir/build
Building CXX object CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o
/Library/Developer/CommandLineTools/usr/bin/c++      -o CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o -c /usr/local/Cellar/cmake/3.6.2/share/cmake/Modules/CMakeCXXCompilerABI.cpp
Linking CXX executable cmTC_34702
/usr/local/Cellar/cmake/3.6.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_34702.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/c++     -Wl,-search_paths_first -Wl,-headerpad_max_install_names  -v -Wl,-v CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o  -o cmTC_34702   
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
 "/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o cmTC_34702 -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lSystem /Library/Developer/CommandLineTools/usr/bin/../lib/clang/7.3.0/lib/darwin/libclang_rt.osx.a
@(#)PROGRAM:ld  PROJECT:ld64-264.3.102
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
Library search paths:
    /usr/lib
    /usr/local/lib
Framework search paths:
    /Library/Frameworks/
    /System/Library/Frameworks/


Parsed CXX implicit link information from above output:
  link line regex: [^( *|.*[/\])(ld|([^/\]+-)?ld|collect2)[^/\]*( |$)]
  ignore line: [Change Dir: /Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/CMakeTmp]
  ignore line: []
  ignore line: [Run Build Command:"/usr/bin/make" "cmTC_34702/fast"]
  ignore line: [/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_34702.dir/build.make CMakeFiles/cmTC_34702.dir/build]
  ignore line: [Building CXX object CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o]
  ignore line: [/Library/Developer/CommandLineTools/usr/bin/c++      -o CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o -c /usr/local/Cellar/cmake/3.6.2/share/cmake/Modules/CMakeCXXCompilerABI.cpp]
  ignore line: [Linking CXX executable cmTC_34702]
  ignore line: [/usr/local/Cellar/cmake/3.6.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_34702.dir/link.txt --verbose=1]
  ignore line: [/Library/Developer/CommandLineTools/usr/bin/c++     -Wl,-search_paths_first -Wl,-headerpad_max_install_names  -v -Wl,-v CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o  -o cmTC_34702   ]
  ignore line: [Apple LLVM version 7.3.0 (clang-703.0.31)]
  ignore line: [Target: x86_64-apple-darwin15.6.0]
  ignore line: [Thread model: posix]
  ignore line: [InstalledDir: /Library/Developer/CommandLineTools/usr/bin]
  link line: [ "/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o cmTC_34702 -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lSystem /Library/Developer/CommandLineTools/usr/bin/../lib/clang/7.3.0/lib/darwin/libclang_rt.osx.a]
    arg [/Library/Developer/CommandLineTools/usr/bin/ld] ==> ignore
    arg [-demangle] ==> ignore
    arg [-dynamic] ==> ignore
    arg [-arch] ==> ignore
    arg [x86_64] ==> ignore
    arg [-macosx_version_min] ==> ignore
    arg [10.11.0] ==> ignore
    arg [-o] ==> ignore
    arg [cmTC_34702] ==> ignore
    arg [-search_paths_first] ==> ignore
    arg [-headerpad_max_install_names] ==> ignore
    arg [-v] ==> ignore
    arg [CMakeFiles/cmTC_34702.dir/CMakeCXXCompilerABI.cpp.o] ==> ignore
    arg [-lc++] ==> lib [c++]
    arg [-lSystem] ==> lib [System]
    arg [/Library/Developer/CommandLineTools/usr/bin/../lib/clang/7.3.0/lib/darwin/libclang_rt.osx.a] ==> lib [/Library/Developer/CommandLineTools/usr/bin/../lib/clang/7.3.0/lib/darwin/libclang_rt.osx.a]
  Library search paths: [;/usr/lib;/usr/local/lib]
  Framework search paths: [;/Library/Frameworks/;/System/Library/Frameworks/]
  remove lib [System]
  collapse lib [/Library/Developer/CommandLineTools/usr/bin/../lib/clang/7.3.0/lib/darwin/libclang_rt.osx.a] ==> [/Library/Developer/CommandLineTools/usr/lib/clang/7.3.0/lib/darwin/libclang_rt.osx.a]
  collapse library dir [/usr/lib] ==> [/usr/lib]
  collapse library dir [/usr/local/lib] ==> [/usr/local/lib]
  collapse framework dir [/Library/Frameworks/] ==> [/Library/Frameworks]
  collapse framework dir [/System/Library/Frameworks/] ==> [/System/Library/Frameworks]
  implicit libs: [c++;/Library/Developer/CommandLineTools/usr/lib/clang/7.3.0/lib/darwin/libclang_rt.osx.a]
  implicit dirs: [/usr/lib;/usr/local/lib]
  implicit fwks: [/Library/Frameworks;/System/Library/Frameworks]

Detecting CXX [-std=c++11] compiler features compiled with the following output:
Change Dir: /Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_a8d63/fast"
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_a8d63.dir/build.make CMakeFiles/cmTC_a8d63.dir/build
Building CXX object CMakeFiles/cmTC_a8d63.dir/feature_tests.cxx.o
/Library/Developer/CommandLineTools/usr/bin/c++     -std=c++11 -o CMakeFiles/cmTC_a8d63.dir/feature_tests.cxx.o -c /Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/feature_tests.cxx
Linking CXX executable cmTC_a8d63
/usr/local/Cellar/cmake/3.6.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a8d63.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/c++     -Wl,-search_paths_first -Wl,-headerpad_max_install_names   CMakeFiles/cmTC_a8d63.dir/feature_tests.cxx.o  -o cmTC_a8d63  


    Feature record: CXX_FEATURE:0cxx_aggregate_default_initializers
    ...
    Feature record: CXX_FEATURE:1cxx_variadic_templates

Detecting C [-std=c11] compiler features compiled with the following output:
Change Dir: /Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_9a269/fast"
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_9a269.dir/build.make CMakeFiles/cmTC_9a269.dir/build
Building C object CMakeFiles/cmTC_9a269.dir/feature_tests.c.o
/Library/Developer/CommandLineTools/usr/bin/cc    -std=c11 -o CMakeFiles/cmTC_9a269.dir/feature_tests.c.o   -c /Users/user/code/cpp/mongo-cxx-driver/build/CMakeFiles/feature_tests.c
Linking C executable cmTC_9a269
/usr/local/Cellar/cmake/3.6.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9a269.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/cc    -Wl,-search_paths_first -Wl,-headerpad_max_install_names   CMakeFiles/cmTC_9a269.dir/feature_tests.c.o  -o cmTC_9a269  


    Feature record: C_FEATURE:1c_function_prototypes
    Feature record: C_FEATURE:1c_restrict
    Feature record: C_FEATURE:1c_static_assert
    Feature record: C_FEATURE:1c_variadic_macros

(如果需要其他線路,我很樂意發送它們)。 ls / usr / local / lib / pkgconfig顯示以下內容:

lcms2.pc        libbson-1.0.pc      libmongoc-1.0.pc    libmongoc-ssl-1.0.pc    libtiff-4.pc        mysqlclient.pc

發現了問題。 @acm要求顯示pkg-config --cflags --libs libmongoc-1.0 libbson-1.0 ,我試圖這樣做:

~/code/cpp/mongo-cxx-driver/build  (master) $> pkg-config --cflags --libs libmongoc-1.0 libbson-1.0
-bash: pkg-config: command not found

顯然沒有安裝pkg-config。 通過自制軟件快速安裝后,我跑了同樣的路線,得到了:

~/code/cpp/mongo-cxx-driver/build  (master) $> pkg-config --cflags --libs libmongoc-1.0 libbson-1.0
-I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -L/usr/local/lib -lmongoc-1.0 -lbson-1.0

之后cmake運行得很好,並且也做了。

謝謝你的幫助 :-)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM