问题:
book@100ask:~/02_options$ arm-linux-gnueabihf-gcc -shared -o libsub.so sub.o
/home/book/100ask_am335x/ToolChain/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/6.2.1/../../../../arm-linux-gnueabihf/bin/ld: sub.o: relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
sub.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
解决方案:
book@100ask:~/02_options$ arm-linux-gnueabihf-gcc -fPIC -c sub.o sub.c
sub.c: In function 'sub_fun':
sub.c:3:8: warning: implicit declaration of function 'printf' [-Wimplicit-function-decl aration]
printf("Sub fun!\n");
^~~~~~
sub.c:3:8: warning: incompatible implicit declaration