Ubuntu14.04 安装FLTK

2015-12-06  本文已影响0人  李晓锋

昨天晚上,读了C++之父的《C++程序设计原理与实践》一书的第12~16章,其中介绍了图形用户界面编程用到一些基本技术,读完之后大呼过瘾。为了实践书中介绍的方法,今天在ubuntu上把需要用到的GUI库fltk安装一下,如下是安装的记录。

安装必须的支持库

sudo apt-get install build-essential xorg-dev libx11-dev libcairo2-dev

如果支持库不全,可能在configure阶段遇到以下错误:

checking for pthread_create using -lpthread... yes

checking for X... no

./configure: line 410: test: aborting.: integer expression expected

configure: error: Configure could not find required X11 libraries

./configure: line 299: return: aborting.: numeric argument required

./configure: line 309: exit: aborting.: numeric argument required

make阶段遇到以下错误:

=== making src ===

Compiling Fl.cxx...

make[1]: g++: Command not found

make[1]: *** [Fl.o] Error 127

make: *** [all] Error 1

从[官网](http://www.fltk.org/index.php)下载安装包,目前的稳定版是1.3.3,所以决定使用这个版本。

解压源代码包

tar xvzf fltk-1.3.3-source-tar.gz

首先打开README,看看configure都支持一些什么选项。

You can run configure yourself to get the exact setup you    need. Type "./configure".  Options include:

--enable-cygwin        - Enable the Cygwin libraries (WIN32)

--enable-debug          - Enable debugging code & symbols

--disable-gl            - Disable OpenGL support

--enable-shared        - Enable generation of shared libraries

--enable-threads        - Enable multithreading support

--enable-xdbe          - Enable the X double-buffer extension

--enable-xft            - Enable the Xft library (anti-aliased fonts)

--bindir=/path          - Set the location for executables

[default = /usr/local/bin]

--libdir=/path          - Set the location for libraries

[default = /usr/local/lib]

--includedir=/path      - Set the location for include files.

[default = /usr/local/include]

--prefix=/dir          - Set the directory prefix for files

[default = /usr/local]

configure、make、make install安装三部曲,安装软件。为了好管理,不适用默认的路径,我把所有文件都装到了HOME目录下

mkdir -p ~/fltk/{bin, lib, include}

./configure --enable-debug --disable-gl --enable-shared --enable-threads --enable-xdbe --enable-xft --bindir=/home/xlee/fltk/bin --libdir=/home/xlee/fltk/lib --includedir=/home/xlee/fltk/include --prefix=/home/xlee/fltk

make

make install

如果在make过程中遇到以下错误:

Compiling filename_list.cxx...

filename_list.cxx: In function ‘int fl_filename_list(const char*, dirent***, int (*)(dirent**, dirent**))’:

filename_list.cxx:121:73: error: invalid conversion from ‘int (*)(const void*, const void*)’ to ‘int (*)(const dirent**, const dirent**)’ [-fpermissive]

int n = scandir(dirloc, list, 0, (int(*)(const void*,const void*))sort);

^

In file included from ../FL/filename.H:101:0,

from filename_list.cxx:21:

/usr/include/dirent.h:254:12: error:  initializing argument 4 of ‘int scandir(const char*, dirent***, int (*)(const dirent*), int (*)(const dirent**, const dirent**))’ [-fpermissive]

extern int scandir (const char *__restrict __dir,

^

make[1]: *** [filename_list.o] Error 1

make: *** [all] Error 1

则修改src/filename_list.cxx文件的第121行为

int n = scandir(dirloc, list, 0, (int (*)(const dirent**, const dirent**))sort);

至此,编译安装完成。

上一篇 下一篇

猜你喜欢

热点阅读