如何在 Ubuntu 12.10 的 Netbeans 7.3 中使用 Stroustrup 的图形库(Simple_window.h、Graph.h、...)?
How can I use Stroustrup's graphics libraries (Simple_window.h, Graph.h, ...) in Netbeans 7.3 in Ubuntu 12.10?
每个人。我正在学习Bjarne Stroustrup的"使用C++编程原理和实践"一书。我在Ubuntu 12.10中使用Netbeans 7.3。我想在本书的第12章中构建并运行这个简单的图形程序。程序如下:
#include "Simple_window.h" // get access to our window library
#include "Graph.h" // get access to our graphics library facilities
int main()
{
using namespace Graph_lib; // our graphics facilities are in Graph_lib
Point tl(100,100); // to become top left corner of window
Simple_window win(tl,600,400,"Canvas"); // make a simple window
Polygon poly; // make a shape (a polygon)
poly.add(Point(300,200)); // add a point
poly.add(Point(350,100)); // add another point
poly.add(Point(400,200)); // add a third point
poly.set_color(Color::red); // adjust properties of poly
win.attach (poly); // connect poly to the window
win.wait_for_button(); // give control to the display engine
}
我两天内无法构建此程序。我在中添加了所有图形库http://www.stroustrup.com/Programming/Graphics/我的项目。我还成功地安装了FLTK-1.1.10,并将其配置为Netbeans。所有关于FLTK的程序都能很好地在Netbeans中运行。但是,当涉及到构建和运行上面显示的程序时,会出现许多错误。错误如下:"未定义引用…"。如何在Netbeans中解决此问题?
错误发生如下:
g++-o dist/Debug/GNU-Linux-x86/cpapplication_3 build/Debug-GNU-Linux-x86/GUI.o build/Debug/GNU-Lianux-x86/Graph.o build/Debbug/GNU-Liinux-x86/Simple_window.o build/Deebug/GNU-Linux-x86/window.o uild/Debug/GNU-Linux-x86/main.o-L..//下载/fltk-1.10/lib-lfltk-lfltk_forms-lfltk_gl-lfltk_images-lfltk_jpeg../../Downloads/fltk-1.1.10/lib/libfltk.a(Fl_get_system_colors.o(:在函数getsyscolor(char const*, char const*, char const*, char const*, void (*)(unsigned char, unsigned char, unsigned char))':
Fl_get_system_colors.cxx:(.text+0x17): undefined reference to
XGetDefault'中Fl_get_system_colors.cx:(.text+0x38(:未定义对XParseColor'
../../Downloads/fltk-1.1.10/lib/libfltk.a(Fl_get_system_colors.o): In function
Fl_parse_color的引用(char const*、unsigned char&、unsignedchar&unsigned char&(':Fl_get_system_colors.cxx:(.text+0x2cd(:对"XParseColor"的未定义引用。。。
看起来您需要指定要链接的X库:
-lXext -lX11
如果您下载了FLTK 1.3.3,则include的名称与以前的版本不同。因此,在Bjarne Stroustrup的书的第1203页,关于如何安装fltk的教程不再好了,因为它们已经改变了很多。以下是关于如何为VS安装它以及如何在Win32项目中设置它的教程。http://www.c-jump.com/bcc/common/Talk2/Cxx/FltkInstallVC/FltkInstallVC.html在fltk网站上,有一些教程(解释不如Bjarne好,但没关系(。
- 提升图形库:资源受限的最短周期
- 提升图形库 - 深度优先 仅通过连接的顶点进行搜索
- 如何在提升图形库中获取属性的类型
- 提升图形库:以高性能的方式检查vertex_descriptor的有效性
- 提升图形库 - 具有正好 N 条边/顶点的图形
- 有没有办法通过 LEMON 图形库中的 Map 值获取节点?
- 提升图形库 - 将矢量推送到边缘属性
- 是否可以同时使用 GUI 和 3D 图形库创建应用程序
- 创建像OpenGL这样的图形库
- 提升图形库:防止 DFS 访问未连接的节点
- 用于将三维模型导入OpenGL/C++项目的推荐文件格式和图形库
- 无法链接 read_graphviz() 示例的提升图形库
- 提升图形库:获取edge_descriptor或通过 int 类型的索引访问边缘
- 使用两个访问者提升图形库
- 提升图形库:顶点过滤图上的 BFS
- 在使用 BOOST 图形库生成的图形中添加随机边
- C/C++图形库查询节点由三个部分组成
- 我正在尝试通过 Boost 图形库从 Graphviz DOT 文件中读取图形.如何读取存储在数组中的未知数量的属性
- 我应该使用图形库吗?
- 提升图形库 - 来自外部向量的权重属性