[CDRIVER-1150] Can't build r3.0.0: package 'libmongoc-1.0>=1.3.1' not found Created: 04/Mar/16  Updated: 08/Dec/17  Resolved: 16/Mar/16

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

Type: Bug Priority: Major - P3
Reporter: Andrey Ponomarenko Assignee: A. Jesse Jiryu Davis
Resolution: Incomplete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File PKG_CONFIG_DEBUG_SPEW_CMAKE_OUTPUT.txt     File config.log    

 Description   

I can't build r3.0.0. The libbson 1.3.3 and mongo-c-driver 1.3.3 have been installed properly.

The CMake configure error message is the following:

]$ cmake .
– The CXX compiler identification is GNU 4.9.2
– Check for working CXX compiler: /bin/c++
– Check for working CXX compiler: /bin/c++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– No build type selected, default is Release
– The C compiler identification is GNU 4.9.2
– Check for working C compiler: /bin/cc
– Check for working C compiler: /bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– checking for module 'libbson-1.0>=1.3.1'
– found libbson-1.0, version 1.3.3
– Found LIBBSON: TRUE
– Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
– Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
– Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
– Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
– Performing Test COMPILER_HAS_DEPRECATED_ATTR
– Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
– checking for module 'libmongoc-1.0>=1.3.1'
– package 'libmongoc-1.0>=1.3.1' not found
CMake Error at cmake-3.2.3/Modules/FindPkgConfig.cmake:340 (message):
A required package was not found
Call Stack (most recent call first):
cmake-3.2.3/Modules/FindPkgConfig.cmake:502 (_pkg_check_modules_internal)
cmake/FindLibMongoC.cmake:26 (pkg_check_modules)
src/mongocxx/CMakeLists.txt:23 (find_package)

– Configuring incomplete, errors occurred!



 Comments   
Comment by Vincent D [ 08/Dec/17 ]

Thank you for the info.
In fact my problem was a bit different : the cmake of cmongocxx was telling that libbson was not found.
I've finally figured out that I may, at one point, have messed with the configuration of pkgconfig.
pkg-config (which I've installed months ago by apt-get and don't know much about) was somehow misconfigured.
pkg-config --modversion libbson-1.0 would fail
but pkg-config --modversion /usr/local/lib/pkg-config/libbson-1.0.pc was ok

I did

sudo apt remove pkg-config
sudo apt clean pkg-config
sudo apt purge pkg-config

then
sudo apt install pkg-config
and now mongocxx's cmake go fine.

Comment by A. Jesse Jiryu Davis [ 08/Dec/17 ]

Yes, that looks to me like the correct steps. You have built libmongoc with "./configure", which is generated by the Autotools. Building libmongoc that way will also build libbson. You should now have libbson and libmongoc 1.6.3 installed on your system.

I recommend you try the latest release of libmongoc, 1.8.2, instead.

Comment by Vincent D [ 08/Dec/17 ]

Hi I have the same problem,
What do you mean by

recommendation is that you build libbson and libmongoc both using Autotools

From the files in the mongo-cxx release I don't see what else than cmake I could use to build mongocxx.

I actually do the following :

# cmongo
wget https://github.com/mongodb/mongo-c-driver/releases/download/1.6.3/mongo-c-driver-1.6.3.tar.gz
tar xzf mongo-c-driver-1.6.3.tar.gz
cd mongo-c-driver-1.6.3
./configure --disable-automatic-init-and-cleanup
make
sudo make install
cd ..
sudo ldconfig
 
curl -OL https://github.com/mongodb/mongo-cxx-driver/archive/r3.1.3.tar.gz
tar -xzf r3.1.3.tar.gz
cd mongo-cxx-driver-r3.1.3/build
cmake -DCMAKE_BUILD_TYPE=Release -DBSONCXX_POLY_USE_MNMLSTC=1 -DCMAKE_INSTALL_PREFIX=/usr/local ..
sudo make install
cd ../..

Comment by A. Jesse Jiryu Davis [ 18/Mar/16 ]

Great, thanks for your reply.

Comment by Andrey Ponomarenko [ 17/Mar/16 ]

It's OK to close the issue. My problem is resolved.

Comment by Andrey Ponomarenko [ 17/Mar/16 ]

There is no any specific reason for me to build them by different build systems. Thank you.

Comment by A. Jesse Jiryu Davis [ 16/Mar/16 ]

andrewponomarenko, I'm going to close this for now. My recommendation is that you build libbson and libmongoc both using Autotools. (The CMake build is primarily meant for Windows builds.) If you have a strong need to mix Autotools and CMake builds, please reopen this ticket and we'll gladly debug the problem with you.

Comment by A. Jesse Jiryu Davis [ 14/Mar/16 ]

Oh, I missed that. Can you tell me why you're building libbson with Automake and the C Driver with CMake please?

