当前位置: 首页 > news >正文

lazarus for arm32编译so链接出错

测试空的so project,编译时不使用cthreads,cmem编译链接正常能生成so文件。
library Project1;{$mode objfpc}{$H+}usesClasses{$ifdef UNIX}, cthreads,cmem{$endif}{ you can add units after this };beginend.

使用了cthreads后,编译时会出现链接出错:

D:\QFLazarus4.4\cross\bin-x86_64-win64\arm-linux\arm-linux-gnueabihf-ld.exe: D:\QFLazarus4.4\cross\lib\arm-linux\crtbegin.o: relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
D:\QFLazarus4.4\cross\lib\arm-linux\crtbegin.o: error adding symbols: Bad value
project1.lpr(16,1) Error: Error while linking

 

QQ_1770017438402

解决方法:
project-->project options-->Compiler options-->Custom options-->添加

-fPIC

QQ_1770017956714

 重新编译就可以生成so文件:

QQ_1770018120514