我是一个leda-6.3库用户。

我使用graphwin来操纵和显示图形,但是发现
graphwin方法在编译代码时未定义,尽管它们
在LEDA / incl / LEDA / graphics / graphwin.h中声明

所以我认为这是目标文件的问题。

#include <LEDA/graphics/graphwin.h>
#include <LEDA/graph/graph_alg.h>

using namespace leda;

int main()
{
GraphWin gw("LEDA Graph Editor");
node u=gw.new_node(point(100,100));
node v=gw.new_node(point(100,200));
gw.new_edge(u,v);

gw.display();
gw.get_window().read_mouse();

graph& G=gw.get_graph();
G.new_node();
gw.get_window().read_mouse();

gw.update_graph();
gw.get_window().read_mouse();

return 0;
}



  编译:g ++ -I $ LEDAROOT / incl -L $ LEDAROOT gw.cpp -lleda -lX11 -lm -o gw


错误:

/tmp/ccVHyRbL.o: In function `main':
gw.cpp:(.text+0x1e): undefined reference to `leda::GraphWin::GraphWin(char const*)'
gw.cpp:(.text+0x58): undefined reference to `leda::GraphWin::new_node(leda::point const&)'
gw.cpp:(.text+0xc6): undefined reference to `leda::GraphWin::new_node(leda::point const&)'
gw.cpp:(.text+0x11c): undefined reference to `leda::GraphWin::new_edge(leda::node_struct*, leda::node_struct*)'
gw.cpp:(.text+0x128): undefined reference to `leda::GraphWin::display()'
gw.cpp:(.text+0x17e): undefined reference to `leda::GraphWin::update_graph()'
collect2: ld returned 1 exit status

最佳答案

您正在使用哪个版本的LEDA?
请考虑免费版本的LEDA不包含GraphWin。
因此,它不包含GraphWin库,导致在编译程序时出现此类错误。

关于c++ - LEDA-6.3库,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6724449/

10-15 00:38