[CMake] 32 bits compilation on x64 platform - how to find system libraries

Marcel Loose loose at astron.nl
Mon Dec 7 09:12:27 EST 2009


On Mon, 2009-12-07 at 14:18 +0100, Olivier Pierard wrote:
> Marcel Loose wrote:
> > On Mon, 2009-12-07 at 13:19 +0100, Mathieu Malaterre wrote:
> >   
> >> On Mon, Dec 7, 2009 at 11:43 AM, Marcel Loose <loose at astron.nl> wrote:
> >>     
> >>> Hi Olivier,
> >>>
> >>> I think you need to set the global property FIND_LIBRARY_USE_LIB64_PATHS
> >>> to OFF.
> >>>
> >>> BTW, I disagree with Mathieu that building 32-bit libraries/executables
> >>> on a 64-bit system is cross-compilation. These binaries can be run
> >>> without a problem on the host system. So, IMHO, you don't need a
> >>> toolchain file. The only thing you have to do is instruct gcc/g++ to
> >>> generate 32-bit objects/binaries, using the -m32 option, and tell CMake
> >>> to look in lib instead of lib64 by setting the aforementioned property.
> >>>       
> >> There is two things from the top of my head:
> >> 1. ia64 which is not x86 compatible
> >> 2. You still need a libz/libpng/libjpeg compiled as 32bits on your
> >> amd64 system...
> >>
> >> I think the project needs to be self contained (convenient libs)
> >> otherwise to get it compiled using the -m32 trick
> >>
> >> 2cts
> >>     
> >
> > Hi Mathieu
> >
> > Indeed, ia64 is not x86 compatible. I thought that Olivier was using a
> > x86_64 processor. Most 64-bit distros (for x86_64 that is) also provide
> > 32-bit libs/binaries.
> >   
> Thanks guys for your insights.  I'm effectively working on a x86_64 with
> 32-bits pre-compiled libs provided by Suse in folder /usr/lib/ while
> 64-bits libraries are in /usr/lib64/.
> 
> Solution proposed by Marcel seemed perfectly suitable for me.  So I tried:
> set(FIND_LIBRARY_USE_LIB64_PATHS OFF)
> ...
> find_library(FLTK_LIB_TEST NAMES fltk)
> message(FIND_LIBRARY_USE_LIB64_PATHS: ${FIND_LIBRARY_USE_LIB64_PATHS})
> message(FLTK_LIB_TEST: ${FLTK_LIB_TEST})
> 
> And with 'cmake -U "*LIB*" ..', I get:
> FIND_LIBRARY_USE_LIB64_PATHS:OFF
> FLTK_LIB_TEST:/usr/lib64/libfltk.a
> 
> Of course, libfltk.a is well in both folders /usr/lib/ and /usr/lib64/.
> 
> Olivier
> > Best regards,
> > Marcel Loose.
> >
> >
> >
> >

Hi Olivier,

FIND_LIBRARY_USE_LIB64_PATHS is a property. Set it like this:

  set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF)

If you do, you'll see that CMake will find /usr/lib/libfltk.a.

Best regards,
Marcel Loose.




More information about the CMake mailing list