Search code examples
clinuxredhatlibconfig

Build 'libconfig' as a 32-bit library


I am trying to use the libconfig (http://www.hyperrealm.com/libconfig/ ) for a little utility I am trying to write. I am trying to build libconfig then copy the library file (libconfig.a) to my utility's directory. When I build my utility I get warnings about the architecture being incompatible. Here is one of the specific warning messages I receive.

/usr/bin/ld: warning: i386:x86-64 architecture of input file 'libconfig.a(libconfig_la-libconfig.o)' is incompatible with i386 output

I am building on a Red Hat Enterprise Linux Server release 5.10 machine (uname -m produces 'x86_64'). I tried building libconfig with the following:

configure --disable-cxx CFLAGS='-m32' LDFLAGS='-m32'

But unfortunately, this didn't seem to produce the correct library as I still see the same warnings. There are other utilities that are created during the build process and all utilities share make common make directives which are specifying CFLAGS = -m32 -Wextra -Wall -Werror -Os and LDFLAGS = -m32, so I am unable to change this behavior.

I have also tried configure --disable-cxx CFLAGS='-arch i386' LDFLAGS='-arch i386, but this command line will not build the library.

Does anyone know how to build the libconfig as a 32-bit library to be consumed correctly.

Thanks,
Mark


Solution

  • The configure script will ignore arguments like CFLAGS= when passed on the command line. You need to set them for the invocation of configure, i.e. something like:

    env CFLAGS=-m32 LDFLAGS=-m32 ./configure --disable-cxx
    

    When this is done, all the symbols listed in the resulting lib/.libs/libconfig.a are listed with 32-bit addresses when the library is rebuilt.

    Note in the configure script help output it does say:

    Some influential environment variables:

    which means that they need to be environment variables, not passed in as parameters to the command