简体   繁体   中英

FLTK 1.3 Linking errors

I update my FLTK from 1.1 to 1.3, then I can't compile my code which is worked well before update.

...
    [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

Here's my 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})

I tried to add some libs in my CMakeLists.txt, but it's not work. Who can tell me what's the problem?

From FLTK 1.3's README.CMake.txt:

USING CMAKE WITH FLTK

This howto assumes that you have FLTK libraries which were built using CMake, installed. Building them with CMake generates some CMake helper files which are installed in standard locations, making FLTK easy to find and use.

Here is a basic CMakeLists.txt file using FLTK.


cmake_minimum_required(VERSION 2.6)

project(hello)

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

add_executable(hello WIN32 hello.cxx)

target_link_libraries(hello fltk)


The find_package command tells CMake to find the package FLTK, REQUIRED means that it is an error if it's not found. NO_MODULE tells it to search only for the FLTKConfig file, not using the FindFLTK.cmake supplied with CMake, which doesn't work with this version of FLTK.

Once the package is found we include the ${FLTK_USE_FILE} which adds the FLTK include directories and library link information to its knowledge base. After that your programs will be able to find FLTK headers and when you link the fltk library, it automatically links the libraries fltk depends on.

It seems that from FLTK 1.1 to 1.3 they changed the method needed to find the library, maybe for comparability/testing reasons?

I got hung up on the same issue, hope someone finds this useful. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM