无法编译 mongo-cxx-driver
unable to compile mongo-cxx-driver
从 CXX Driver Quickstart guide 我完全无法在 Ubuntu 或 CentOS VM 上完成新驱动程序的编译。
我已经按照这封信的步骤进行了好几次,但我不确定哪里出了问题。
In file included from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/bulk_write.hpp:20:0,
from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/bulk_write.cpp:19:
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc.hpp:31:63: error: ‘mongoc_client_pool_set_ssl_opts’ was not declared in this scope
#define MONGOCXX_LIBMONGOC_SYMBOL(name) constexpr auto name = mongoc_##name;
^
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc_symbols.hpp:42:1: note: in expansion of macro ‘MONGOCXX_LIBMONGOC_SYMBOL’
MONGOCXX_LIBMONGOC_SYMBOL(client_pool_set_ssl_opts)
我已经重做了好几次了。好几次我都重新安装了整个操作系统。有问题的错误与 mongo-c-driver 的 1.2 开发版本有关。我确定安装了它,但是出了点问题。
编辑:
我认为这不会很快得到解决,而且我没有时间真正解决这个问题。我暂时改用了 RethinkDB。几个月后我会再试一次。
编辑 2:
构建过程(确保 MongoDB 服务器已启动且 运行)
git clone -b 1.2.0-dev https://github.com/mongodb/mongo-c-driver
./autogen.sh
sudo make && sudo make install
git clone -b master https://github.com/mongodb/mongo-cxx-driver
cd mongo-cxx-driver/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
sudo make && sudo make install
GCC and G++ version are 4.9.2
编辑 3:
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.27.1")
-- checking for module 'libbson-1.0'
-- found libbson-1.0, version 1.2.0-dev
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- checking for module 'libmongoc-1.0'
-- found libmongoc-1.0, version 1.2.0-dev
-- Configuring done
-- Generating done
-- Build files have been written to: /home/sam/downloads/mongo-cxx-driver/build
我现在还添加了我的 cmake 构建的标志:
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_COMPILER=/usr/bin/clang ..
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
Target: x86_64-redhat-linux-gnu
Thread model: posix
我现在遇到 more/better 错误。
In file included from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc.hpp:32:
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc_symbols.hpp:42:1: error:
use of undeclared identifier 'mongoc_client_pool_set_ssl_opts'; did you
mean 'client_pool_set_ssl_opts'?
MONGOCXX_LIBMONGOC_SYMBOL(client_pool_set_ssl_opts)
^
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc.hpp:31:63: note:
expanded from macro 'MONGOCXX_LIBMONGOC_SYMBOL'
#define MONGOCXX_LIBMONGOC_SYMBOL(name) constexpr auto name = mongoc_##name;
^
<scratch space>:19:1: note: expanded from here
mongoc_client_pool_set_ssl_opts
^
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc_symbols.hpp:42:27: note:
'client_pool_set_ssl_opts' declared here
MONGOCXX_LIBMONGOC_SYMBOL(client_pool_set_ssl_opts)
^
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc.hpp:31:56: note:
expanded from macro 'MONGOCXX_LIBMONGOC_SYMBOL'
#define MONGOCXX_LIBMONGOC_SYMBOL(name) constexpr auto name = mongoc_##name;
^
In file included from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/bulk_write.cpp:19:
In file included from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/bulk_write.hpp:20:
In file included from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc.hpp:32:
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc_symbols.hpp:42:1: error:
variable 'client_pool_set_ssl_opts' declared with 'auto' type cannot
appear in its own initializer
MONGOCXX_LIBMONGOC_SYMBOL(client_pool_set_ssl_opts)
^
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc.hpp:31:63: note:
expanded from macro 'MONGOCXX_LIBMONGOC_SYMBOL'
#define MONGOCXX_LIBMONGOC_SYMBOL(name) constexpr auto name = mongoc_##name;
^
<scratch space>:19:1: note: expanded from here
mongoc_client_pool_set_ssl_opts
^
编辑 4:
将 clang 更新到 3.6,因为我认为这可能会解决一些问题。我重建了 libbson,libmongoc 并再次尝试。
Scanning dependencies of target mongocxx
[ 23%] Building CXX object src/mongocxx/CMakeFiles/mongocxx.dir/bulk_write.cpp.o
In file included from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/bulk_write.cpp:19:
In file included from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/bulk_write.hpp:20:
In file included from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc.hpp:32:
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc_symbols.hpp:42:1: error: use of undeclared identifier
'mongoc_client_pool_set_ssl_opts'; did you mean 'mongoc_client_pool_try_pop'?
MONGOCXX_LIBMONGOC_SYMBOL(client_pool_set_ssl_opts)
^
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc.hpp:31:63: note: expanded from macro
'MONGOCXX_LIBMONGOC_SYMBOL'
#define MONGOCXX_LIBMONGOC_SYMBOL(name) constexpr auto name = mongoc_##name;
^
<scratch space>:20:1: note: expanded from here
mongoc_client_pool_set_ssl_opts
^
/usr/local/include/libmongoc-1.0/mongoc-client-pool.h:45:23: note: 'mongoc_client_pool_try_pop' declared here
mongoc_client_t *mongoc_client_pool_try_pop (mongoc_client_pool_t *pool);
^
1 error generated.
make[2]: *** [src/mongocxx/CMakeFiles/mongocxx.dir/bulk_write.cpp.o] Error 1
make[1]: *** [src/mongocxx/CMakeFiles/mongocxx.dir/all] Error 2
make: *** [all] Error 2
我找到问题了。
#ifdef MONGOC_ENABLE_SSL
void mongoc_client_pool_set_ssl_opts (mongoc_client_pool_t *pool,
const mongoc_ssl_opt_t *opts);
#endif
MONGOC_ENABLE_SSL 被设置为 0 因为我没有安装 OpenSSL-devel 包。我将向 MongoCXX 驱动程序开发人员提出问题,以确保他们将其清楚地放在 wiki 页面上。
从 CXX Driver Quickstart guide 我完全无法在 Ubuntu 或 CentOS VM 上完成新驱动程序的编译。
我已经按照这封信的步骤进行了好几次,但我不确定哪里出了问题。
In file included from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/bulk_write.hpp:20:0,
from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/bulk_write.cpp:19:
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc.hpp:31:63: error: ‘mongoc_client_pool_set_ssl_opts’ was not declared in this scope
#define MONGOCXX_LIBMONGOC_SYMBOL(name) constexpr auto name = mongoc_##name;
^
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc_symbols.hpp:42:1: note: in expansion of macro ‘MONGOCXX_LIBMONGOC_SYMBOL’
MONGOCXX_LIBMONGOC_SYMBOL(client_pool_set_ssl_opts)
我已经重做了好几次了。好几次我都重新安装了整个操作系统。有问题的错误与 mongo-c-driver 的 1.2 开发版本有关。我确定安装了它,但是出了点问题。
编辑:
我认为这不会很快得到解决,而且我没有时间真正解决这个问题。我暂时改用了 RethinkDB。几个月后我会再试一次。
编辑 2:
构建过程(确保 MongoDB 服务器已启动且 运行)
git clone -b 1.2.0-dev https://github.com/mongodb/mongo-c-driver
./autogen.sh
sudo make && sudo make install
git clone -b master https://github.com/mongodb/mongo-cxx-driver
cd mongo-cxx-driver/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
sudo make && sudo make install
GCC and G++ version are 4.9.2
编辑 3:
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.27.1")
-- checking for module 'libbson-1.0'
-- found libbson-1.0, version 1.2.0-dev
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- checking for module 'libmongoc-1.0'
-- found libmongoc-1.0, version 1.2.0-dev
-- Configuring done
-- Generating done
-- Build files have been written to: /home/sam/downloads/mongo-cxx-driver/build
我现在还添加了我的 cmake 构建的标志:
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_COMPILER=/usr/bin/clang ..
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
Target: x86_64-redhat-linux-gnu
Thread model: posix
我现在遇到 more/better 错误。
In file included from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc.hpp:32:
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc_symbols.hpp:42:1: error:
use of undeclared identifier 'mongoc_client_pool_set_ssl_opts'; did you
mean 'client_pool_set_ssl_opts'?
MONGOCXX_LIBMONGOC_SYMBOL(client_pool_set_ssl_opts)
^
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc.hpp:31:63: note:
expanded from macro 'MONGOCXX_LIBMONGOC_SYMBOL'
#define MONGOCXX_LIBMONGOC_SYMBOL(name) constexpr auto name = mongoc_##name;
^
<scratch space>:19:1: note: expanded from here
mongoc_client_pool_set_ssl_opts
^
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc_symbols.hpp:42:27: note:
'client_pool_set_ssl_opts' declared here
MONGOCXX_LIBMONGOC_SYMBOL(client_pool_set_ssl_opts)
^
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc.hpp:31:56: note:
expanded from macro 'MONGOCXX_LIBMONGOC_SYMBOL'
#define MONGOCXX_LIBMONGOC_SYMBOL(name) constexpr auto name = mongoc_##name;
^
In file included from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/bulk_write.cpp:19:
In file included from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/bulk_write.hpp:20:
In file included from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc.hpp:32:
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc_symbols.hpp:42:1: error:
variable 'client_pool_set_ssl_opts' declared with 'auto' type cannot
appear in its own initializer
MONGOCXX_LIBMONGOC_SYMBOL(client_pool_set_ssl_opts)
^
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc.hpp:31:63: note:
expanded from macro 'MONGOCXX_LIBMONGOC_SYMBOL'
#define MONGOCXX_LIBMONGOC_SYMBOL(name) constexpr auto name = mongoc_##name;
^
<scratch space>:19:1: note: expanded from here
mongoc_client_pool_set_ssl_opts
^
编辑 4:
将 clang 更新到 3.6,因为我认为这可能会解决一些问题。我重建了 libbson,libmongoc 并再次尝试。
Scanning dependencies of target mongocxx
[ 23%] Building CXX object src/mongocxx/CMakeFiles/mongocxx.dir/bulk_write.cpp.o
In file included from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/bulk_write.cpp:19:
In file included from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/bulk_write.hpp:20:
In file included from /home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc.hpp:32:
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc_symbols.hpp:42:1: error: use of undeclared identifier
'mongoc_client_pool_set_ssl_opts'; did you mean 'mongoc_client_pool_try_pop'?
MONGOCXX_LIBMONGOC_SYMBOL(client_pool_set_ssl_opts)
^
/home/sam/downloads/mongo-cxx-driver/src/mongocxx/private/libmongoc.hpp:31:63: note: expanded from macro
'MONGOCXX_LIBMONGOC_SYMBOL'
#define MONGOCXX_LIBMONGOC_SYMBOL(name) constexpr auto name = mongoc_##name;
^
<scratch space>:20:1: note: expanded from here
mongoc_client_pool_set_ssl_opts
^
/usr/local/include/libmongoc-1.0/mongoc-client-pool.h:45:23: note: 'mongoc_client_pool_try_pop' declared here
mongoc_client_t *mongoc_client_pool_try_pop (mongoc_client_pool_t *pool);
^
1 error generated.
make[2]: *** [src/mongocxx/CMakeFiles/mongocxx.dir/bulk_write.cpp.o] Error 1
make[1]: *** [src/mongocxx/CMakeFiles/mongocxx.dir/all] Error 2
make: *** [all] Error 2
我找到问题了。
#ifdef MONGOC_ENABLE_SSL
void mongoc_client_pool_set_ssl_opts (mongoc_client_pool_t *pool,
const mongoc_ssl_opt_t *opts);
#endif
MONGOC_ENABLE_SSL 被设置为 0 因为我没有安装 OpenSSL-devel 包。我将向 MongoCXX 驱动程序开发人员提出问题,以确保他们将其清楚地放在 wiki 页面上。