[CXX-1762] Compilation problems Created: 14/Apr/19  Updated: 16/Oct/21  Resolved: 22/Apr/19

Status: Closed
Project: C++ Driver
Component/s: Build
Affects Version/s: 3.3.0
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: sphinxs Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux Mint 19.1, CMake 3.10.2, G++ 7.0.4, Lib BSON 1.0, Lib Mongo C 1.0, BSON CXX and Mongo CXX 13.0



 Description   

I have installed Mongo C and Mongo CXX drivers for C++. Whe  I was testing the installation I had receive the error:

[ 50%] Building CXX object CMakeFiles/Proto-buffer.dir/source/classes/connection/connection.cpp.o
/home/pc/Downloads/Proto-buffer/source/classes/connection/connection.cpp:7:10: fatal error: bsoncx
x/json.hpp: No such file or directory
 #include <bsoncxx/json.hpp>
 ^~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/Proto-buffer.dir/build.make:62: recipe for target 'CMakeFiles/Proto-buffer.dir/source/c
lasses/connection/connection.cpp.o' failed
make[2]: *** [CMakeFiles/Proto-buffer.dir/source/classes/connection/connection.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Proto-buffer.dir/all' failed
make[1]: *** [CMakeFiles/Proto-buffer.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

 My CPP file:

#include <cstdint>
#include <iostream>
#include <vector>
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/stdx.hpp>
#include <mongocxx/uri.hpp>
 
int main(const int argc, const char *argv[]) {
mongocxx::uri uri("mongodb://localhost:27017");
mongocxx::client client(uri);
}

 
My CMakeList file:
 

# Project
CMAKE_MINIMUM_REQUIRED(VERSION 3.10.2)
 
PROJECT(Proto-buffer CXX)
 
SET(CMAKE_CXX_STANDARD 17)
 
set(CMAKE_CXX_EXTENSIONS OFF)
 
# Libraries
FIND_PACKAGE(libmongocxx REQUIRED)
 
FIND_PACKAGE(libbsoncxx REQUIRED)
 
INCLUDE_DIRECTORIES(${LIBMONGOCXX_INCLUDE_DIR})
 
INCLUDE_DIRECTORIES(${LIBBSONCXX_INCLUDE_DIR})
 
INCLUDE_DIRECTORIES("/usr/local/include/mongocxx/v_noabi/mongocxx")
 
INCLUDE_DIRECTORIES("/usr/local/include/bsoncxx/v_noabi/bsoncxx")
 
INCLUDE_DIRECTORIES("/usr/local/include/libmongoc-1.0")
 
INCLUDE_DIRECTORIES("/usr/local/include/libbson-1.0")
 # Executables
ADD_EXECUTABLE(${PROJECT_NAME} ./source/classes/connection/connection.cpp

How can I fix this? (for more details read this).



 Comments   
Comment by Jeremy Mikola [ 29/Apr/19 ]

sphinxs: Based on your last comment, can we assume the compilation problem has been fully resolved? It sounds like you identified the issue, but I just wanted to confirm.

Comment by sphinxs [ 28/Apr/19 ]

Thanks and sorry for this issue, once this has nothing to do with the CXX driver. The main problem its that I was including the source code of CXX /usr/local/include but not the shared libraries (.so) present in /usr/local/lib. Besides the libraries types, I was including the source code, but not linking the library to the executable in the CMakeList file.

Comment by Jeremy Mikola [ 22/Apr/19 ]

Additionally, on the off chance this may be related to the C and C++ driver installation steps from the Proto-buffer README, it may also be worth reaching out to the project author.

Edit: sphinxs: Please disregard the above suggestion. I didn't realize that you and the Proto-buffer author were one and the same person.

Comment by Kevin Albertson [ 22/Apr/19 ]

We're closing this since this does not appear to be a problem with the C++ driver. But feel free to re-open if you think this is caused by a bug in the C++ driver.

Comment by Kevin Albertson [ 22/Apr/19 ]

Hi sphinxs, thanks for the report! This project is for C++ driver bugs or feature requests. The best place for questions regarding MongoDB usage or C++ driver specifics is the mongodb-user mailing list or stackoverflow as you will reach a broader audience there.

If your business requires an answer from MongoDB within a time frame then we do offer production support.

Generated at Wed Feb 07 22:03:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.