[CXX-1656] Could not find header files Created: 26/Sep/18  Updated: 27/Sep/18  Resolved: 27/Sep/18

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

Type: Bug Priority: Major - P3
Reporter: Klaus [X] Assignee: A. Jesse Jiryu Davis
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I am trying to use mongocxx driver version 3.3.1 but when I am compiling the sample given in the docs, I have the following issue:

In file included from /usr/local/include/bsoncxx/v_noabi/bsoncxx/document/element.hpp:20:0,
 from /usr/local/include/bsoncxx/v_noabi/bsoncxx/array/element.hpp:20,
 from /usr/local/include/bsoncxx/v_noabi/bsoncxx/array/view.hpp:21,
 from /usr/local/include/bsoncxx/v_noabi/bsoncxx/array/value.hpp:20,
 from /usr/local/include/bsoncxx/v_noabi/bsoncxx/builder/core.hpp:21,
 from /usr/local/include/bsoncxx/v_noabi/bsoncxx/builder/stream/document.hpp:17,
 from test.cpp:3:
/usr/local/include/bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp:24:55: fatal error: bsoncxx/third_party/mnmlstc/core/string.hpp: No such file or directory
 #include <bsoncxx/third_party/mnmlstc/core/string.hpp>

I built and installed the driver as follows:

 

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_PREFIX_PATH=/usr/local ..
sudo make EP_mnmlstc_core
make 
make install

 

What do you think ? Have I forgotten something?

 

 



 Comments   
Comment by Klaus [X] [ 27/Sep/18 ]

Yes, it would be great to have an official RPM of the C++ Driver. In the meantime, I managed to packaged it myself so everything’s good !

I am ready to start coding and using it now (:

Comment by A. Jesse Jiryu Davis [ 27/Sep/18 ]

Thanks for the info. I couldn't reproduce your issue when I was built the C++ Driver myself, so I hypothesize that there's a problem with building it as part of an RPM install. We'll keep this in mind when we create an official RPM of the C++ Driver in the future.

Comment by Klaus [X] [ 27/Sep/18 ]

I am using CentOS release 6.5, with gcc 4.8.2 and cmake3 version 3.6.1.

I tried to package mongocxx driver to have a RPM I can install easily but I don't know why, I don’t have headers in /usr/local/include/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc when I am installing the generated RPM.

What I did in my spec file is the following:

%build
cd build
cmake -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_INSTALL_PREFIX=/usr/local \
 -DCMAKE_PREFIX_PATH=/usr/local \
 -DBSONCXX_POLY_USE_MNMLSTC=1 ..
sudo make EP_mnmlstc_core
make
%install
rm -rf %{buildroot}
cd build
make install DESTDIR=%{buildroot}

Do you have an idea of what I did wrong?

EDIT: I solved my problem by doing the following in my spec file:

%install
MNMLSTC_HEADERS=/usr/local/include/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc
mkdir -p %{buildroot}$MNMLSTC_HEADERS
cp -r $MNMLSTC_HEADERS/* %{buildroot}$MNMLSTC_HEADERS/
cd build
make install DESTDIR=%{buildroot}

It is not particularly beautiful... but it works.

If you have a better idea, please let me know!

Comment by A. Jesse Jiryu Davis [ 27/Sep/18 ]

Thanks Klaus. What compiler version and Linux distro and verson are you using? I want to investigate those compiler warnings. But no, you don't need to worry about them.

For me with Ubuntu 18.04, cmake 3.10.2, and gcc 7.3.0, the C++ driver's build system properly chooses MNMLSTC as the polyfill by default. The following steps properly install both MNMLSTC and the driver:

curl -OL https://github.com/mongodb/mongo-cxx-driver/archive/r3.3.1.tar.gz
tar -xzf r3.3.1.tar.gz
cd mongo-cxx-driver-r3.3.1/build
# Chooses MNMLSTC by default, and downloads it.
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
# Make and install MNMLSTC, this is not automatic.
# Puts headers in /usr/local/include/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc
sudo make EP_mnmlstc_core
# Install the driver.
make && sudo make install

Comment by Klaus [X] [ 27/Sep/18 ]

Thanks for the quick reply Jesse. Indeed, I thought that MNMLSTC/core would be chosen by default for non-Windows platforms and Boost would be chosen by default for Windows platforms.

By the way, by compiling the example, I have some warnings on MNMLSTC cpp sources, like for instance:

/usr/local/include/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc/core/string.hpp:42:69: warning: declaration of 'len' shadows a member of 'this' [-Wshadow]
 constexpr basic_string_view (pointer str, size_type len) noexcept :

or even some warnings on bsoncxx sources, like for instance:

/usr/local/include/bsoncxx/v_noabi/bsoncxx/decimal128.hpp: In constructor 'bsoncxx::v_noabi::decimal128::decimal128(uint64_t, uint64_t)':
/usr/local/include/bsoncxx/v_noabi/bsoncxx/decimal128.hpp:45:54: warning: declaration of 'low' shadows a member of 'this' [-Wshadow]
 decimal128(uint64_t high, uint64_t low) noexcept : _high(high), _low(low) {}

Do I need to worry ?

Comment by A. Jesse Jiryu Davis [ 26/Sep/18 ]

Thanks for the info. It seems like our CMakeLists.txt should have chosen MNMLSTC by default, right? Is the problem that “make install” installs the driver but doesn’t install MNMLSTC, and then when you’re using the installed driver MNMLSTC is not available systemwide?

Comment by Klaus [X] [ 26/Sep/18 ]

My bad, I forgot to choose a C++17 polyfill with:

-DBSONCXX_POLY_USE_MNMLSTC=1

This ticket can be closed.

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