statical linking
Dear all!
I have to build a big software project on my x86 debian machine to run on MIPS (actually mipsel) hardware. I can build dynamical app, but the problem that my embedded platfom has uClibc and my development platform has a normal libc. I can't build uClibc for mipsel because I get a ton of errors in kernel headers. Right now I have no time to fig into uClinc and spend time trying to build it. I can build a "Hello world!" app statically linked and it runs flawlessly. If I build my project dynamically I have no problems. But when I build statically I have many errors that functions not found. Code:
mipsel-linux-gnu-gcc -static -L /usr/mipsel-linux-gnu/lib -lm -lpthread -L ../Lib/ -o ../Cmds//ETCP Rels//detc0cru.o Rels//detc0m2f.o Rels//detc0mai.o Rels//detc0soc.o Rels//detc0vru.o ../Lib//IsaNwl.o ../Lib//IsaSys.o ../Lib//ISysSoc.o I have libc.a, libm.a and libpthread.a. So my question - how can I avoid these errors? Why I get these errors? Why does libc.a is found but libm.a and libpthread.a don't? IsaSys.o it's a library actually but with an .o extension. My be I have to turn it to a normal library with .a extension? But it works with dynamic linking without problems. Any help will be highly appreciated. |
I found an answer to my prev question: for MIPS gcc must get `-pthread' parameter not '-lpthread'.
But I still don't know how to correct math functions which are not found: Code:
mipsel-linux-gnu-gcc -pthread -static -L /usr/mipsel-linux-gnu/lib -L ../Lib/ -lm -o ../Cmds//IsaVM Rels//dipl0lnk.o Rels//divm0mai.o ../Lib//IsaKer.o ../Lib//IsaSrv.o ../Lib//IsaIXL.o ../Lib//IsxlHsd.o ../Lib//IsxlEtcp.o ../Lib//IsxlRsi.o ../Lib//IsaNwl.o ../Lib//EtcpCmon.o ../Lib//RsiCmon.o ../Lib//IKvbHsd.o ../Lib//IKvbEtcp.o ../Lib//IsaSys.o ../Lib//ISysSoc.o ../Lib//ISysHbt.o |
Try taking away the trailing forward-slash. The paths in the output you provided appear to be invalid.
Code:
gcc ... -L ../Lib ... |
Hi!
I solved my problem by adding "/usr/mipsel-linux-gnu/lib/libm.a" at the end of commandline. Not a nice solution, but at least it works. I really don't understand why does this happen with static linking. |
Quote:
|
probably there is a libm.so in /usr/lib and there is no libm.a there.
The other problem can be you wrote -L../Lib (capital) instead of -L../lib. You know which one is the correct path. |
Quote:
2. I use cross compilation, so in my /usr/mipsel-linux-gnu/lib exist two libraries - libm.so and libm.a Dynamic linking is working, for the static linking I must specify the path to libm.a explicitly. That is the problem. I don't undertsand why doesn't mipsel-linux-gnu-gcc see the static lib. Code:
oleg@debian-vm:~$ ls -l /usr/mipsel-linux-gnu/lib/lib[cm].* |
oh, yes, one more thing: just move -lm to the end of the command, this should be the last one
|
Quote:
|
All times are GMT -5. The time now is 09:00 AM. |