本帖最后由 sunsili 于 2023-8-14 21:37 编辑 编译时遇到了错误: gcc -o fork_test.a fork_test.c /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' collect2: error: ld returned 1 exit status 分析要链接动态库 用命令: gcc -shared -g -o fork_test.a fork_test.c /usr/bin/ld: /tmp/cc1wgtVD.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC /tmp/cc1wgtVD.o: error adding symbols: Bad value collect2: error: ld returned 1 exit status 但又出现问题, 按提示要加参数 fPIC的, 但我没用 重新用原始命令编译: gcc -o fork_test.a fork_test.c 又OK了 |
|Archiver|手机版|深圳市光明谷科技有限公司|光明谷商城|Sunshine Silicon Corpporation ( 粤ICP备14060730号 ) |Sitemap
GMT+8, 2024-11-24 16:52 , Processed in 0.326493 second(s), 43 queries .
Powered by Discuz! X3.2 Licensed
© 2001-2013 Comsenz Inc.