c++ libdl.so: Can't open shared library in 32bit application

902 views Asked by At

I am writing a little project in which I want to call a function from a shared library. For that I want to use libdl.so's dlopen() function.

I have everything set up so that it will work just fine when I build and run it as a 64bit application. However as soon as I am compiling it as a 32bit application and then try to run it, it won't be able to load any library.

dlopen() simply returns null and a call to dlerror() reveals

libtbbmalloc.so.2: cannot open shared object file: No such file or directory

Now I am guessing that I have to somehow install a 32bit version of that library but I can't find it in the package manager and what I have found online isn't too helpful either.

Does someone know that the problem is and/or how I could fic it?


I am building my project via cmake v3.10 and in the CMakeLists.txt I am using this instructions for 32bit:

set_target_properties(clib PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
target_link_libraries(clib /usr/lib32/libdl.so)

I have installed the package g++-multilib and my g++ version is 7.3.0.

I am attempting to build my program on Linux Mint 18.3 (6bit).

1

There are 1 answers

0
Raven On BEST ANSWER

With the help of @Lorinczy Zsigmond in the comments, I was able to find the problem: I had to install the packages libtbb-dev:i836 and libz-dev:i836 in order for the function loading to work properly.