ld:入口点(起点)未定义.通常在crt1.o中用于体系结构x86_64

ld: entry point (start) undefined. Usually in crt1.o for architecture x86_64

本文关键字:crt1 用于 体系结构 x86 入口 起点 未定义 ld      更新时间:2023-10-16

我已经为我的终端编写了一个简单的hello-world函数来编译,并且我一直在获得

    587216304:EECS280 jacobmyers$ g++ hello.cpp -o hell
    ld: entry point (start) undefined.  Usually in crt1.o for architecture x86_64
    collect2: error: ld returned 1 exit status

我使用的是gcc 4.9.2版本,我在网上找不到任何能帮我解决这个问题的东西。我很确定这与编译的I/O有关。

另外,这里的代码证明我可以写一个简单的hello世界函数,应该很好哈哈

    #include <iostream>
    #include <string>
    using namespace std;

    int main()
    {
        cout<<"hello world";
    return  0;
    }

提前感谢!

嗯,for architecture x86_64
尝试使用-m32:g++ hello.cpp -o hello -m32进行编译。

此外,我注意到您使用了GCC 4.9.2。我使用GCC 4.9.1编译了完全相同的代码(只是复制粘贴),它的编译和执行都很完美。

更新:对此感到困惑:OSX GCC安装程序
卸载当前GCC并下载安装程序并安装它!试试这个,我自己也用过,很好。