当前位置: 技术问答>linux和unix
使用ld链接器出现cannot find entry symbol __start问题
来源: 互联网 发布时间:2016-10-06
本文导语: 我在使用链接器时发生错如下,不知道怎么解决,期待高手指教! ./ld -s -o exe ji4.o gebp.o main.o ./ld: warning: cannot find entry symbol __start; defaulting to 00000000100000c0 main.o: In function `main': main1.c:(.text+0x34): undefined re...
我在使用链接器时发生错如下,不知道怎么解决,期待高手指教!
./ld -s -o exe ji4.o gebp.o main.o
./ld: warning: cannot find entry symbol __start; defaulting to 00000000100000c0
main.o: In function `main':
main1.c:(.text+0x34): undefined reference to `atoi'
main1.c:(.text+0x54): undefined reference to `atoi'
main1.c:(.text+0x74): undefined reference to `atoi'
main1.c:(.text+0x94): undefined reference to `atoi'
main1.c:(.text+0xbc): undefined reference to `atoi'
main.o:main1.c:(.text+0xe4): more undefined references to `atoi' follow
main.o: In function `set_Matrix':
main1.c:(.text+0x1c8): undefined reference to `rand'
main.o: In function `test_Goto':
main1.c:(.text+0x2e8): undefined reference to `malloc'
main1.c:(.text+0x304): undefined reference to `malloc'
main1.c:(.text+0x320): undefined reference to `malloc'
main1.c:(.text+0x35c): undefined reference to `puts'
main1.c:(.text+0x36c): undefined reference to `exit'
main1.c:(.text+0x37c): undefined reference to `time'
main1.c:(.text+0x38c): undefined reference to `srand'
main1.c:(.text+0x448): undefined reference to `gettimeofday'
main1.c:(.text+0x4a8): undefined reference to `gettimeofday'
main1.c:(.text+0x544): undefined reference to `printf'
main1.c:(.text+0x554): undefined reference to `free'
main1.c:(.text+0x564): undefined reference to `free'
main1.c:(.text+0x574): undefined reference to `free'
main.o: In function `comp_DGEMM':
main1.c:(.text+0xf44): undefined reference to `gettimeofday'
main1.c:(.text+0xfa4): undefined reference to `gettimeofday'
main1.c:(.text+0x1080): undefined reference to `printf'
./ld -s -o exe ji4.o gebp.o main.o
./ld: warning: cannot find entry symbol __start; defaulting to 00000000100000c0
main.o: In function `main':
main1.c:(.text+0x34): undefined reference to `atoi'
main1.c:(.text+0x54): undefined reference to `atoi'
main1.c:(.text+0x74): undefined reference to `atoi'
main1.c:(.text+0x94): undefined reference to `atoi'
main1.c:(.text+0xbc): undefined reference to `atoi'
main.o:main1.c:(.text+0xe4): more undefined references to `atoi' follow
main.o: In function `set_Matrix':
main1.c:(.text+0x1c8): undefined reference to `rand'
main.o: In function `test_Goto':
main1.c:(.text+0x2e8): undefined reference to `malloc'
main1.c:(.text+0x304): undefined reference to `malloc'
main1.c:(.text+0x320): undefined reference to `malloc'
main1.c:(.text+0x35c): undefined reference to `puts'
main1.c:(.text+0x36c): undefined reference to `exit'
main1.c:(.text+0x37c): undefined reference to `time'
main1.c:(.text+0x38c): undefined reference to `srand'
main1.c:(.text+0x448): undefined reference to `gettimeofday'
main1.c:(.text+0x4a8): undefined reference to `gettimeofday'
main1.c:(.text+0x544): undefined reference to `printf'
main1.c:(.text+0x554): undefined reference to `free'
main1.c:(.text+0x564): undefined reference to `free'
main1.c:(.text+0x574): undefined reference to `free'
main.o: In function `comp_DGEMM':
main1.c:(.text+0xf44): undefined reference to `gettimeofday'
main1.c:(.text+0xfa4): undefined reference to `gettimeofday'
main1.c:(.text+0x1080): undefined reference to `printf'
|
./ld -s -o exe ji4.o gebp.o main.o -lc
这样可以通过链接,但是运行会出错。
-lc的意思是把libc.a链接进去,那些atoi、malloc之类的函数都在这个库里
这样可以通过链接,但是运行会出错。
-lc的意思是把libc.a链接进去,那些atoi、malloc之类的函数都在这个库里
|
这几个函数是C语言基础库里的,也就是libc.so里的.
没有__start是因为c程序以main为主函数,汇编以start为主函数入口
你改用gcc连接就行了,
gcc -o exe ji4.o gebp.o main.o
这样就行了.
如果你非用ld,自己把libc.so连接上吧.
没有__start是因为c程序以main为主函数,汇编以start为主函数入口
你改用gcc连接就行了,
gcc -o exe ji4.o gebp.o main.o
这样就行了.
如果你非用ld,自己把libc.so连接上吧.
|
main.o ?
main1.c ?
main1.c中缺少一些头文件,添加试试
#include
#include
#include
#include
main1.c ?
main1.c中缺少一些头文件,添加试试
#include
#include
#include
#include