Comment by Andrey Ponomarenko [ 14/Mar/16 ]

There is no config.log in the c driver because it is configured by cmake.

Comment by Andrey Ponomarenko [ 14/Mar/16 ]

libbson config log

Comment by A. Jesse Jiryu Davis [ 09/Mar/16 ]

libbson's and libmongoc's Makefiles both put their pkgconfig files in $(libdir)/pkgconfig/:

https://github.com/mongodb/libbson/blob/master/src/Makefile.am#L23
https://github.com/mongodb/mongo-c-driver/blob/master/src/Makefile.am#L1

... so I don't know why they'd put installed different places. If you'd like to open a Jira ticket in the CDRIVER project with the config.log generated by both libbson and libmongoc we can debug from there.

Comment by Andrey Ponomarenko [ 08/Mar/16 ]

Output of "PKG_CONFIG_DEBUG_SPEW=1 cmake"

Comment by Andrey Ponomarenko [ 08/Mar/16 ]

Seems that the issue is with the installation of the Mongo C driver. It is installed to "/usr/lib/pkgconfig/libmongoc-1.0.pc", but libbson is installed to "/usr/lib64/pkgconfig/libbson-1.0.pc". The output of the "PKG_CONFIG_DEBUG_SPEW=1 cmake" is attached.

Comment by Andrew Morrow (Inactive) [ 07/Mar/16 ]

andrewponomarenko - One thing that puzzles me is that while configuring without PKG_CONFIG_PATH, the CMake build was able to find libbson-1.3.3, but then failed to find libmongoc at all. Presumably, libbson and libmongoc were installed to the same location. Why did the first one succeed, and the second one fail? Can you verify that you only have one instance of each of libbson and libmongoc installed on the system? I think the easiest way would be to search the filesystem for libmongoc-1.0.pc and libbson-1.0.pc. Another interesting thing to try would be to set PKG_CONFIG_DEBUG_SPEW in the environment to get more detailed information on what pkgconfig is doing.

mark.benvenuto - I wouldn't expect that the user would need to set PKG_CONFIG_PATH in this situation. The /usr/lib/pkgconfig path should be automatically included in the search path. If it wasn't, how was libbson, presumably installed to /usr, located in the original failed configuration attempt?

Comment by Mark Benvenuto [ 06/Mar/16 ]

acm Is there a way to we can advise the user that they need to set PKG_CONFIG_PATH in some cases? I know this affects Fedora users, but does it also affect Ubuntu users?

Comment by Andrey Ponomarenko [ 04/Mar/16 ]

Hello,

Thank you for the reply.

The mongo-c-driver is configured with "cmake -DCMAKE_INSTALL_PREFIX=/usr" and libbson with "./configure --prefix=/usr".

The file libmongoc-1.0.pc is presented in the system:

]$ cat /usr/lib/pkgconfig/libmongoc-1.0.pc

prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${exec_prefix}/include

Name: libmongoc
Description: The libmongoc MongoDB client library.
Version: 1.3.3
Requires: libbson-1.0
Libs: -L${libdir} -lmongoc-1.0
Cflags: -I${includedir}/libmongoc-1.0

Adding PKG_CONFIG_PATH=/usr/lib/pkgconfig/ parameter fixed the issue:

]$ PKG_CONFIG_PATH=/usr/lib/pkgconfig/ cmake .

– The CXX compiler identification is GNU 4.9.2
– Check for working CXX compiler: /bin/c++
– Check for working CXX compiler: /bin/c++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– No build type selected, default is Release
– The C compiler identification is GNU 4.9.2
– Check for working C compiler: /bin/cc
– Check for working C compiler: /bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– checking for module 'libbson-1.0>=1.3.1'
– found libbson-1.0, version 1.3.3
– Found LIBBSON: TRUE
– Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
– Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
– Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
– Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
– Performing Test COMPILER_HAS_DEPRECATED_ATTR
– Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
– checking for module 'libmongoc-1.0>=1.3.1'
– found libmongoc-1.0, version 1.3.3
– Found LIBMONGOC: TRUE
– Configuring done
– Generating done
– Build files have been written to: r3.0.0/mongo-cxx-driver-r3.0.0

Why the CMake can't find default pkgconfig path (/usr/lib/pkgconfig/) automatically?

Thank you!

Comment by Mira Carey [ 04/Mar/16 ]

Andrey,

What location have you installed libmongoc and libbson into? If those directories aren't already registered with pkg-config, you may need to specify PKG_CONFIG_PATH on the cmake command line invocation.

I.e.

# If you've installed the c driver from the source tarball without specifying a prefix
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig cmake .

You're looking for a directory containing a file named libmongoc-1.0.pc

Regards,
Jason

Generated at Wed Feb 07 21:11:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.