g++ -static -o app tmain.o -L. -ltapi
g++ -shared -fPIC -o libtapi.so tapi.o TGame.o //生成libtapi.so动态库文件
ar cr libtapi.a tapi.o TGame.o //生成libtapi.a静态库文件
-static-libgcc This option links the GNU libgcc library statically. It is the opposite of option shared-libgcc.
-m32
-m64
Generate code for 32-bit or 64-bit environments of Darwin and SVR4 targets (including GNU/Linux). The 32-bit
environment sets int, long and pointer to 32 bits and generates code that runs on any PowerPC variant. The
64-bit environment sets int to 32 bits and long and pointer to 64 bits, and generates code for PowerPC64, as
for -mpowerpc64.
ldd 可执行程序能查看程序链接的库
-o -o1 -o2 -o3 优化代码
***********代码调试
-g -o0表示不进行代码优化
-fPIC 产生位置无关的代码,一般创建共享库时需要
GNU Tools使用
显示归档文件中的内容 ar -tv 或者 odjdump -a
nm 能够列出目标文件中的符号
size 能够列出目标文件各节的大小
本文详细介绍了如何使用静态库生成可执行文件,并通过多种命令行工具进行库文件的生成与链接,包括生成静态库libtapi.a、动态库libtapi.so,以及使用ldd检查可执行文件依赖的库。同时,提供了代码调试、优化和相关工具的使用说明。
3203

被折叠的 条评论
为什么被折叠?



