b0ti
b0ti

Reputation: 2329

Configure fails to detect proper ld on a 64-bit system with 32-bit userland

I have an i386 debian system running in an lxc container. The userland is 32 bit, the kernel is 64 bit. Thus configure detects this:

checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu

Probably this is taken from the output of uname -m

I have a package which builds fine with gcc and the result is a proper 32 bit binary. Unfortunately in another c++ project I get this:

configure:8595: checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries

From here on the linker is using this switch and thus will try to link 64 bit libs instead of 32 bit and it fails:

/usr/bin/ld: skipping incompatible /usr/lib/libboost_program_options.so when searching for -lboost_program_options
/usr/bin/ld: skipping incompatible /usr/lib/libboost_program_options.a when searching for -lboost_program_options
/usr/bin/ld: cannot find -lboost_program_options
collect2: ld returned 1 exit status

Though the library .so file is the proper 32 bit ELF:

file /usr/lib/libboost_program_options.so.*      
/usr/lib/libboost_program_options.so.1.42.0: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, stripped

What's odd is that configure works fine for the other project and the linker is detected correctly to use the proper arch (elf_i386):

checking whether the gcc linker (/usr/bin/ld -m elf_i386) supports shared libraries... yes

Any hints?

Upvotes: 5

Views: 6954

Answers (2)

Fredo
Fredo

Reputation: 31

I just remove unknown for the syntax of command. The problem is the target: /usr/local/libexec/gcc/x86_64-unknown-linux-gnu/ An idea to reconfigure target in a conf flie?

This works for me:

Replace: ./configure --host=x86_64-unknown-linux-gnu --build=x86_64-unknown-linux-gnu \ --target=x86_64-unknown-linux-gnu --options...

By: ./configure --host=x86_64-linux-gnu --build=x86_64-linux-gnu --options...

Upvotes: 3

Employed Russian
Employed Russian

Reputation: 213897

Probably this is taken from the output of uname -m

This configure script is clearly confused.

To un-confuse it, tell it exactly what you want it to do:

./configure --host=i686-unknown-linux-gnu --build=i686-unknown-linux-gnu \
  --target=i686-unknown-linux-gnu

Upvotes: 1

Related Questions