Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking with x86 shared library on Linux x64

I'm trying to link with x86 shared library on x64 Ubuntu 11.04 Natty Narwhal but I get the following message:

/usr/bin/ld: skipping incompatible ./bin/libshared.so when searching for -lshared
/usr/bin/ld: cannot find -lshared

Some details:
The shared library name is libshared.so
The shared library is build on x86 OS.
I have installed lib32stdc++6.
The makefile looks like this:

test: main.o
    g++ -mi386linux -L./bin -lshared main.o -o test

main.o: main.cpp
    g++ -m32 -c main.cpp -o main.o

Any ideas?

Edit: After changing -mi386linux flag to -m32 I got this error:

/usr/bin/ld: cannot find -lshared  
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status

running locate I found libstdc++.so in the following places:

/usr/lib/x86_64-linux-gnu/libstdc++.so.6  
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.14  
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5/libstdc++.so  
/usr/lib32/libstdc++.so.6  
/usr/lib32/libstdc++.so.6.0.14
like image 827
Ohad Horesh Avatar asked Oct 25 '22 06:10

Ohad Horesh


1 Answers

I'm not sure what the -mi386linux is supposed to be about, but if you replace it by -m32 on the link line then I suspect this will work.

like image 140
TomH Avatar answered Oct 27 '22 09:10

TomH