0.交叉编译链的安装和配置:
详见:https://blog.youkuaiyun.com/markton1990/article/details/86073551
以使用arm-linux-gnueabihf-gcc为例。
1.动态库/静态库/可执行程序的切换
1.1 C/C++ Build->Build Artifact,在artifact type处,可以设置是生成可执行文件,静态库,动态库。
2.使用交叉编译工具链
2.1 C/C++ Build->GCC C Compiler,在Command处,填写arm-linux-gnueabihf-gcc。
2.2 C/C++ Build->GCC C Compiler->Miscellaneous,在other flags处,加上-fPIC。
3 GCC C Linker
3.1 在Command处,填写arm-linux-gnueabihf-gcc。
3.2 在Libraries处,添加所依赖的库(如果是生成动态库,若依赖系统库,需手动添加进去,如果生成的静态库,则不需要)。
可能遇到的问题:
1)arm平台编译动态库报 relocation R_ARM_MOVW_ABS_NC:2.2是这个问题的解决方法。
2)relocation R_X86_64_32S against `base' can not be used when making a shared object; recompile with -fPIC:2.2是其解决方法。
2)eclipse出现的错误:Relocations in generic ELF (EM: 40):是由于编译链使用混淆,3.1是其解决方法。