【发布时间】:2021-07-06 17:46:21
【问题描述】:
我最近在终端下载了 g++ 编译器后,在我的 m1 mac 中下载了 vs 代码,然后我下载了扩展 C/C++ IntelliSence 和 Code Runner。之后,我编写了一个简单的 Hello World 程序,但它给了我一个错误。
代码:
#include<iostream>
using namespace std;
void main()
{
cout<<"Hello World";
}
输出:
[Running] cd "/Users/mohammedalif/HelloWorld/" && g++ main.cpp -o main &&
Undefined symbols for architecture arm64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[Done] exited with code=1 in 0.22 seconds
这是我和代码一起得到的输出截图
这是我得到的,而不是简单的 Hello World 输出。
我应该怎么做才能解决这个问题???
【问题讨论】:
-
void main()不是 main 的有效签名。相关:https://stackoverflow.com/questions/4207134/what-is-the-proper-declaration-of-main-in-c 这个在线 g++ 也显示了一个错误:https://ideone.com/comNhN
标签: c++ visual-studio-code architecture linker apple-m1