Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc-arm linking error: attempted static link of dynamic object

Tags:

c

qemu

gcc

linker

I am trying to compile a program with arm-linux-gnueabi-gcc containing neon instructions and executing it over Qemu. The code is,

#include <arm_neon.h>
void NeonTest(short int * __restrict a, short int * __restrict b, short int * __restrict z)
{
int i;
for (i = 0; i < 200; i++) {
z[i] = a[i] * b[i];
        }
}

I successfully do it without using -static flag. But Qemu does not execute/recognize an executable if -static flag is not used. So when I use -static to compile and link, I get the following error,

junaid@junaid755:~/code/c$ arm-linux-gnueabi-gcc -static -march=armv7-a -mtune=cortex-a9 -ftree-vectorize -mhard-float -mfloat-abi=softfp -mfpu=neon -ffast-math -mvectorize-with-neon-quad -S neon_test.c 
junaid@junaid755:~/code/c$ arm-linux-gnueabi-gcc -static -march=armv7-a -mtune=cortex-a9 -ftree-vectorize -mhard-float -mfloat-abi=softfp -mfpu=neon -ffast-math -mvectorize-with-neon-quad -c neon_test.s -o neon_test.o 
junaid@junaid755:~/code/c$ arm-linux-gnueabi-gcc -static -march=armv7-a -mtune=cortex-a9 -ftree-vectorize -mhard-float -mfloat-abi=softfp -mfpu=neon -ffast-math -mvectorize-with-neon-quad neon_test.o -o neon_test 
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/ld: attempted static link of dynamic object `/lib/ld-linux.so.3'
collect2: error: ld returned 1 exit status

I have tried the ermine, statifier and other softwares for portable linux applications. But the issue is they work on executables, while in my case the executable generation is causing error.

like image 637
junaids Avatar asked Nov 28 '25 11:11

junaids


1 Answers

The problem is solved when i installed arm-linux-gnueabihf-gcc on my system. Maybe additional packages installed may have resloved the problem. Now I use arm-linux-gnueabihf-gcc command instead of arm-linux-gnueabi-gcc. Now the exe file is statically linked. But the problem is not totally solved. On qemu it give segmentation fault now.

like image 158
junaids Avatar answered Nov 30 '25 05:11

junaids



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!