1

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

timrau
  • 22,578
  • 4
  • 51
  • 64
lordhog
  • 3,427
  • 5
  • 32
  • 43

1 Answers1

2

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

Anya Shenanigans
  • 91,618
  • 3
  • 107
  • 122
  • Petesh, thanks for the information. Unfortunately, I am still unable to create the 32-bit library. I failed to mentioned that my beloved IT dept has everyone using tsch by default, so the `evn CFLAGS-m32 LDFLAGS=-32` does not work. I tried setting the env variable in my startup script (/.cshrc) with setenv, but that doesn't work either. I never see the message that you indicated. I also tried creating a script with a `#!/bin/bash` with the command you listed above and that didn't work either. – lordhog Aug 23 '14 at 13:15
  • @lordhog - since the `-m32` will also affect linking, I suggest you try passing: `env CC="gcc -m32" ./configure ...` – Brett Hale Aug 23 '14 at 13:39
  • @BrettHale, thanks for showing me how to correctly issue the command within tsch. Once the command was formatted correctly the configure command worked and then `make` built the correct library. I tried both command line versions (@Petesh and @BrettHale) and both created a library that worked with my utility. They were not binary equivalent though. I am not sure what the differences are or how to determine that, but diff does tell me they are different. I can't thank @BrettHale and @Petesh enough. – lordhog Aug 24 '14 at 12:01