1.官网下载源码压缩包。版本建议最新,我这里的版本是1.3.8
2. 终端输入:sudo apt-get install build-essential xorg-dev libx11-dev libcairo2-dev
//此步骤必要!!!安装依赖库,不然后面安装总会出错!!!
3.挤压文件: tar -xvf fltk .tar.gz
4.进入源文件:cd fltk-1.3.8/
5.修改先关配置,比如我需要OpenGL支持,默认的是不支持,我就改成支持。按照你们的需要修改即可。修改方式为:./configure + options
./configure --enable-debug --enable-gl --enable-shared --enable-threads --enable-xdbe --enable-xft
相关参数有:
--enable-cygwin
Enable the Cygwin libraries under 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 for anti-aliased fonts under X11
--bindir=/path
Set the location for executables [default = $prefix/bin]
--datadir=/path
Set the location for data files. [default = $prefix/share]
--libdir=/path
Set the location for libraries [default = $prefix/lib]
--includedir=/path
Set the location for include files. [default = $prefix/include]
--mandir=/path
Set the location for man pages. [default = $prefix/man]
--prefix=/dir
Set the directory prefix for files [default = /usr/local]
6.make
7.安装:sudo make install
8.测试安装是否成功:
1.vim hello.cpp
hello.cpp的代码为:
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
int main(int argc, char **argv) {
Fl_Window *window = new Fl_Window(340,180);
Fl_Box *box = new Fl_Box(20,40,300,100,"Hello, World!");
box->box(FL_UP_BOX);
box->labelfont(FL_BOLD+FL_ITALIC);
box->labelsize(36);
box->labeltype(FL_SHADOW_LABEL);
window->end();
window->show(argc, argv);
return Fl::run();
}
2.编译:fltk-config --compile hello.cpp
3.运行:./hello
**over**