今天编译fltk-1.1.10居然出现error,这个版本我以前在笔记本上装过多次,只有cmake完g以后有一个警告而已,可以正常安装不影响。但是现在为啥这个版本在我这台组装台式机上面就报错,无法安装呢?估计这是个bug,并且已经被他们发现并揪出去了,因为我看最新版1.3.3的源代码里面/usr/local/src/fltk-1.1.10/src/filename_list.cxx这个函数大变样了。以后有时间的话再去追究一下这个问题的细节...这里只是记录一下这个错误,并未解决它。建议如果你也遇到这个问题,可以直接放弃安装这个版本,直接装新版本的,比如当前最新版fltk-1.3.3-source.tar.gz,没有任何警告和错误。编译环境:gcc-4.8。
错误如下:
[ 53%] Building CXX object src/CMakeFiles/fltk.dir/filename_isdir.o
[ 54%] Building CXX object src/CMakeFiles/fltk.dir/filename_list.o
/usr/local/src/fltk-1.1.10/src/filename_list.cxx: In function ‘int fl_filename_list(const char*, dirent***, int (*)(dirent**, dirent**))’:
/usr/local/src/fltk-1.1.10/src/filename_list.cxx:70:68: error: invalid conversion from ‘int (*)(const void*, const void*)’ to ‘int (*)(const dirent**, const dirent**)’ [-fpermissive]
int n = scandir(d, list, 0, (int(*)(const void*,const void*))sort);
^
In file included from /usr/local/src/fltk-1.1.10/FL/filename.H:91:0,
from /usr/local/src/fltk-1.1.10/src/filename_list.cxx:30:
/usr/include/dirent.h:256: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[2]: *** [src/CMakeFiles/fltk.dir/filename_list.o] Error 1
make[1]: *** [src/CMakeFiles/fltk.dir/all] Error 2
make: *** [all] Error 2
其它信息备案
=============================
源代码:
fltk-1.1.10-source.tar.bz2或者fltk-1.1.10-source.tar.gz,下载地址:http://www.fltk.org/software.php
cmake的配置:
BUILD_EXAMPLES *ON
BUILD_SHARED_LIBS *OFF
BUILD_TESTING *ON
CMAKE_BACKWARDS_COMPATIBILITY *2.4
CMAKE_BUILD_TYPE *
CMAKE_INSTALL_PREFIX */usr/local/fltk-1.1.10
CMAKE_USE_PTHREADS *ON
FLTK_USE_SYSTEM_JPEG *OFF
FLTK_USE_SYSTEM_PNG *OFF
FLTK_USE_SYSTEM_ZLIB *OFF
USE_OPENGL *ON
cmake配置时,c键完成之后,出来g键; 按g键,出来一个警告:
CMake Warning (dev) at png/CMakeLists.txt:21 (ADD_LIBRARY): Policy CMP0003 should be set before this line. Add code such as
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
as early as possible but after the most recent call to
cmake_minimum_required or cmake_policy(VERSION). This warning appears because target "fltk_png" links to some libraries for which the linker must search:
-lm
and other libraries with known full path: /usr/local/src/fltk-1.1.10/bin/libfltk_zlib.a
CMake is adding directories in the second list to the linker search path in case they are needed to find libraries from the first list (for backwards compatibility with CMake 2.4). Set policy CMP0003 to OLD or NEW to enable or disable this behavior explicitly. Run "cmake --help-policy CMP0003" for more information. This warning is for project developers. Use -Wno-dev to suppress it.
我很确定这个警告不是问题的原因,因为我以前在笔记本上成功编译安装成功过,当时也报这个警告。
============================================================后来=========================
把gcc降级为gcc-4.6后,又重试了安装fltk-1.1.10,还是报和之前一样的错误:
[ 49%] Building CXX object src/CMakeFiles/fltk.dir/filename_ext.o
[ 49%] Building CXX object src/CMakeFiles/fltk.dir/filename_isdir.o
[ 50%] Building CXX object src/CMakeFiles/fltk.dir/filename_list.o
/usr/local/src/fltk-1.1.10/src/filename_list.cxx: In function ‘int fl_filename_list(const char*, dirent***, int (*)(dirent**, dirent**))’:
/usr/local/src/fltk-1.1.10/src/filename_list.cxx:70:68: error: invalid conversion from ‘int (*)(const void*, const void*)’ to ‘int (*)(const dirent**, const dirent**)’ [-fpermissive]
/usr/include/dirent.h:256:12: error: initializing argument 4 of ‘int scandir(const char*, dirent***, int (*)(const dirent*), int (*)(const dirent**, const dirent**))’ [-fpermissive]
make[2]: *** [src/CMakeFiles/fltk.dir/filename_list.o] Error 1
make[1]: *** [src/CMakeFiles/fltk.dir/all] Error 2
make: *** [all] Error 2
ltu@pangolin:/usr/local/src/fltk-1.1.10/bin$
查了一会,如这里所说http://comments.gmane.org/gmane.comp.lib.fltk.bugs/6510。这是个bug在http://www.fltk.org/str.php?L2931这里有个patch来解决这个bug,但是我将他们提供的scandir_patches_for_fltk-1.3.x-r9824.tar.gz目录里文件拷贝到对应目录,试了,在我的系统上还是不行。加了const而已。错误如下:
[ 49%] Building CXX object src/CMakeFiles/fltk.dir/filename_isdir.o
[ 50%] Building CXX object src/CMakeFiles/fltk.dir/filename_list.o
/usr/local/src/fltk-1.1.10/src/filename_list.cxx: In function ‘int fl_filename_list(const char*, dirent***, int (*)(const dirent**, const dirent**))’:
/usr/local/src/fltk-1.1.10/src/filename_list.cxx:118:77: error: invalid conversion from ‘int (*)(const void*, const void*)’ to ‘int (*)(const dirent**, const dirent**)’ [-fpermissive]
/usr/include/dirent.h:256:12: error: initializing argument 4 of ‘int scandir(const char*, dirent***, int (*)(const dirent*), int (*)(const dirent**, const dirent**))’ [-fpermissive]
make[2]: *** [src/CMakeFiles/fltk.dir/filename_list.o] Error 1
make[1]: *** [src/CMakeFiles/fltk.dir/all] Error 2
make: *** [all] Error 2
ltu@pangolin:/usr/local/src/fltk-1.1.10/bin$
该错误未解决!!!
Update: 该错误已解决!fltk-1.1.10已成功编译通过。
==========================================================
详细解决方法请点此处!