Search code examples
shared-librariesgnucross-compilingautotoolslibtool

GNU/Libtool cross-compilation


I have very base question about GNU/Libtool. My project is build by GNU/autotools and contains the shared object build by GNU/Libtool. I want to compile the i386 shared object on the x86-64 machine, so I do:

$ ./configure --build=i386
checking for a BSD-compatible install... /usr/bin/install -c
...
checking whether to build shared libraries... no
checking whether to build static libraries... yes
...
config.status: executing depfiles commands
config.status: executing libtool commands
$

The configure script tell me the the shared libraries are not supported, and the make command fails. How to fix this cross-compile issue?

Should I find the answer in Libtool manual?


Solution

  • --build is typically for things like Canadian cross compilation. You probably want to use the --host option. You haven't specified the system type, but if ./config.guess gives something like:

    x86_64-apple-darwin or x86_64-pc-linux-gnu

    Then you would specifiy

    --host=i386-apple-darwin or i386-pc-linux-gnu

    Also - you may need to set some compiler flags to force 32-bit code generation. e.g.,

    env CC="gcc -m32" ./configure --host=....

    Often, the -m32 option is sufficient - you won't need to bother with the --host option.