0
我正在使用Mac OSX 10.11 El Capitan
。体系结构x86_64的未定义符号:El Capitan
此前我使用的是OSX 10.10
。我的旧版OSX我运行的是gcc 4.9
和g++ 4.9
。但升级到OSX 10.11
后,所有C++程序开始无法编译。
然后我在OSX 10.11
切换回gcc 4.2
和我收到以下错误:
Undefined symbols for architecture x86_64:
"Graph::BFS(int)", referenced from:
_main in BFS-e06012.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我尝试了所有的答案。我试过这些命令来运行:
$ g++ -stdlib=libstdc++ BFS.cc -o BFS
$ g++ -lstdc++ BFS.cc -o BFS
$ gcc -lstdc++ BFS.cc -o BFS
$ g++ BFS.cc
但是没有什么适合我的。
当我在外壳上启动gcc --version
。我得到这个:
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.2.0
Thread model: posix
我试图运行是BFS.cc
这是继程序:
/*
* Algo: BFS
*/
#include <iostream>
#include <list>
using namespace std;
class Graph {
int V;
list<int> *adj;
public:
Graph(int V);
void addEdge(int v, int w);
void BFS(int s);
};
Graph::Graph(int V) {
this->V = V;
adj = new list<int> [V];
}
void Graph::addEdge(int v, int w) {
adj[v].push_back(w);
}
int main(int argc, char const *argv[]) {
Graph g(4);
g.addEdge(0, 1);
g.addEdge(0, 2);
g.addEdge(1, 2);
g.addEdge(2, 0);
g.addEdge(2, 3);
g.addEdge(3, 3);
cout << "Following is Breadth First Traversal (starting from vertex 2) \n";
g.BFS(2);
return 0;
}
谁能帮助我在这?
实现就在那里。我错过了复制它。 –
然后这是另一个问题。你必须检查你发布的内容,现在完全由你来修改这个问题。 –