MongoDB C++ Driver installation on Mac OS - c++

It's been 2 days I'm trying to install the driver C++ of MongoDB but I keep running into the same mistake ( in Mac OS X environnement )
In file included from /opt/local/include/boost/filesystem/operations.hpp:24,
from /opt/local/include/boost/filesystem/convenience.hpp:22,
from pch.h:83,
from pch.cpp:18:
/opt/local/include/boost/filesystem/config.hpp:16:5: error: #error Compiling Filesystem version 3 file with BOOST_FILESYSTEM_VERSION defined != 3
In file included from util/goodies.h:22,
from pch.h:161,
from pch.cpp:18:
util/concurrency/mutex.h: In function 'boost::xtime mongo::incxtimemillis(long long int)':
Before installing the lib ( by doing "scons" ), I installed pcre and boost via portmac ( sudo port install boost ).
Any ideas ? I'm really stuck right now..
Thx guys.

You need downgrade the boost library to 1.45 or earlier version to build the mongodb, because it depend on the boost::filesystem v2, but the latest boost (after v1.46) is using boost::filesystem v3 by default.
http://www.boost.org/users/history/version_1_46_0.html
Filesystem:
Version 3 of the library is now the default.

I had the same problem, and downgrading to boost 1.45 got it compiled for me (thanks Flier Lu). I use MacPorts to install Boost; here's instructions on how to downgrade:
https://trac.macports.org/wiki/howto/InstallingOlderPort

Related

boost/beast/core.hpp: There is no such file or directory

I need to write a server in C ++ and today I downloaded Boost via sudo apt-get install-f libboost-all-dev , but this sample code does not compile. Writes an error:
boost.cpp:16:32: fatal error: boost/beast/core.hpp: There is no such file or directory
#include <boost/beast/core.hpp>
And and /usr/include/boost/ no "beast" folder"
How to solve the problem? I've pumped it many times
$ grep BOOST_VERSION /usr/include/boost/version.hpp
#ifndef BOOST_VERSION_HPP
#define BOOST_VERSION_HPP
// BOOST_VERSION % 100 is the patch level
// BOOST_VERSION / 100 % 1000 is the minor version
// BOOST_VERSION / 100000 is the major version
#define BOOST_VERSION 106501
// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
$ grep VERSION /etc/os-release
VERSION="18.04.5 LTS (Bionic Beaver)"
VERSION_ID="18.04"
VERSION_CODENAME=bionic
http_server_sync.cpp
https://www.boost.org/doc/libs/1_75_0/libs/beast/doc/html/beast/examples.html#beast.examples.clients
If the version is old, then how to update correctly?
UPD:
I updated Ubuntu to 20.4, after the files appeared, but there were also problems with linking. Deleted past library files:
sudo apt remove libboost-all-dev
sudo apt autoremove
then I downloaded it from the official website normally:
$ wget https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.gz
$ tar xf boost_1_76_0.tar.gz
$ ./bootstrap.sh
$ ./b2
And after linking so (wrong, probably, but linked!)
Compilation example:
$ g++ boost.cpp -I/home/matroskin/boost_1_76_0 -L/home/matroskin//boost_1_76_0/stage/lib -lboost_system -lpthread```
According to the documentation,
https://www.boost.org/doc/libs/1_66_0/
Beast
Portable HTTP, WebSocket, and network operations using only C++11 and Boost.Asio
...
First Release 1.66.0
you need to upgrade to at least 1.66.0
Edit
In practice, you have a few options
Upgrade ubuntu release. Yes, some people consider it a bit risky and it may result in the necessity of reinstalling the system.
Remove the boost package and, instead, install boost manually, from the sources. This is not difficult, and is well-documented.
I don't use ubuntu and I can't help you more. I remember I once had to install a newer version of boost then the one I had in my package system and it was not a big problem. Also, beast is a header-only library, so you'll even won't have to compile (this part of boost, but beast may depend on other parts of the library, that have to be compiled).
I'll reiterate: installing boost from sources is not that difficult and certainly is safe for your system.

