Bla*_*est 34 linux program-entry-point undefined-reference
我正在将应用程序从Solaris移植到Linux
链接的目标文件没有定义main().但是在Solaris中正确地完成了编译和链接,并生成了可执行文件.在Linux中我得到这个错误
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
Run Code Online (Sandbox Code Playgroud)
我的问题是,我不能包含新的.c/.o文件,因为它是一个巨大的应用程序,并已运行多年.我怎样才能摆脱这个错误?
makefile的代码提取:
RPCAPPN = api
LINK = cc
$(RPCAPPN)_server: $(RPCAPIOBJ)
$(LINK) -g $(RPCAPIOBJ) -o $(RPCAPPN)_server $(IDALIBS) $(LIBS) $(ORALIBS) $(COMMONLIB) $(LIBAPI) $(CCLIB) $(THREADLIB) $(DBSERVERLIB) $(ENCLIB)
Run Code Online (Sandbox Code Playgroud)
Pau*_*l R 35
尝试添加-nostartfiles到链接器选项,即
$(LINK) -nostartfiles -g ...
Run Code Online (Sandbox Code Playgroud)
从gcc文档:
-nostartfiles
Do not use the standard system startup files when linking. The standard system libraries are used normally, unless -nostdlib or -nodefaultlibs is used.
Run Code Online (Sandbox Code Playgroud)
这导致crt1.o不被链接(默认情况下它通常是链接的) - 通常仅在您实现自己的_start代码时使用.