gpt4 book ai didi

c++ - 收到错误 clang : error: linker command failed with exit code 1 (use -v to see invocation) while compile C++ file from terminal

转载 作者:行者123 更新时间:2023-11-28 00:00:18 25 4
gpt4 key购买 nike

我遇到了这个错误

clang: error: linker command failed with exit code 1 (use -v to see invocation)

当我从终端编译简单的 cpp 文件时

gcc hello.cpp

这里是 hello.cpp 文件的内容:

#include <iostream>
using namespace std;

// main() is where program execution begins.

int main()
{
cout << "Hello World"; // prints Hello World
return 0;
}

我认为它可能与 XCode 编译器冲突?

最佳答案

gcc hello.cpp 应该是 g++ hello.cpp

gcc 用于编译和链接 C 代码,而 g++ 用于 C++ 代码。

I think it might conflict with XCode compiler?

没有。重点是 gcc 命令还能够编译从 .cpp 文件扩展名中检测到的 C++ 代码,尽管 libstdc++.a 不会不会自动链接。

关于c++ - 收到错误 clang : error: linker command failed with exit code 1 (use -v to see invocation) while compile C++ file from terminal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39588350/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com