4

我将我的 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 中添加一些库,但它不起作用。谁能告诉我是什么问题?

4

1 回答 1

2

来自 FLTK 1.3 的 README.CMake.txt:

将 CMAKE 与 FLTK 一起使用

本指南假定您已安装使用 CMake 构建的 FLTK 库。使用 CMake 构建它们会生成一些安装在标准位置的 CMake 帮助文件,使 FLTK 易于查找和使用。

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


cmake_minimum_required(版本 2.6)

项目(你好)

find_package(FLTK REQUIRED NO_MODULE) 包括(${FLTK_USE_FILE})

add_executable(hello WIN32 hello.cxx)

target_link_libraries(你好 fltk)


find_package 命令告诉 CMake 查找包 FLTK,REQUIRED 表示如果没有找到就是错误。NO_MODULE 告诉它只搜索 FLTKConfig 文件,而不是使用 CMake 提供的 FindFLTK.cmake,它不适用于这个版本的 FLTK。

找到包后,我们包含 ${FLTK_USE_FILE},它将 FLTK 包含目录和库链接信息添加到其知识库中。之后,您的程序将能够找到 FLTK 标头,并且当您链接 fltk 库时,它会自动链接 fltk 所依赖的库。

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

我挂断了同样的问题,希望有人觉得这很有用。:)

于 2013-03-13T14:56:11.493 回答