Mongocxx header files issue

Hello. I have installed mongo-cxx-driver-r3.6.5 by following the instructions Linux (build from tar). Then I copied mongo-cxx-driver-r3.6.5/src/{bsoncxx, mongocxx} directories to /usr/local/include. The problem is that at compiling my testing code, some mongocxx source files are missing.

This is a produced error. “config.hpp” does not exist, but by inspecting the files I see that “config.hpp.in” does exist. Etc. There are several missing source files.

/usr/local/include/bsoncxx/config/prelude.hpp:68:10: fatal error: bsoncxx/config/config.hpp: No such file or directory #include <bsoncxx/config/config.hpp>

The shortened main.cpp code:

#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/stdx.hpp>
#include <mongocxx/uri.hpp>
#include <mongocxx/instance.hpp>
#include <bsoncxx/builder/stream/helpers.hpp>
#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/builder/stream/array.hpp>
int main()
{
    return 0;
}

Could you tell me how to fix it?

OS: Ubuntu 18.04, g++ compiler.

This section of the forum is for the M001 MongoDB university course.

You will be better serve by posting into a more appropriate section.

1 Like

I was able to redirect that to a more appropriate section.

1 Like

It seems unlikely that after following the instructions that you linked that it would be necessary to manually copy the header files. In fact, copying them as you did results in some missing components, as you found out. You should remove the /usr/local/include/{bsoncxx,mongocxx} directories that you manually copied and then use either CMake or pkg-config (depending on which suits your build setup) to get the appropriate flags that will allow the compiler and linker to locate the headers and libraries. This tutorial shows an example with pkg-config.

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.