Dear,
I'm quite new to CMake and I would like to build an application with itk, vtk
and fltk. I managed to build a simple program that link the three parts
together, but I still have some problem linking in the right way the fltk
libraries.
Infact, when I try to use these lines to create a background in a window
fl_register_images();
Fl_Box *background =
Fl_JPEG_Image *background_img =
background->image(background_img);
I have these errors
2>fltkimagesd.lib(Fl_JPEG_Image.obj) : error LNK2019: riferimento al simbolo
esterno _jpeg_read_scanlines non risolto nella funzione "public: __thiscall
Fl_JPEG_Image::Fl_JPEG_Image(char const *)" (??0Fl_JPEG_Image@@QAE@PBD@Z)
.....
2>fltkimagesd.lib(Fl_PNG_Image.obj) : error LNK2019: riferimento al simbolo
esterno _png_read_end non risolto nella funzione "public: __thiscall
Fl_PNG_Image::Fl_PNG_Image(char const *)" (??0Fl_PNG_Image@@QAE@PBD@Z)
.....
I think that my problem could be related to the CMake list enclosed, but I
cannot figure out what's wrong!!
Does anyone can help me?
Thank you in advance,
Best regards,
Luca
// initialize image
libnewFl_Box(0,0,lwindow,mwindow);newFl_JPEG_Image("D:/icon/master_back.jpg");CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
IF(COMMAND CMAKE_POLICY)
CMAKE_POLICY(SET CMP0003 NEW)
ENDIF(COMMAND CMAKE_POLICY)
PROJECT(PROVA)
INCLUDE_REGULAR_EXPRESSION("^.*$")
# Tell CMake's FIND_PACKAGE command where to look for our Find<pkg>
# modules.
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROVA_SOURCE_DIR})
IF(NOT WIN32)
OPTION(BUILD_SHARED_LIBS "Build PROVA with shared libraries." OFF)
ENDIF(NOT WIN32)
FIND_PACKAGE(ITK)
IF(ITK_FOUND)
INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
MESSAGE(FATAL_ERROR
"Cannot build PROVA without ITK. Please set ITK_DIR.")
ENDIF(ITK_FOUND)
# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
# warnings
IF(WIN32)
IF(NOT BORLAND)
IF(NOT CYGWIN)
IF(NOT MINGW)
IF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
ADD_DEFINITIONS(
-D_CRT_FAR_MAPPINGS_NO_DEPRECATE
-D_CRT_IS_WCTYPE_NO_DEPRECATE
-D_CRT_MANAGED_FP_NO_DEPRECATE
-D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_DEPRECATE_GLOBALS
-D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
-D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
-D_CRT_VCCLRIT_NO_DEPRECATE
-D_SCL_SECURE_NO_DEPRECATE
)
ENDIF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
ENDIF(NOT MINGW)
ENDIF(NOT CYGWIN)
ENDIF(NOT BORLAND)
ENDIF(WIN32)
#-----------------------------------------------------------------------------
# Configure Dart testing support.
INCLUDE(${CMAKE_ROOT}/Modules/Dart.cmake)
MARK_AS_ADVANCED(TCL_TCLSH)
IF(BUILD_TESTING)
ENABLE_TESTING()
ENDIF(BUILD_TESTING)
# Determine what packages are available
# Add an option to use or not use VTK
OPTION(USE_VTK "Use VTK (The Visualization Toolkit) (some applications need
this)" OFF)
IF(USE_VTK)
FIND_PACKAGE(VTK)
IF (VTK_FOUND)
INCLUDE (${VTK_USE_FILE})
# Test for VTK using std libs
IF(WIN32) # It seems that the following message is only relavant for MSVC 6
installs
IF(NOT VTK_USE_ANSI_STDLIB)
MESSAGE("Warning. Your VTK was not built with the VTK_USE_ANSI_STDLIB "
"option ON. Link errors may occur. Consider re-building VTK "
"with this option ON. For MSVC 6, you MUST turn on the VTK "
"option. ITK will not link otherwise.")
ENDIF(NOT VTK_USE_ANSI_STDLIB)
ENDIF(WIN32)
## New versions of VTK have removed the HYBRID option, and it is now linked ot
the RENDERING option
## The PATENTED option also no longer exists in version 4.5 and greater, and
these features no longer
## need a special flag set.
IF( "${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}" LESS 4.5 )
# Test for VTK building Hybrid
IF(NOT VTK_USE_HYBRID)
MESSAGE("Your VTK was not built with the VTK_USE_HYBRID option ON. "
"Please reconfigure and recompile VTK with this option before
"
"trying to use it with ITK.")
SET(VTK_FOUND 0)
ENDIF(NOT VTK_USE_HYBRID)
# If VTK was built using Patented, add an option for using patented code
# in InsightApplications (SNAP in particular)
IF(VTK_USE_PATENTED)
OPTION(USE_VTK_PATENTED "Use VTK Patented Libraries (optional)" OFF)
MARK_AS_ADVANCED(USE_VTK_PATENTED)
IF(USE_VTK_PATENTED)
ADD_DEFINITIONS(-DUSE_VTK_PATENTED)
ENDIF(USE_VTK_PATENTED)
ENDIF(VTK_USE_PATENTED)
ELSE( "${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}" LESS 4.5 )
IF(NOT VTK_USE_RENDERING)
MESSAGE("Your VTK was not built with the VTK_USE_RENDERING option ON.
"
"Please reconfigure and recompile VTK with this option before
"
"trying to use it with ITK.")
SET(VTK_FOUND 0)
ENDIF(NOT VTK_USE_RENDERING)
ENDIF( "${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}" LESS 4.5 )
ENDIF (VTK_FOUND)
ENDIF(USE_VTK)
# Look for OpenGL.
FIND_PACKAGE(OpenGL)
IF(OPENGL_INCLUDE_PATH)
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_PATH})
ENDIF(OPENGL_INCLUDE_PATH)
# Add an option to use or not use FLTK (http://www.fltk.org)
OPTION(USE_FLTK "Use FLTK (The Fast Light Toolkit) for GUI (some applications
need this)" OFF)
IF(USE_FLTK)
FIND_PACKAGE(FLTK)
IF(FLTK_FOUND)
INCLUDE_DIRECTORIES(${FLTK_INCLUDE_DIR})
ENDIF(FLTK_FOUND)
ENDIF(USE_FLTK)
# then vtkFlRenderWindowInteractor.h and .cxx
FIND_PATH(VTK_FL_RWI_H_PATH vtkFlRenderWindowInteractor.h)
FIND_PATH(VTK_FL_RWI_CXX_PATH vtkFLRenderWindowInteractor.cxx)
IF(NOT VTK_FL_RWI_H_PATH)
MESSAGE(FATAL_ERROR "Please enter the path of vtkFlRenderWindowInteractor.h")
ENDIF(NOT VTK_FL_RWI_H_PATH)
IF(NOT VTK_FL_RWI_CXX_PATH)
MESSAGE(FATAL_ERROR "Please enter the path of
vtkFlRenderWindowInteractor.cxx")
ENDIF(NOT VTK_FL_RWI_CXX_PATH)
# add the vtkFlRenderWindowInteractor.h path to the include directories
INCLUDE_DIRECTORIES(${VTK_FL_RWI_H_PATH})
# remember to actually build and link with vtkFlRenderWindowInteractor.cxx
ADD_EXECUTABLE(PROVA PROVA.cpp
${VTK_FL_RWI_CXX_PATH}/vtkFlRenderWindowInteractor.cxx)
# The fluid-generated fltk sources have many warnings. This macro
# will disable warnings for the generated files on some compilers.
MACRO(ITK_DISABLE_FLTK_GENERATED_WARNINGS files)
IF(CMAKE_COMPILER_IS_GNUCXX)
FOREACH(f ${files})
STRING(REGEX REPLACE "\\.fl$" ".cxx" SRC "${f}")
STRING(REGEX REPLACE ".*/([^/]*)$" "\\1" SRC "${SRC}")
SET_SOURCE_FILES_PROPERTIES(${SRC} PROPERTIES COMPILE_FLAGS -w)
ENDFOREACH(f)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
IF(MSVC)
FOREACH(f ${files})
STRING(REGEX REPLACE "\\.fl$" ".cxx" SRC "${f}")
STRING(REGEX REPLACE ".*/([^/]*)$" "\\1" SRC "${SRC}")
SET_SOURCE_FILES_PROPERTIES(${SRC} PROPERTIES COMPILE_FLAGS /w)
ENDFOREACH(f)
ENDIF(MSVC)
ENDMACRO(ITK_DISABLE_FLTK_GENERATED_WARNINGS)
# Macro for adding resources to GUI application on the Mac
#
IF(APPLE AND NOT FLTK_USE_X)
FIND_PROGRAM(ITK_APPLE_RESOURCE Rez /Developer/Tools)
FIND_FILE(ITK_FLTK_RESOURCE mac.r
/usr/local/include/FL
${FLTK_DIR}/FL)
IF(NOT ITK_FLTK_RESOURCE)
MESSAGE("Fltk resources not found, GUI application will not respond to
mouse events")
ENDIF(NOT ITK_FLTK_RESOURCE)
MACRO(ADD_GUI_EXECUTABLE name sources)
ADD_EXECUTABLE(${name} ${sources})
INSTALL_TARGETS(/bin ${name})
SET(EXEC_PATH ${EXECUTABLE_OUTPUT_PATH})
IF(NOT EXEC_PATH)
SET(EXEC_PATH ${CMAKE_CURRENT_BINARY_DIR})
ENDIF(NOT EXEC_PATH)
IF(ITK_APPLE_RESOURCE)
ADD_CUSTOM_COMMAND(SOURCE ${name}
COMMAND ${ITK_APPLE_RESOURCE}
ARGS -t APPL ${ITK_FLTK_RESOURCE} -o
${EXEC_PATH}/${name}
TARGET ${name})
ENDIF(ITK_APPLE_RESOURCE)
ENDMACRO(ADD_GUI_EXECUTABLE)
ELSE(APPLE AND NOT FLTK_USE_X)
MACRO(ADD_GUI_EXECUTABLE name sources)
ADD_EXECUTABLE(${name} ${sources})
INSTALL_TARGETS(/bin ${name})
ENDMACRO(ADD_GUI_EXECUTABLE)
ENDIF(APPLE AND NOT FLTK_USE_X)
INCLUDE_DIRECTORIES(${PROVA_SOURCE_DIR})
ADD_EXECUTABLE(PROVA PROVA.cpp)
IF (FLTK_FOUND)
FLTK_WRAP_UI(PROVA PROVA.fl)
ENDIF (FLTK_FOUND)
TARGET_LINK_LIBRARIES (PROVA
ITKIO ITKAlgorithms ITKCommon ITKBasicFilters ITKNumerics
${FLTK_LIBRARIES}
vtkRendering vtkGraphics vtkHybrid vtkWidgets
vtkImaging vtkIO vtkFiltering vtkCommon
)
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake