首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gcc链接器和OGDF“未定义对`OGDF::Initialization::Initialization()‘的引用”

gcc链接器和OGDF“未定义对`OGDF::Initialization::Initialization()‘的引用”
EN

Stack Overflow用户
提问于 2013-12-03 21:30:25
回答 2查看 1.2K关注 0票数 3

我正在尝试让OGDF工作,看看它是否适合我的项目,但我在使用示例程序时遇到了问题。

我正在尝试编译this example program

代码语言:javascript
复制
#include <ogdf/basic/Graph.h>
#include <ogdf/basic/graph_generators.h>
#include <ogdf/layered/DfsAcyclicSubgraph.h>

using namespace ogdf;

int main()
{
    Graph G;
    randomSimpleGraph(G, 10, 20);
    DfsAcyclicSubgraph DAS;
    DAS.callAndReverse(G);
    G.writeGML("test.gml");

    return 0;
}

使用以下命令:

代码语言:javascript
复制
$g++ -pthread -I ./OGDF/ -L ./OGDF/_release/ -lOGDF test2.cpp 

但是我得到了以下错误

代码语言:javascript
复制
/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

我尝试使用来自OGDF的include编译hello world,但我仍然得到:

代码语言:javascript
复制
undefined reference to `ogdf::Initialization::Initialization()'

我想我的链接不正确还是怎么的?

EN

回答 2

Stack Overflow用户

发布于 2014-06-02 21:41:43

当你链接到一个库的时候,你必须非常小心你输入内容的顺序。尝试将test2.cpp放在-lOGDF之前,如下所示:

代码语言:javascript
复制
g++ -pthread -I ./OGDF/ -L ./OGDF/_release/ test2.cpp -lOGDF 
票数 2
EN

Stack Overflow用户

发布于 2014-04-18 16:13:54

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

查看此处:http://www.ogdf.net/doku.php/tech:defines

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20352535

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档