编译FLTK时Errors汇总

在Linux环境下编译FLTK时遇到多种错误,包括缺少X11/Xlocale.h导致的编译中断,需要安装libx11-dev;在构建共享库时遇到的链接错误,解决方法是关闭选项OPTION_BUILD_SHARED_LIBS;aclocal-1.14命令未找到的问题,通过运行autoreconf -ivf解决;以及在gcc 4.6.4上编译Fl_JPEG_Image时的类型转换错误,需手动修正源代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装fltk-1.3.3-source.tar.gz时,出现的错误汇总:


错误一:

sudo tar -xvf fltk-1.3.3-source.tar.gz

cd fltk-1.3.3

sudo ccmake ./

sudo make


安装到22%,报错如下:

….

[ 21%] Building C object png/CMakeFiles/fltk_png.dir/pngread.c.o

[ 21%] Building C object png/CMakeFiles/fltk_png.dir/pngset.c.o

[ 22%] Building C object png/CMakeFiles/fltk_png.dir/pngwio.c.o

Linking C static library ../lib/libfltk_png.a

[ 22%] Built target fltk_png

Scanning dependencies of target fltk

[ 22%] Building CXX object src/CMakeFiles/fltk.dir/Fl.cxx.o

In file included from /install/fltk-1.3.3/FL/Fl.H:30:0,

              from /install/fltk-1.3.3/src/Fl.cxx:48:

/install/fltk-1.3.3/FL/fl_utf8.h:62:27: fatal error: X11/Xlocale.h: No such file or directory

compilation terminated.

make[2]: *** [src/CMakeFiles/fltk.dir/Fl.cxx.o] Error 1

make[1]: *** [src/CMakeFiles/fltk.dir/all] Error 2

make: *** [all] Error 2


错误原因:缺少Xlib.h,可以通过命令:apt-file search Xlib.h搜索一下,可知其包含在package libx11-dev中。


解决方法: 安装libx11-dev则可:

sudo apt-get install libx11-dev


装完后,进入fltk-1.3.3目录,继续刚刚中断的编译:

sudo make



错误二:

[ 84%] Building CXX object src/CMakeFiles/fltk_images_SHARED.dir/Fl_JPEG_Image.cxx.o

[ 84%] Building CXX object src/CMakeFiles/fltk_images_SHARED.dir/Fl_PNG_Image.cxx.o

[ 84%] Building CXX object src/CMakeFiles/fltk_images_SHARED.dir/Fl_PNM_Image.cxx.o

Linking CXX shared library ../lib/libfltk_imagesd.so