Point Cloud Library - Cannot find pcl_visualizer in Windows 10

I installed PCL 1.11.1 (head) on Windows 10 using vcpkg, but it seems it doesn't include the visualizer, even when I install PCL with VTK and OpenGL support.
I get this error:
fatal error C1083: Cannot open include file: 'pcl/visualization/pcl_visualizer.h': No such file or directory
And there are no file named pcl_visualizer.h in my disk.
Any ideas how to solve the problem without installing PCL from source?
Here is the list of libraries installed by vcpkg:
boost 1.74.0
boost-vcpkg-helpers:x86-windows 7#2
brotli:x86-windows 1.0.9
bzip2:x86-windows 1.0.8#1
curl:x86-windows 7.73.0#4
curl[non-http]:x86-windows
curl[schannel]:x86-windows
curl[ssl]:x86-windows
curl[sspi]:x86-windows
curl[winssl]:x86-windows
double-conversion:x86-windows 3.1.5
egl-registry:x86-windows 2020-02-20
eigen3:x86-windows 3.3.7#8
expat:x86-windows 2020-08-18
flann:x86-windows 2019-04-07-1
freeglut:x86-windows 3.2.1-4
freetype:x86-windows 2.10.2#5
freetype[bzip2]:x86-windows
freetype[png]:x86-windows
glew:x86-windows 2.1.0#9
harfbuzz:x86-windows 2.7.2#1
hdf5:x86-windows 1.12.0
hdf5[szip]:x86-windows
hdf5[zlib]:x86-windows
icu:x86-windows 67.1#6
jsoncpp:x86-windows 1.9.4
libharu:x86-windows 2017-08-15-9
libharu[notiffsymbols]:x86-windows
libiconv:x86-windows 1.16#6
libjpeg-turbo:x86-windows 2.0.5#1
liblzma:x86-windows 5.2.5#2
libogg:x86-windows 1.3.4#3
libpng:x86-windows 1.6.37#13
libtheora:x86-windows 1.2.0alpha1-2
libxml2:x86-windows 2.9.10#2
lz4:x86-windows 1.9.2-2
netcdf-c:x86-windows 4.7.4#1
opengl:x86-windows 0.0#8
openssl:x86-windows 1.1.1h#3
pcl:x86-windows 1.11.1#1
pcl[opengl]:x86-windows
pcl[vtk]:x86-windows
pegtl-2:x86-windows 2.8.3
proj4:x86-windows 7.2.0
proj4[database]:x86-windows
proj4[tiff]:x86-windows
pugixml:x86-windows 1.11.1
qhull:x86-windows 8.0.2
ragel:x86-windows 6.10-3
sqlite3:x86-windows 3.33.0
sqlite3[tool]:x86-windows
szip:x86-windows 2.1.1-6
tiff:x86-windows 4.1.0
utfcpp:x86-windows 3.1.2#1
vtk:x86-windows 9.0.1#2
xxhash:x86-windows 0.8.0#1
zlib:x86-windows 1.2.11#9
zstd:x86-windows 1.4.5#1
PCL Visualization does not currently support VTK 9.0
see discussions in https://github.com/microsoft/vcpkg/issues/11462 https://github.com/microsoft/vcpkg/issues/11601 https://github.com/microsoft/vcpkg/issues/15130

linking of C++ and Python with BOOST; error = rule "Copyright" unknown in module "xml"

