[CXX-1513] Can I use mongocxx 3.1.3 and MongoDB 3.4 with 32-bit software? Created: 09/Feb/18  Updated: 27/Oct/23  Resolved: 01/Mar/18

Status: Closed
Project: C++ Driver
Component/s: BSON, Build
Affects Version/s: 3.1.3
Fix Version/s: None

Type: Task Priority: Critical - P2
Reporter: Adwait Lele Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: 32-bit, compatability
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

x86_64 machine with VMWare/CentOS 7.4 and MongoDB 3.4, Mongo C++ driver 3.1.3 installed



 Description   

I have some code that I compile using the -m32 option with g+. The software is 32-bit so it needs to be compiled as such. I want to integrate MongoDB and the Mongo C+ driver with this code.

When I compile my code I get errors like this:

/usr/bin/ld: skipping incompatible /usr/local/lib/libmongocxx.so when searching for -lmongocxx
/usr/bin/ld: skipping incompatible /usr/local/lib/libmongocxx.a when searching for -lmongocxx
/usr/bin/ld: skipping incompatible /usr/local/lib/libmongocxx.so when searching for -lmongocxx
/usr/bin/ld: skipping incompatible /usr/local/lib/libmongocxx.a when searching for -lmongocxx
/usr/bin/ld: cannot find -lmongocxx
/usr/bin/ld: skipping incompatible /usr/local/lib/libbsoncxx.so when searching for -lbsoncxx
/usr/bin/ld: skipping incompatible /usr/local/lib/libbsoncxx.a when searching for -lbsoncxx
/usr/bin/ld: skipping incompatible /usr/local/lib/libbsoncxx.so when searching for -lbsoncxx
/usr/bin/ld: skipping incompatible /usr/local/lib/libbsoncxx.a when searching for -lbsoncxx
/usr/bin/ld: cannot find -lbsoncxx

I have been able to successfully use the C++ driver to write programs that I didn't compile with the -m32 option, but is there a workaround to using C++ driver 3.1.3 and MongoDB 3.4 with 32-bit compilation?

Or do I have to use an older version of MongoDB and the legacy C++ driver?



 Comments   
Comment by Adwait Lele [ 01/Mar/18 ]

I think you can close this issue for now.

Thanks,
Adwait

Comment by Andrew Morrow (Inactive) [ 01/Mar/18 ]

Hi adwaitl - Is there any additional assistance we can provide?

Comment by A. Jesse Jiryu Davis [ 20/Feb/18 ]

Hi, to compile libbson and libmongoc in 32-bit mode, I suggest:

export CFLAGS="-m32 -march=i386"
./configure
make
sudo make install

Comment by Adwait Lele [ 20/Feb/18 ]

Any idea about this?^

Comment by Adwait Lele [ 12/Feb/18 ]

How do I compile the C driver and libbson in 32-bit mode? Like I mentioned previously I used the Building from a release tarball section from here (http://mongoc.org/libmongoc/current/installing.html) to install the C driver and libbson.

The Makefile is 5700 lines long - what places would I indicate the -m32 flag?

Comment by Andrew Morrow (Inactive) [ 09/Feb/18 ]

You should just be able to compile with the new flags, it should overwrite any changed files for both C and C++ drivers.

Comment by Adwait Lele [ 09/Feb/18 ]

Yes you are correct. Not the server source code. I just want to integrate the C++ driver into the 32-bit code.

  • If I already have a 64-bit "build" of libmongoc and libbson on my machine, do I have to clean anything up or can I just compile it using make with the -m32 option? I used the Building from a release tarball section here (http://mongoc.org/libmongoc/current/installing.html)
  • Same question for the C++ driver. I assume I can just run the CMake in the Mongo C++ Driver directory with right flags for 32-bit compilation. No need to do any "cleanup".

I'll take a look at the CMake documentation.

Thanks.

Comment by Andrew Morrow (Inactive) [ 09/Feb/18 ]

Just to clarify, when you say "want to integrate MongoDB and the Mongo C++ driver with this code", you really mean just the C++ driver right? Not the server source code? As written it is a little unclear. But I'm going to reply assuming that you really mean that you want to integrate the C++ driver into your 32-bit code so that you can talk to a remote MongoDB server.

As far as I know, there is no reason that the driver will not work in 32-bit mode. You will however, need to compile it (and the C driver and libbson) in 32-bit mode as well. You will need to pass the -m32 flag into the C driver build when using autotools or CMake, and into the C++ driver when using CMake. For CMake you can do this by using the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS to incorporate the -m32 flag into the compiler invocations used when building the drivers. Please consult the CMake documentation for more details on how to do this.

Comment by Adwait Lele [ 09/Feb/18 ]

In the description, the first sentence should say:

I have some code that I compile using the -m32 option with g++. The software is 32-bit so it needs to be compiled as such. I want to integrate MongoDB and the Mongo C++ driver with this code.

I forgot that JIRA uses "+" to format underlines.

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