crt1.o: In function `_start': - undefined reference to `main' in Linux

后端 未结 5 900
被撕碎了的回忆
被撕碎了的回忆 2020-12-01 02:50

I am porting an application from Solaris to Linux

The object files which are linked do not have a main() defined. But compilation and linking is done properly in Sol

5条回答
  •  执念已碎
    2020-12-01 03:34

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

    $(LINK) -nostartfiles -g ...
    

    From the gcc documentation:

    -nostartfiles
        Do not use the standard system startup files when linking. The standard system libraries are used normally, unless -nostdlib or -nodefaultlibs is used. 
    

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

提交回复
热议问题