在 ubuntu 16.04 上安装 Mongo C 驱动程序时出现问题 [英] Problem installing Mongo C Driver on ubuntu 16.04

查看:59
本文介绍了在 ubuntu 16.04 上安装 Mongo C 驱动程序时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用以下命令在 ubuntu 16.04 上安装了 Mongo C 驱动程序:

I have installed the Mongo C Driver on ubuntu 16.04 using the command:

sudo apt-get install libmongoc-1.0-0


当我尝试使用 cmake 进行编译时,出现以下错误:


When I try to compile using cmake, I get the following errors:

rolf@ubuntu2:~/src/test$ cmake .
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:4 (find_package):
By not providing "Findlibmongoc-1.0.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"libmongoc-1.0", but CMake did not find one.
Could not find a package configuration file provided by "libmongoc-1.0"
(requested version 1.7) with any of the following names:

    libmongoc-1.0Config.cmake
    libmongoc-1.0-config.cmake

Add the installation prefix of "libmongoc-1.0" to CMAKE_PREFIX_PATH or set
"libmongoc-1.0_DIR" to a directory containing one of the above files.  If
"libmongoc-1.0" provides a separate development package or SDK, be sure it
has been installed.

-- Configuring incomplete, errors occurred!
See also "/home/rolf/src/test/CMakeFiles/CMakeOutput.log".
rolf@ubuntu2:~/src/test$ apt list --installed

在我看来是C驱动安装有问题,还是cmake?我使用的cmake文件是:

It seems to me that the C driver installation has a problem, or could it be cmake? The cmake file I use is:

cmake_minimum_required(VERSION 6.5)

# Specify the minimum version you require.
find_package (libmongoc-1.0 1.7 REQUIRED)

message ("--   mongoc found version \"${MONGOC_VERSION}\"")
message ("--   mongoc include path \"${MONGOC_INCLUDE_DIRS}\"")
message ("--   mongoc libraries \"${MONGOC_LIBRARIES}\"")

# sample program

add_executable (error-example error-example.c)
target_include_directories (error-example PRIVATE "${MONGOC_INCLUDE_DIRS}")
target_link_libraries (error-example PRIVATE "${MONGOC_LIBRARIES}")
target_compile_definitions (error-example PRIVATE "${MONGOC_DEFINITIONS}")


是不是有什么步骤我忘记了?欢迎提出想法.


Is there some step I have forgotten? Ideas welcome.


更新
我在另一篇文章中找到了对 pkg-config 和 libmongoc-1.0.pc 文件的引用,并检查了这一点:


Update
I found references to pkg-config and libmongoc-1.0.pc file in another post and checked this out:

rolf@lme-u1604:~$ pkg-config --cflags --libs libmongoc-1.0
Package libmongoc-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libmongoc-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libmongoc-1.0' found
rolf@lme-u1604:~$

我检查了整个 FS,但 .pc 文件不在那里.如果确实是这个问题,应该用什么流程来创建这个问题,我该如何解决这个问题?

I checked the whole FS and the .pc file is not there. If indeed this is the problem, what process should create this and how do I fix this?

推荐答案

how-to 安装不完整,至少对于 ubuntu.

The how-to installation is not complete, at least for ubuntu.

您需要进一步安装:

  sudo  apt-get install libmongoc-dev
  sudo  apt-get install libbson-dev
  sudo  apt-get install libbson-1.0-0

到目前为止一切顺利.

如果你遵循他们给出的例子

If you are following the example they gave

试试

      #include <mongoc.h>

代替:

      #include <mongoc/mongoc.h>

#

您的 cmake 应如下所示

#

your cmake should look like the following

 cmake_minimum_required(VERSION 3.13)
 project(mongodb_c C)
 set(CMAKE_C_STANDARD 11)
 include_directories("/usr/include/libmongoc-1.0")
 include_directories("/usr/include/libbson-1.0")
 add_executable(mongodb_c main.c)
 target_link_libraries(mongodb_c /usr/lib/x86_64-linux-gnu/libmongoc-1.0.so.0 /usr/lib/x86_64-linux-gnu/libbson-1.0.so.0)

假设您将代码放在名为 main.c 的文件中

assuming you put your code in a file named main.c

干杯,

马哈茂德

这篇关于在 ubuntu 16.04 上安装 Mongo C 驱动程序时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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