无法编译mongo-cxx-driver

时间:2015-10-03 02:34:22

标签: c++ mongodb 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。在几个月后,我会再次尝试。

EDIT2:

构建过程(确保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

我现在得到了更多/更好的错误。

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

1 个答案:

答案 0 :(得分:1)

我找到了这个问题。

#ifdef MONGOC_ENABLE_SSL
void                  mongoc_client_pool_set_ssl_opts (mongoc_client_pool_t   *pool,
                                                       const mongoc_ssl_opt_t *opts);
#endif
由于我没有安装OpenSSL-devel软件包,因此

MONGOC_ENABLE_SSL设置为0 。我将向MongoCXX驱动程序开发人员提出一个问题,以确保他们明确地将其放在维基页面上。