[CMake] Finding 32bit libs on 64bit Ubuntu install
Nick Deubert
ndeubert at gmail.com
Fri Apr 22 14:59:41 EDT 2016
Hey everyone, I am trying to build and link some 32bit binaries on
Ubuntu 15.10 64bit, but no matter what combination of arguments I give
FIND_LIBRARY I cannot get it to use the 32bit libs. I have been
scouring the mailing lists and came up with all these things to try
but nothing has worked so far. I am using cmake 3.0.2. Please let me
know what I am missing. Thanks in advance for your help.
Nick
The relevant part of my cmake file:
Set(CFLAGS "-m32")
Set(CXXFLAGS "-m32")
Set(CMAKE_C_FLAGS "-m32")
Set(CMAKE_CXX_FLAGS "-m32")
Set(CMAKE_SHARED_LINKER_FLAGS "-m32")
Set(FIND_LIBRARY_USE_LIB64_PATHS OFF)
MESSAGE( STATUS "CMAKE_LIBRARY_PATH: " ${CMAKE_LIBRARY_PATH} )
MESSAGE( STATUS "CFLAGS: " ${CFLAGS} )
MESSAGE( STATUS "CXXFLAGS: " ${CXXFLAGS} )
MESSAGE( STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS} )
MESSAGE( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} )
MESSAGE( STATUS "CMAKE_SHARED_LINKER_FLAGS: " ${CMAKE_SHARED_LINKER_FLAGS} )
MESSAGE( STATUS "FIND_LIBRARY_USE_LIB64_PATHS: "
${FIND_LIBRARY_USE_LIB64_PATHS} )
FIND_LIBRARY(DL_LIBRARY NAMES dl PATHS ${LIB_PATH}
NO_DEFAULT_PATH)
FIND_LIBRARY(NL_LIBRARY NAMES nl PATHS ${LIB_PATH}
NO_DEFAULT_PATH)
FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthread PATHS ${LIB_PATH}
NO_DEFAULT_PATH)
MESSAGE(STATUS "DL_LIBRARY is ${DL_LIBRARY}")
MESSAGE(STATUS "NL_LIBRARY is ${NL_LIBRARY}")
MESSAGE(STATUS "PTHREAD_LIBRARY is ${PTHREAD_LIBRARY}")
The output I get:
-- CMAKE_LIBRARY_PATH: /lib/i386-linux-gnu
-- CFLAGS: -m32
-- CXXFLAGS: -m32
-- CMAKE_C_FLAGS: -m32
-- CMAKE_CXX_FLAGS: -m32
-- CMAKE_SHARED_LINKER_FLAGS: -m32
-- FIND_LIBRARY_USE_LIB64_PATHS: OFF
-- DL_LIBRARY is DL_LIBRARY-NOTFOUND
-- NL_LIBRARY is NL_LIBRARY-NOTFOUND
-- PTHREAD_LIBRARY is PTHREAD_LIBRARY-NOTFOUND
Without NO_DEFAULT_PATH:
-- DL_LIBRARY is /usr/lib/x86_64-linux-gnu/libdl.so
-- NL_LIBRARY is /lib/x86_64-linux-gnu/libnl.so
-- PTHREAD_LIBRARY is /usr/lib/x86_64-linux-gnu/libpthread.so
Proof that I have the 32bit libs installed:
$ ls -l /lib/i386-linux-gnu/*pthread*
-rwxr-xr-x 1 root root 137044 Feb 16 14:06
/lib/i386-linux-gnu/libpthread-2.21.so*
lrwxrwxrwx 1 root root 18 Feb 16 14:06
/lib/i386-linux-gnu/libpthread.so.0 -> libpthread-2.21.so*
$ ls -l /lib/i386-linux-gnu/*libnl*
-rw-r--r-- 1 root root 165936 Jul 15 2015 /lib/i386-linux-gnu/libnl-3.a
lrwxrwxrwx 1 root root 19 Jul 15 2015
/lib/i386-linux-gnu/libnl-3.so -> libnl-3.so.200.21.0
lrwxrwxrwx 1 root root 19 Jul 15 2015
/lib/i386-linux-gnu/libnl-3.so.200 -> libnl-3.so.200.21.0
-rw-r--r-- 1 root root 132852 Jul 15 2015
/lib/i386-linux-gnu/libnl-3.so.200.21.0
$ ls -l /lib/i386-linux-gnu/*libdl*
-rw-r--r-- 1 root root 13808 Feb 16 14:06 /lib/i386-linux-gnu/libdl-2.21.so
lrwxrwxrwx 1 root root 13 Feb 16 14:06
/lib/i386-linux-gnu/libdl.so.2 -> libdl-2.21.so
More information about the CMake
mailing list