crt1.o:在函数"_start"中:-在Linux中未定义对"main"的引用 [英] crt1.o: In function `_start': - undefined reference to `main' in Linux

查看:1225
本文介绍了crt1.o:在函数"_start"中:-在Linux中未定义对"main"的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将应用程序从Solaris移植到Linux

I am porting an application from Solaris to Linux

链接的目标文件没有定义main().但是在Solaris中正确进行了编译和链接,并生成了可执行文件.在Linux中,我收到此错误

The object files which are linked do not have a main() defined. But compilation and linking is done properly in Solaris and executable is generated. In Linux I get this error

    /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main' 

我的问题是,我无法包含新的.c/.o文件,因为它是一个庞大的应用程序,并且已经运行了很多年.如何摆脱这个错误?

My problem is, I cannot include new .c/.o files since its a huge application and has been running for years. How can I get rid of this error?

makefile的代码提取:

Code extractes of makefile:

RPCAPPN = api
LINK = cc 

    $(RPCAPPN)_server: $(RPCAPIOBJ)
            $(LINK) -g $(RPCAPIOBJ) -o $(RPCAPPN)_server $(IDALIBS) $(LIBS) $(ORALIBS) $(COMMONLIB) $(LIBAPI) $(CCLIB) $(THREADLIB) $(DBSERVERLIB) $(ENCLIB)

推荐答案

尝试将-nostartfiles添加到链接器选项中,即

Try adding -nostartfiles to your linker options, i.e.

$(LINK) -nostartfiles -g ...

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. 

这将导致crt1.o不被链接(通常默认情况下为链接)-通常仅在实现自己的_start代码时使用.

This causes crt1.o not to be linked (it's normally linked by default) - normally only used when you implement your own _start code.

这篇关于crt1.o:在函数"_start"中:-在Linux中未定义对"main"的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