I am trying to execute linking of C++ and Python with BOOST.
Using the example from https://www.boost.org/doc/libs/1_63_0/libs/python/doc/html/tutorial/tutorial/hello.html#tutorial.hello.let_s_jam, and issuing bjam at ~/libs/python/example/tutorial/ which contains these files:
hello.cpp hello.py Jamfile
The read-out from the console error is:
/home/benjamin/boost/boost_1_71_0/tools/build/src/tools/types/xml.jam:12:
in load ERROR: rule "Copyright" unknown in module "xml".
Here is what I undertook to solve this problem:
I built boost from boost_1_71_0.tar.bz2 using the ./b2 file in the directory /boost/boost_1_71_0/ which is dated November 14, 2019.
My Ubuntu 18.04 system has a b2 link at /usr/bin/b2 -> bjam, which is older (March 6, 2018) and the bjam file (March 6, 2018).
No other bjam files exist on the system.
From bjam for boost 1.54, I tried:
sudo-apt install bjam
error: E: Package 'bjam' has no installation candidate.
All the programs in the user-config.jam file (e.g., c++, msvc/code, python3) are correct, which is located in my /home/benjamin/boost/boost_1_71_0/tools/build/example/.
For pity's sake and to help me (newbie), please advise.
Looking at error message it seems that error is with file /home/benjamin/boost/boost_1_71_0/tools/build/src/tools/types/xml.jam
I checked with my local installation (which is boost 1.65.1), but I am not able to locate any file with name xml.jam. But I have few other .jam file at location /usr/share/boost-build/src/tools/types/. As example
asm.jam
# Copyright Craig Rodrigues 2005. Distributed under the Boost
# Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
type ASM : s S asm ;
So it seems that your xml.jam either invalid OR few lines should be commented (as in above file).
Try below options.
Check your xml.jam, if there are any content which are not related jam then you should comment out information.
Rename your xml.jam to xml.jam.bkp. This file may not be needed.(Not needed in my case with boost 1.65.1)
Try to install everything from Ubuntu package manager and use that. You can install all boost module by sudo apt install libboost-all-dev. I tried https://github.com/boostorg/python/tree/develop/example code with my local installed boost (1.65.1) from package manager and it work fine.

Building MySQL Connector/C++ from source with cmake fails (conflicts with a previous declaration)

