[CMake] Finding 32bit libs on 64bit Ubuntu install

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon Apr 25 16:01:47 EDT 2016


On 2016-04-25 14:06-0400 Nick Deubert wrote:

> On Fri, Apr 22, 2016 at 5:08 PM, Alan W. Irwin
> <irwin at beluga.phys.uvic.ca> wrote:
>> On 2016-04-22 14:59-0400 Nick Deubert wrote:
>>
>>> 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.
>>
>>
>> CMake 3.0.2 is pretty old, and there were some find and other issues
>> for early CMake-3 versions.  I don't know whether any of those issues
>> are relevant to the issue you are discussing. Nevertheless, as an
>> experiment (and to make sure your eventual solution works for the
>> latest CMake) I would suggest you try building and using the latest
>> released version of CMake, 3.5.2, to see if that makes any difference.
>>
>> Alan
>
> Ok I upgraded to 3.2.2 which is the latest ubuntu 15.10 offers (I will
> try 16.04 w/3.5.1 soon), but I get the same issue.

> Is my syntax all correct as far as you can tell?

Hi Nick:

The syntax is OK _as far as I can tell_, but I did notice one important
issue in the libdl information you supplied with your original post which is
your 64-bit version of libdl is

-- DL_LIBRARY is /usr/lib/x86_64-linux-gnu/libdl.so

but there is no libdl.so in your 32-bit directory listings.  The closest
you come is

/lib/i386-linux-gnu/libdl.so.2 -> libdl-2.21.so

but that doesn't cut it, and you need a development symlink (provided
by the development version of a library package) that defines a 32-bit
libdl.so symlink that can be found by CMake. Such symlink would
ordinarily be supplied by a Ubuntu development package.  I don't have
Ubuntu installed myself, but Ubuntu is based on Debian, and for Debian
jessie the package name is libc6-dev-i386, and it contains the

/usr/lib32/libdl.so

symlink.  So look for a similarly named package for Ubuntu, verify it contains
libdl.so  (I did that on Debian using "apt-file search libdl.so") and install it.

I haven't looked at the other 32-bit libraries you are trying to
find, but I assume there are similar "did not install development
version of package" issues for those as well.

If installing the correct development versions of the 32-bit libraries
does not completely solve your issue, then my advice is

1. When faced with a CMake issue build and install the latest CMake
(don't wait for Ubuntu to package it up)
to help you illustrate the problem.  Building the latest version of
CMake is straightforward.  You can use an older version of cmake to
do that or else use the bootstrap script (mentioned at
<https://cmake.org/download/> to build on Unix platforms that don't
have any cmake version available.

2. make a really simple test project to illustrate the problem, e.g.,

cmake_minimum_required(VERSION 3.5.2 FATAL_ERROR)
project(test C)
find_library(DL_LIBRARY dl)
message(STATUS DL_LIBRARY = ${DL_LIBRARY})

I tried that project here (with minimum 3.4.3 since that is the latest
version of CMake I happen to have built here [with the bootstrap
script by the way]) with the following (good) results:
-- The C compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- DL_LIBRARY=/usr/lib/x86_64-linux-gnu/libdl.so
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/test_cmake/build_dir

I assume you would get similarly good results with this simple project
in the 32-bit case once you have installed the relevant development
packages for your 32-bit libraries, but you should check that.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list