FLTK 1.3链接错误

时间:2012-10-04 16:29:17

标签: c++ cmake fltk

我将我的FLTK从1.1更新到1.3,然后我无法编译在更新之前运行良好的代码。

...
    [100%] Building CXX object CMakeFiles/PROSTVIEW.dir/include/nifti/vtkznzlib.cxx.o
    Linking CXX executable PROSTVIEW
    /usr/local/lib/libfltk.a(fl_font.cxx.o): In function `fontopen(char const*, int, bool, int)':
    fl_font.cxx:(.text+0x298): undefined reference to `FcPatternCreate'
    fl_font.cxx:(.text+0x362): undefined reference to `FcPatternAddString'
    fl_font.cxx:(.text+0x3e3): undefined reference to `FcPatternAddString'
    fl_font.cxx:(.text+0x3f7): undefined reference to `FcPatternAddInteger'
    fl_font.cxx:(.text+0x40b): undefined reference to `FcPatternAddInteger'
    fl_font.cxx:(.text+0x424): undefined reference to `FcPatternAddDouble'
    fl_font.cxx:(.text+0x43c): undefined reference to `FcPatternAddString'
    fl_font.cxx:(.text+0x4df): undefined reference to `FcMatrixRotate'
    fl_font.cxx:(.text+0x4f7): undefined reference to `FcPatternAddMatrix'
    fl_font.cxx:(.text+0x516): undefined reference to `FcPatternAddBool'
    fl_font.cxx:(.text+0x52c): undefined reference to `FcPatternAddBool'
    fl_font.cxx:(.text+0x549): undefined reference to `XftFontMatch'
    fl_font.cxx:(.text+0x5a0): undefined reference to `XftFontOpen'
    fl_font.cxx:(.text+0x5b0): undefined reference to `FcPatternDestroy'
    fl_font.cxx:(.text+0x5f3): undefined reference to `XftFontOpenPattern'
    fl_font.cxx:(.text+0x603): undefined reference to `FcPatternDestroy'
    fl_font.cxx:(.text+0x659): undefined reference to `XftFontOpenXlfd'
    /usr/local/lib/libfltk.a(fl_font.cxx.o): In function `utf8extents(Fl_Font_Descriptor*, char const*, int, _XGlyphInfo*)':
    fl_font.cxx:(.text+0x84b): undefined reference to `XftTextExtents32'
    /usr/local/lib/libfltk.a(fl_font.cxx.o): In function `fl_xft_width(Fl_Font_Descriptor*, unsigned int*, int)':
    fl_font.cxx:(.text+0x98a): undefined reference to `XftTextExtents32'
    /usr/local/lib/libfltk.a(fl_font.cxx.o): In function `fl_destroy_xft_draw(unsigned long)':
    fl_font.cxx:(.text+0x102e): undefined reference to `XftDrawChange'
    /usr/local/lib/libfltk.a(fl_font.cxx.o): In function `Fl_Xlib_Graphics_Driver::draw(char const*, int, int, int)':
    fl_font.cxx:(.text+0x10c6): undefined reference to `XftDrawCreate'
    fl_font.cxx:(.text+0x10f6): undefined reference to `XftDrawChange'
    fl_font.cxx:(.text+0x1140): undefined reference to `XftDrawSetClip'
    fl_font.cxx:(.text+0x1202): undefined reference to `XftDrawString32'
    /usr/local/lib/libfltk.a(fl_font.cxx.o): In function `fl_drawUCS4(Fl_Graphics_Driver*, unsigned int const*, int, int, int)':
    fl_font.cxx:(.text+0x1313): undefined reference to `XftDrawCreate'
    fl_font.cxx:(.text+0x1343): undefined reference to `XftDrawChange'
    fl_font.cxx:(.text+0x138d): undefined reference to `XftDrawSetClip'
    fl_font.cxx:(.text+0x1433): undefined reference to `XftDrawString32'
    /usr/local/lib/libfltk.a(fl_font.cxx.o): In function `Fl_Xlib_Graphics_Driver::rtl_draw(char const*, int, int, int)':
    fl_font.cxx:(.text+0x1480): undefined reference to `FcUtf8Len'
    fl_font.cxx:(.text+0x14ff): undefined reference to `FcUtf8ToUcs4'
    collect2: ld returned 1 exit status
    make[2]: *** [PROSTVIEW] Error 1
    make[1]: *** [CMakeFiles/PROSTVIEW.dir/all] Error 2
    make: *** [all] Error 2

这是我的CMakeLists.txt

cmake_minimum_required(VERSION 2.6)

PROJECT(PROSTVIEW)

SET(CMAKE_BUILD_TYPE DEBUG)
SET(CMAKE_CXX__FLAGS -O3 -pipe -ffast-math -Wno-deprecated)

# Chargement Package
# FLTK
 FIND_PACKAGE ( FLTK )
 IF ( FLTK_FOUND )
    INCLUDE_DIRECTORIES( ${FLTK_INCLUDE_DIR} )
 ENDIF ( FLTK_FOUND )

# ITK
FIND_PACKAGE ( ITK )
IF ( ITK_FOUND )
    INCLUDE( ${USE_ITK_FILE} )
ENDIF( ITK_FOUND ) 

# VTK
FIND_PACKAGE ( VTK )
IF ( VTK_FOUND )
    INCLUDE( ${USE_VTK_FILE} )
ENDIF( VTK_FOUND )
SET(VTK_LIBRARIES vtkCommon vtkRendering vtkWidgets vtkGraphics vtkGenericFiltering vtkzlib)

# vtkFlRenderWindowInteractor
SET(VTKFL_INCLUDE_DIR "include/vtkfl")
SET(VTKFL_CPP 
${VTKFL_INCLUDE_DIR}/vtkFlRenderWindowInteractor.cxx)

# Auxiliary_Tools
SET(AT_DIR "include/Auxiliary_Tools")
SET(AT_INCLUDE_DIR ${AT_DIR}/include)
SET(AT_LIBRARY_DIR ${AT_DIR}/lib)

#Nifty
SET(NII_DIR "include/nifti")
SET(NII_SRC 
${NII_DIR}/vtkNIfTIReader.cxx
${NII_DIR}/vtkNIfTIWriter.cxx
${NII_DIR}/vtkAnalyzeReader.cxx
${NII_DIR}/vtkAnalyzeWriter.cxx
${NII_DIR}/vtknifti1_io.cxx
${NII_DIR}/vtkznzlib.cxx)

#Other include
SET(PROSTVIEW_INCLUDE_DIR "include")
SET(PROSTVIEW_SRC
${PROSTVIEW_INCLUDE_DIR}/ContourTmt.cpp
${PROSTVIEW_INCLUDE_DIR}/conversion.cpp 
${PROSTVIEW_INCLUDE_DIR}/TmtMatrix.cpp) 

# VOLUME Widget
SET(VOLUME_WIDGET_DIR "include/GUI")
SET(VOLUME_WIDGET 
${VOLUME_WIDGET_DIR}/VOLUME_Loader.cpp 
${VOLUME_WIDGET_DIR}/VOLUME_Widget.cpp 
${VOLUME_WIDGET_DIR}/VOLUME_Mouse_Widget.cpp 
${VOLUME_WIDGET_DIR}/VOLUME_3DView.cpp 
${VOLUME_WIDGET_DIR}/CONTOUR_Loader.cpp 
${VOLUME_WIDGET_DIR}/ProstView.cpp)

# MODULES
SET(MODULE_DIR "Module")

# SEGMENTATION
SET(SEGMENTATION_DIR "Module/Segmentation")
SET(SEGMENTATION 
${SEGMENTATION_DIR}/DDC2D.cpp 
${SEGMENTATION_DIR}/DDC3D.cpp 
${SEGMENTATION_DIR}/DDC3DHu.cpp 
${SEGMENTATION_DIR}/DDC3DPlus.cpp 
${SEGMENTATION_DIR}/DDC3DBal.cpp 
${SEGMENTATION_DIR}/IMAGE_ENERGY.cpp 
${SEGMENTATION_DIR}/REGULARIZATION.cpp 
${SEGMENTATION_DIR}/OPTIMAL_SURFACE_DETECTION.cpp 
${SEGMENTATION_DIR}/OPTIMAL_MULTIPLE_SURFACES_DETECTION.cpp 
${SEGMENTATION_DIR}/RESAMPLE_From_Prostate.cpp
${SEGMENTATION_DIR}/RECTAL_WALL_US.cpp 
${SEGMENTATION_DIR}/BLADDER_MRI.cpp 
${SEGMENTATION_DIR}/RECTUM_MRI.cpp 
${SEGMENTATION_DIR}/REGION_GROWING.tpp )

#MESH
SET(MESH_DIR "Module/Mesh")
SET(MESH
${MESH_DIR}/GENERIC_MESH.cpp
${MESH_DIR}/ELLIPSOID_MESH.cpp
${MESH_DIR}/PROSTATE_MESH.cpp
${MESH_DIR}/TUBULAR_MESH.cpp
${MESH_DIR}/OPEN_MESH.cpp
${MESH_DIR}/QUADRIC_MESH.cpp
${MESH_DIR}/ELLIPTICAL_CYLINDER_MESH.cpp 
${MESH_DIR}/CONTOURS_MAN_MESH.cpp)

#STUDY
SET(STUDY_DIR "Module/Statistics")
SET(STUDY
${STUDY_DIR}/PROFILE.cpp
${STUDY_DIR}/Histogram.cpp
${STUDY_DIR}/HISTOGRAM_FROM_MESH.cpp
${STUDY_DIR}/TRAINING_SET_ALIGNMENT.cpp
${STUDY_DIR}/APPEARANCE_MODEL.cpp)

# MOMENTS
SET(MOMENTS_DIR "Module/Moments")
SET(MOMENTS 
${MOMENTS_DIR}/KRAWTCHOUK_Moments.tpp 
${MOMENTS_DIR}/TCHEBICHEF_Moments.tpp 
${MOMENTS_DIR}/GEOMETRIC_Moments.tpp)

#VALIDATION
SET(VALIDATION_DIR "Module/Evaluation")
SET(VALIDATION 
${VALIDATION_DIR}/Metrics.cpp)

# Include et Link Directories
INCLUDE_DIRECTORIES(${FLTK_INCLUDE_DIR} ${VTK_INCLUDE_DIRS} ${VTKFL_INCLUDE_DIR} ${AT_INCLUDE_DIR} ${NII_DIR} ${PROSTVIEW_INCLUDE_DIR} ${VOLUME_WIDGET_DIR} ${MODULE_DIR})
LINK_DIRECTORIES(${FLTK_LIBRARY_DIR} ${VTK_LIBRARY_DIRS} ${AT_LIBRARY_DIR} ${PROSTVIEW_INCLUDE_DIR} ${VOLUME_WIDGET_DIR} ${MODULE_DIR})

# Sources
SET(SRC main.cpp) 

# Executables and "stand-alone " librairies
ADD_EXECUTABLE(PROSTVIEW ${SRC} ${PROSTVIEW_SRC} ${VTKFL_CPP} ${VOLUME_WIDGET} ${SEGMENTATION} ${MESH} ${STUDY} ${MOMENTS} ${VALIDATION} ${NII_SRC})

# Linkage
TARGET_LINK_LIBRARIES(PROSTVIEW  ${FLTK_LIBRARIES} ${VTK_LIBRARIES} ${ITK_LIBRARIES})

我试图在我的CMakeLists.txt中添加一些库,但它不起作用。谁能告诉我这是什么问题?

1 个答案:

答案 0 :(得分:1)

来自FLTK 1.3的README.CMake.txt:

  

使用FLTK CMAKE

     

这个假设你假设你有使用的FLTK库   CMake,已安装。用CMake构建它们会产生一些CMake   安装在标准位置的辅助文件,制作FLTK   易于查找和使用。

     

这是使用FLTK的基本CMakeLists.txt文件。

     
     

cmake_minimum_required(VERSION 2.6)

     

项目(你好)

     

find_package(FLTK REQUIRED NO_MODULE)include($ {FLTK_USE_FILE})

     

add_executable(hello WIN32 hello.cxx)

     

target_link_libraries(hello fltk)

     
     

find_package命令告诉CMake找到包FLTK,   必需表示如果找不到则会出错。 NO_MODULE说   它只搜索FLTKConfig文件,而不是使用   与CMake一起提供的FindFLTK.cmake,它不适用于此   FLTK的版本。

     

找到包后,我们会添加$ {FLTK_USE_FILE}   FLTK包含目录和库链接信息   知识库。之后,您的程序将能够找到FLTK   标题和链接fltk库时,它会自动链接   图书馆fltk取决于。

似乎从FLTK 1.1到1.3他们改变了找到库所需的方法,可能是出于可比性/测试的原因?

我被挂在同一个问题上,希望有人觉得这很有用。 :)