0

I am trying to compile mongo-cxx-driver-r3.1.1 on Ubuntu14.4 . I have installed mongo-c-driver-1.6.3 from source as per instructions.

pkg-config --cflags --libs libmongoc-1.0 libbson-1.0 returns 
-I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0  -L/usr/local/lib -lmongoc-1.0 -lsasl2 -lssl -lcrypto -lrt -lbson-1.0

I have boost version 1.57. When I try to compile mongo-cxx-driver-r3.1.1 as per the instructions provided in https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/ using cmake.

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local  ..

I get the following logs :

-- Boost version: 1.57.0

-- Configuring done

-- Generating done

-- Build files have been written to: /user/home/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build

I have tried other options such as:

cmake  -DBSONCXX_POLY_USE_MNMLSTC:Bool=OFF -DBSONCXX_POLY_USE_BOOST:Bool=ON -

DCMAKE_VERBOSE_MAKEFILE=ON  -DCMAKE_C_COMPILER="/usr/bin/gcc" -
DCMAKE_CXX_COMPILER="/usr/bin/g++-4.8"  -DCMAKE_BUILD_TYPE=Release -
DCMAKE_INSTALL_PREFIX=/usr/local -DLIBMONGOC_DIR=/usr/local/lib -
DLIBBSON_DIR=/usr/local/lib .. 

However, I dont see the mongocxx related libraries or header files. Following is the CMakeFiles/CMakeOutput.log output:

The system is: Linux - 3.13.0-32-generic - x86_64 Compiling the CXX

compiler identification source file "CMakeCXXCompilerId.cpp"

succeeded. Compiler: /usr/bin/g++-4.8 Build flags: Id flags:

The output was:

0

Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"

The CXX compiler identification is GNU, found in "/home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/3.2.2/CompilerIdCXX/a.out"

Determining if the CXX compiler works passed with the following output: Change Dir: /home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTryCompileExec1480695504/fast"

ake[1]: Entering directory /home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp' /usr/bin/cmake -E cmake_progress_report /home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp/CMakeFiles 1 Building CXX object CMakeFiles/cmTryCompileExec1480695504.dir/testCXXCompiler.cxx.o /usr/bin/g++-4.8 -o CMakeFiles/cmTryCompileExec1480695504.dir/testCXXCompiler.cxx.o -c /home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx Linking CXX executable cmTryCompileExec1480695504 /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1480695504.dir/link.txt --verbose=1 /usr/bin/g++-4.8 CMakeFiles/cmTryCompileExec1480695504.dir/testCXXCompiler.cxx.o -o cmTryCompileExec1480695504 -rdynamic make[1]: Leaving directory/home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp'

Detecting CXX compiler ABI info compiled with the following output: Change Dir: /home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTryCompileExec4079379117/fast" .............

...................


/home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp/src.cxx:2:25: warning: \u2018int somefunc()\u2019 is deprecated (declared at /home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp/src.cxx:1) [-Wdeprecated-declarations] int main() { return somefunc();} ^ /home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp/src.cxx:2:34: warning: \u2018int somefunc()\u2019 is deprecated (declared at /home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp/src.cxx:1) [-Wdeprecated-declarations] int main() { return somefunc();} ^ Linking CXX executable cmTryCompileExec1892014975 /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1892014975.dir/link.txt --verbose=1 /usr/bin/g++-4.8 -DCOMPILER_HAS_DEPRECATED_ATTR CMakeFiles/cmTryCompileExec1892014975.dir/src.cxx.o -o cmTryCompileExec1892014975 -rdynamic make[1]: Leaving directory `/home/cvaidyan/mongo-c-driver-1.6.3/mongo-cxx-driver-r3.1.1/build/CMakeFiles/CMakeTmp'

Source file was: attribute((deprecated)) int somefunc() { return 0; } int main() { return somefunc();}

I could post the entire cmake output if it is meaningful. I grep'ed for "error" or "fail" in the file , but wasn't able to find either strings.

It would be great if someone could point out, what I am missing here?

acm
  • 12,183
  • 5
  • 39
  • 68
  • 1
    This question is *very* hard to read and understand. Are you saying that CMake failed? I don't see any evidence of that, or at least not in a comprehensible format? If CMake succeeded, you need to run "make && make install" after running cmake in order to build and install the driver. – acm Jun 23 '17 at 14:03
  • running cmake you only prepare make script. I.e. you aren't compiling anything when run `cmake ....`. To actually compile something you should run `make` command from where you point cmake to prepare build. – Alexey Jun 23 '17 at 14:11
  • Hi Chitra! If you still haven't solved your issue, feel free to ask a question on the MongoDB users Google Group[1] or the mongocxx JIRA project[2], and I can help you debug it. [1]: https://groups.google.com/forum/#!forum/mongodb-user [2]: https://jira.mongodb.org/browse/CXX/ – Saghm Jun 28 '17 at 15:41
  • Sorry for the delay in posting. The issue got resolved. There was some issue with the make. – Chitra Vaidyanathan Jul 18 '17 at 12:01

1 Answers1

1

this bash file works well for ubuntu 16.04

#!/bin/bash
apt-get update >> /dev/null
apt-get install openssh-server -y 
apt-get install g++ -y
apt-get install cmake -y
apt-get install git -y
#installing the mongoc dependencies and driver
apt-get install pkg-config libssl-dev libsasl2-dev -y
cd ~
wget https://github.com/mongodb/mongo-c-driver/releases/download/1.6.2/mongo-c-driver-1.6.2.tar.gz
tar xzf mongo-c-driver-1.6.2.tar.gz
cd mongo-c-driver-1.6.2
./configure --disable-automatic-init-and-cleanup
make
make install
cd ~ 
rm mongo-c-driver-1.6.2.tar.gz
rm -rf mongo-c-driver-1.6.2


#installing mongocxx driver - connects c++ to mongo
wget https://github.com/mongodb/mongo-cxx-driver/archive/r3.1.1.tar.gz
tar -xzf r3.1.1.tar.gz
cd mongo-cxx-driver-r3.1.1/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
make EP_mnmlstc_core
make
make install
cd ~
rm r3.1.1.tar.gz
rm -rf mongo-cxx-driver-r3.1.1
Pav K.
  • 2,548
  • 2
  • 19
  • 29