使用libgraph库进行“graphics.h”时出错

时间:2011-03-25 17:27:15

标签: c++ graphics

我试图在ubuntu上使用libgraph库来使用“graphics.h”作为示例程序。 但是在编译时我得到了这些错误:

g++ graph.cpp -o graph -lgraph 

/tmp/ccD6rrqg.o: In function `main':
graph.cpp:(.text+0x32): undefined reference to `initgraph'
graph.cpp:(.text+0x37): undefined reference to `cleardevice'
graph.cpp:(.text+0xf8): undefined reference to `grgetch'
graph.cpp:(.text+0xfd): undefined reference to `closegraph'
/tmp/ccD6rrqg.o: In function `bresen(int, int, int, int)':
graph.cpp:(.text+0x1f9): undefined reference to `putpixel'
graph.cpp:(.text+0x206): undefined reference to `delay'
collect2: ld returned 1 exit status

我是否需要添加更多链接器标志?这个程序适用于Windows,所以我认为程序本身是正确的。

我设法让它运行但是窗口崩溃了:

process_responses:断言`(((long)(dpy-> last_request_read) - (long)(dpy-> request))< = 0)'失败。 我也可以调整窗口大小全屏? thankx!

1 个答案:

答案 0 :(得分:0)

libgraph的installation instructions似乎有点...... 随意。图书馆应该只是明确地链接在:

g++ graph.cpp -o graph /path/to/libgraph.a

或安装的任何地方。

调查库g ++使用的另一种可能性:

 g++ -print-file-name=graph

虽然在我的系统上,它只是回显graph