在cmake C ++项目中使用mongodb cxx驱动程序 [英] Using the mongodb cxx driver in a cmake c++ project

查看:458
本文介绍了在cmake C ++项目中使用mongodb cxx驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是cmake的新手,我想使用c ++和最新的mongodb cxx驱动程序连接到mongodb.我设法编译并安装了驱动程序,但是现在我坚持在cmake项目中使用它.

I am new to cmake and I want to connect to a mongodb using c++ and the latest mongodb cxx driver. I managed to compile and install the driver but now I stuck with using it in my cmake project.

我使用默认设置安装了mongodb驱动程序,因此它位于/usr/local/lib/include/mongocxx/v_noabi/mongocxx下.

I installed the mongodb driver with the default settings, so it's located under /usr/local/lib/include/mongocxx/v_noabi/mongocxx.

在我的cmake文件中,我试图用以下命令解决包含的问题:

In my cmake file i manged to get the includes resolved with:

include_directories(/usr/local/lib/include/mongocxx/v_noabi/usr/local/lib/include/bsoncxx/v_noabi)

include_directories(/usr/local/lib/include/mongocxx/v_noabi /usr/local/lib/include/bsoncxx/v_noabi)

但是我不知道如何将驱动程序库实际链接到我的可执行文件.谁能帮我吗?

but I don't know how to actually link the driver libs to my executable. Could any one please help me?

推荐答案

您不需要那样做.您可以并且应该通过CMake的 pkg_check_modules 子系统. C ++ 11驱动程序同时支持.

You shouldn't need to do it that way. You can and should find the C++11 driver via either CMake's find_package or via pkg_check_modules subsystems. The C++11 driver supports both.

这篇关于在cmake C ++项目中使用mongodb cxx驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