I'm trying to compile the MySQL Connector/C++ 8.0.12 using gcc-8.1.0 and cmake 3.6.2, since the apt package seems to be compiled for gcc-4.9 and crashes when used with gcc-8.1.0 compiled programs (but works with gcc-4.9 compiled programs).
From the MySQL Documentation:
Even a small change in the compiler version can cause problems. If you obtain error messages that you suspect are related to binary incompatibilities, build Connector/C++ from source, using the same compiler and linker that you use to build and link your application.
When I try to build the connector from source as described here:
git clone https://github.com/mysql/mysql-connector-cpp.git
mkdir cppconn
cd cppconn
cmake /home/pi/mysql-connector-cpp
# Everything looks fine except for:
Protobuf include path: /home/pi/mysql-connector-cpp/cdk/protobuf/protobuf-2.6.1/src
...
-- Performing Test HAVE_IS_SAME - Failed
cmake --build . --target install --config Debug
# All lot of warings come up and then:
Scanning dependencies of target protobuf
...
[ 34%] Building CXX object CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/text_format.cc.o
In file included from /home/pi/mysql-connector-cpp/cdk/protobuf/protobuf-2.6.1/src/google/protobuf/text_format.cc:37:
/usr/bin/gcc-8.1.0/include/c++/8.1.0/math.h:65:12: error: ‘constexpr bool std::isinf(double)’ conflicts with a previous declaration
using std::isinf;
^~~~~
In file included from /usr/include/features.h:374,
from /usr/bin/gcc-8.1.0/include/c++/8.1.0/arm-linux-gnueabihf/bits/os_defines.h:39,
from /usr/bin/gcc-8.1.0/include/c++/8.1.0/arm-linux-gnueabihf/bits/c++config.h:508,
from /usr/bin/gcc-8.1.0/include/c++/8.1.0/utility:68,
from /usr/bin/gcc-8.1.0/include/c++/8.1.0/algorithm:60,
from /home/pi/mysql-connector-cpp/cdk/protobuf/protobuf-2.6.1/src/google/protobuf/text_format.cc:35:
/usr/include/arm-linux-gnueabihf/bits/mathcalls.h:201:1: note: previous declaration ‘int isinf(double)’
__MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
^~~~~~~~~~~~
In file included from /home/pi/mysql-connector-cpp/cdk/protobuf/protobuf-2.6.1/src/google/protobuf/text_format.cc:37:
/usr/bin/gcc-8.1.0/include/c++/8.1.0/math.h:66:12: error: ‘constexpr bool std::isnan(double)’ conflicts with a previous declaration
using std::isnan;
^~~~~
In file included from /usr/include/features.h:374,
from /usr/bin/gcc-8.1.0/include/c++/8.1.0/arm-linux-gnueabihf/bits/os_defines.h:39,
from /usr/bin/gcc-8.1.0/include/c++/8.1.0/arm-linux-gnueabihf/bits/c++config.h:508,
from /usr/bin/gcc-8.1.0/include/c++/8.1.0/utility:68,
from /usr/bin/gcc-8.1.0/include/c++/8.1.0/algorithm:60,
from /home/pi/mysql-connector-cpp/cdk/protobuf/protobuf-2.6.1/src/google/protobuf/text_format.cc:35:
/usr/include/arm-linux-gnueabihf/bits/mathcalls.h:234:1: note: previous declaration ‘int isnan(double)’
__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
The requirements stated by the documentation:
A C++ compiler that supports C++11. In case of gcc it must be at least version 4.8. These compilers have been tested: gcc 4.8.5, 5.4.0, 6.3.0, 6.3.1, 7.2.1, 7.3.0, 8.1.1, clang 9.0.0, MS Visual Studio 2015. (present ~ 8.1.0)
CMake 2.8.12 or later. (present - 3.6.2)
Boost 1.59 or later if the version of the C++ standard library used does not implement the UTF8 converter (codecvt_utf8). Boost is also required when building the legacy connector (see below). (libstdc++.so.6.0.25 supports codecvt_utf8 to my knowledge)
OpenSSL version 1.0.x if connector is built with OpenSSL. Instead of OpenSSL the Connector/C++ can be build using WolfSSL 3.14.0 or newer. (present - 1.0.1)
MySQL 8.0 client library if building the legacy connector (see below). (not necessary)
Additional information:
using a Raspberry Pi 2b running Raspbian
libstdc++ version is 6.0.25
Protobuf version seems to be 2.6.1 (to be build)
Thanks in advance. -Minding
The solution was to install gcc properly using this command:
cp -a gcc-*version*/bin/. /usr/bin/
cp -a gcc-*version*/lib/. /usr/lib/
# ... (for all sub directories)
Which just copies all files of the source folder to the destination folder.
Thanks to #Matthieu Brucher for telling me that I installed it wrong and how to install it properly.

Compiling native node addon with c++ 17 inside fails during npm install on ubuntu

I have native add-on for nodejs that uses c++17 features, specifically "shared_mutex".
When I call npm install which downloads and compiles the add-on i get an error:
The linux machine has GCC 6.0 installed.
My Binding.gyp uses the following config to catch os type and add flags accordingly:
'conditions': [
['OS=="linux"', {
'CXXFLAGS': [
'-std=c++1z'
]}],
** i've also tried with '-std=c++17', '-std=c++1z'.
What am I missing?
Update:
1. Updated ubuntu 16.04 to GCC 16.04 and made it default.
2. It seems that when i try to compile it manualy using node-gyp rebuild "CXXFLAGS='-std=c++17'" it works and brings only one error:
"shared_,utex in namespace std does not name a type std::shared_mutex file mutex" (the last error)
Problem solved. For anyone who has the same issue, bind.gyp should use cflags_cc instead of cxxflags.