C++ gcc链接器和OGDF“;未定义对`ogdf::Initialization::Initialization()'&引用;

C++ gcc链接器和OGDF“;未定义对`ogdf::Initialization::Initialization()'&引用;,c++,ogdf,C++,Ogdf,我正在努力工作,看看它是否适合我的项目,但我有一个样本程序的问题 我正在尝试编译: 但是我得到了以下错误 /tmp/ccbpkfdt.o: In function `main': test2.cpp:(.text+0x12): undefined reference to `ogdf::Graph::Graph()' test2.cpp:(.text+0x2e): undefined reference to `ogdf::randomSimpleGraph(ogdf::Graph&,

我正在努力工作,看看它是否适合我的项目,但我有一个样本程序的问题

我正在尝试编译:

但是我得到了以下错误

/tmp/ccbpkfdt.o: In function `main':
test2.cpp:(.text+0x12): undefined reference to `ogdf::Graph::Graph()'
test2.cpp:(.text+0x2e): undefined reference to `ogdf::randomSimpleGraph(ogdf::Graph&, int, int)'
test2.cpp:(.text+0x4e): undefined reference to `ogdf::AcyclicSubgraphModule::callAndReverse(ogdf::Graph&)'
test2.cpp:(.text+0x62): undefined reference to `ogdf::Graph::writeGML(char const*) const'
test2.cpp:(.text+0x7f): undefined reference to `ogdf::Graph::~Graph()'
test2.cpp:(.text+0xa1): undefined reference to `ogdf::Graph::~Graph()'
/tmp/ccbpkfdt.o: In function `__static_initialization_and_destruction_0(int, int)':
test2.cpp:(.text+0xfb): undefined reference to `ogdf::Initialization::Initialization()'
test2.cpp:(.text+0x112): undefined reference to `ogdf::Initialization::~Initialization()'
/tmp/ccbpkfdt.o: In function `ogdf::DfsAcyclicSubgraph::DfsAcyclicSubgraph()':
test2.cpp:(.text._ZN4ogdf18DfsAcyclicSubgraphC2Ev[_ZN4ogdf18DfsAcyclicSubgraphC5Ev]+0x16): undefined reference to `vtable for ogdf::DfsAcyclicSubgraph'
/tmp/ccbpkfdt.o: In function `ogdf::DfsAcyclicSubgraph::~DfsAcyclicSubgraph()':
test2.cpp:(.text._ZN4ogdf18DfsAcyclicSubgraphD2Ev[_ZN4ogdf18DfsAcyclicSubgraphD5Ev]+0xb): undefined reference to `vtable for ogdf::DfsAcyclicSubgraph'
collect2: error: ld returned 1 exit status
我尝试编译hello world,其中包含来自OGDF的内容,但我仍然得到:

undefined reference to `ogdf::Initialization::Initialization()'

我认为我没有正确链接或其他什么?

当使用OGDF作为共享库时,必须使用-DOGDF_DLL构建程序


请参见此处:

在与库链接时,您必须非常小心键入内容的顺序。 尝试将
test2.cpp
放在
-lOGDF
之前,如下所示:

g++ -pthread -I ./OGDF/ -L ./OGDF/_release/ test2.cpp -lOGDF 

你让它工作了吗?我添加了一个解决方案。试试看:)
undefined reference to `ogdf::Initialization::Initialization()'
g++ -pthread -I ./OGDF/ -L ./OGDF/_release/ test2.cpp -lOGDF