![](/img/trans.png)
[英]Compiling my c++ program: clang: error: linker command failed with exit code 1 (use -v to see invocation)
[英]Getting error clang: error: linker command failed with exit code 1 (use -v to see invocation) while compile C++ file from terminal
我收到这个错误
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 ++代码。
我认为这可能与XCode编译器冲突?
不能。关键是gcc
命令还能够编译从.cpp
文件扩展名检测到的C ++代码,尽管libstdc++.a
不会自动链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.