0

How to build mongo-c-driver for 32bit linux on a 64bit linux machine using cmake? I'm trying to build it with -DCMAKE_TOOLCHAIN_FILE and all packages are installed with i386. Error when trying to build:

/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libssl.so: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
gmake[2]: *** [src/libmongoc/CMakeFiles/mongoc_shared.dir/build.make:2012: src/libmongoc/libmongoc-1.0.so.0.0.0] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1566: src/libmongoc/CMakeFiles/mongoc_shared.dir/all] Error 2
gmake: *** [Makefile:171: all] Error 2
  • Which toolchain do you use? According to the path `/usr/lib/x86_64-linux-gnu/libssl.so`, your toolchain allows to search 64-bit binaries, which is not correct. Have you checked solutions in other questions (e.g. [question1](https://stackoverflow.com/questions/1272357/how-to-compile-a-32-bit-binary-on-a-64-bit-linux-machine-with-gcc-cmake), [question2](https://stackoverflow.com/questions/5805874/the-proper-way-of-forcing-a-32-bit-compile-using-cmake)) about building CMake project for 32-bit platform? – Tsyvarev Jun 16 '23 at 18:32
  • I tried to change search path and know I'm getting this warning: `CMake Warning at src/libmongoc/CMakeLists.txt:819 (add_executable): Cannot generate a safe runtime search path for target mongoc-ping because files in some directories may conflict with libraries in implicit directories: runtime library [libsasl2.so.2] in /usr/lib/i386-linux-gnu may be hidden by files in: /usr/lib/x86_64-linux-gnu Some of these libraries may not be found correctly. Call Stack (most recent call first): src/libmongoc/CMakeLists.txt:1006 (mongoc_add_example)` – morioki Jun 16 '23 at 19:06
  • So, CMake treats `/usr/lib/x86_64-linux-gnu` as "implicit directory" for the runtime loader. It seems that your toolchain file is not correct again... – Tsyvarev Jun 16 '23 at 21:05

0 Answers0