/usr/bin/ld: ../lib/libfltk_jpegd.a(jerror.c.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC

../lib/libfltk_jpegd.a: could not read symbols: Bad value

collect2: error: ld returned 1 exit status

make[2]: *** [lib/libfltk_imagesd.so.1.3.3] Error 1

make[1]: *** [src/CMakeFiles/fltk_images_SHARED.dir/all] Error 2

make: *** [all] Error 2


这个问题是在开启了编译shared libraries时,才会出现。也就是说在CMake里,你ON了红色部分:

CMAKE_BUILD_TYPE               *Debug

CMAKE_INSTALL_PREFIX           */usr/local/fltk-1.3.3

OPTION_ARCHFLAGS               *   

OPTION_BUILD_EXAMPLES          *ON  

OPTION_BUILD_SHARED_LIBS       *ON       

OPTION_CAIRO                   *OFF              

OPTION_CAIROEXT                *OFF   

OPTION_CREATE_LINKS            *OFF        

OPTION_LARGE_FILE              *ON   

OPTION_OPTIM                      *   

OPTION_USE_GL                  *ON   

OPTION_USE_POLL                *OFF   

OPTION_USE_SYSTEM_LIBJPEG      *ON        

OPTION_USE_SYSTEM_LIBPNG       *ON               

OPTION_USE_SYSTEM_ZLIB         *ON            

OPTION_USE_THREADS             *ON         

OPTION_USE_XCURSOR             *ON       

OPTION_USE_XDBE                *ON                              

OPTION_USE_XFIXES              *ON

OPTION_USE_XFT                 *ON

OPTION_USE_XINERAMA            *ON


解决方法:设置OPTION_BUILD_SHARED_LIBS 为OFF即可。


参考:

http://www.cnblogs.com/hanxi/archive/2012/07/30/2616069.html



错误三:

test@test:/usr/local/src/Mesa_build$ sudo make

CDPATH="${ZSH_VERSION+.}:" && cd /install/Mesa-10.3.5 && /bin/bash /install/Mesa-10.3.5/bin/missing aclocal-1.14 -I m4

/install/Mesa-10.3.5/bin/missing: line 81: aclocal-1.14: command not found

WARNING: 'aclocal-1.14' is missing on your system.

     You should only need it if you modified 'acinclude.m4' or

     'configure.ac' or m4 files included by 'configure.ac'.

     The 'aclocal' program is part of the GNU Automake package:

     <http://www.gnu.org/software/automake>

     It also requires GNU Autoconf, GNU m4 and Perl in order to run:

     <http://www.gnu.org/software/autoconf>

     <http://www.gnu.org/software/m4/>

     <http://www.perl.org/>

make: *** [/install/Mesa-10.3.5/aclocal.m4] Error 127


错误原因: timestamp skew,从服务器下载来的安装包在本地解压缩文件时时间戳被修改。


解决方法:

在解压后的源文件目录下,

sudo autoreconf -ivf


然后重新编译安装源文件,错误消失。


这个错误的详细描述在这里: “Ubuntun 12.04 WARNING: 'aclocal-1.14' is missing on your system


错误四:(gcc 4.6.4)

[ 53%] Building CXX object src/CMakeFiles/fltk_images.dir/Fl_GIF_Image.cxx.o

[ 54%] Building CXX object src/CMakeFiles/fltk_images.dir/Fl_Help_Dialog.cxx.o

[ 54%] Building CXX object src/CMakeFiles/fltk_images.dir/Fl_JPEG_Image.cxx.o

/usr/local/src/fltk-1.3.3/src/Fl_JPEG_Image.cxx: In constructor ‘Fl_JPEG_Image::Fl_JPEG_Image(const char*)’:

/usr/local/src/fltk-1.3.3/src/Fl_JPEG_Image.cxx:158:29: error: invalid conversion from ‘int’ to ‘boolean’ [-fpermissive]

/usr/local/include/jpeglib.h:1039:13: error:   initializing argument 2 of ‘int jpeg_read_header(j_decompress_ptr, boolean)’ [-fpermissive]

/usr/local/src/fltk-1.3.3/src/Fl_JPEG_Image.cxx: In constructor ‘Fl_JPEG_Image::Fl_JPEG_Image(const char*, const unsigned char*)’:

/usr/local/src/fltk-1.3.3/src/Fl_JPEG_Image.cxx:340:29: error: invalid conversion from ‘int’ to ‘boolean’ [-fpermissive]

/usr/local/include/jpeglib.h:1039:13: error:   initializing argument 2 of ‘int jpeg_read_header(j_decompress_ptr, boolean)’ [-fpermissive]

make[2]: *** [src/CMakeFiles/fltk_images.dir/Fl_JPEG_Image.cxx.o] Error 1

make[1]: *** [src/CMakeFiles/fltk_images.dir/all] Error 2

make: *** [all] Error 2


解决方法:

sudo gedit ../src/Fl_JPEG_Image.cxx


Replace this function declaration (in both 158 and 340 line) as:

jpeg_read_header(&dinfo, 1);              //the original


with

jpeg_read_header(&dinfo, TRUE);      //the changed


This bug is detailed here :Bug in Fl_JPEG_Image: compile fltk-1.3.3 on gcc-4.6.4


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值