[vtkusers] linking problems after upgrade from CMake-2.8.6 to CMake-2.8.12.2

Walter Blume Walter.Blume at stereotaxis.com
Wed May 28 17:33:40 EDT 2014


I have an MFC/Vtk  c++ program that I had been building without problems until I upgraded from CMake-2.8.6 to CMake-2.8.12.2   (This is on Windows with Visual Studio 10)

After the CMake upgrade I got link errors indicating:

1>msvcrtd.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain at 16 referenced in function ___tmainCRTStartup
1>C:\Projects\VtkPrograms\VTKPatheter\build\Debug\vtkPatheter.exe : fatal error LNK1120: 1 unresolved externals

I tried a few things to try and resolve this (changing subsystem to CONSOLE or WINDOWS didn't fix it), but couldn't really figure it out.

I rebuilt VTK (v 5.8.0) successfully with the newer version of CMake, but couldn't get my own program to build without the linking problem.

So I gave up and went back to CMake-2.8.6, but I am wondering if anybody ran into this issue and what sort of magic is required in the CMakelist.txt file to fix it.

Thanks for whatever help you can give me
Walter

----- below is contents of my CMakelist.txt file ----------------
PROJECT(vtkPatheter)

cmake_minimum_required(VERSION 2.6)
# This INCLUDE is to allow developers with both MSVC and Borland compilers installed
# to manually change the FindVTK results to point to the correct (MSVC) vtk build directory
INCLUDE ($ENV{VTK_SOURCE_DIR}/Examples/GUI/Win32/vtkMFC/LocalUserOptions.cmake OPTIONAL)

IF (NOT USE_VTK_FILE)
  INCLUDE (${CMAKE_ROOT}/Modules/FindVTK.cmake)
ENDIF (NOT USE_VTK_FILE)

IF (USE_VTK_FILE)
  INCLUDE(${USE_VTK_FILE})
ENDIF (USE_VTK_FILE)

# This causes the build to be generated with Unicode setting
ADD_DEFINITIONS(-D_UNICODE)

INCLUDE_DIRECTORIES(../GeomPrim/include/inc
                                                ${CMAKE_CURRENT_SOURCE_DIR}/
            ${CMAKE_CURRENT_SOURCE_DIR}/PointGroupData
            ${CMAKE_CURRENT_SOURCE_DIR}/Factory
            ${CMAKE_CURRENT_SOURCE_DIR}/Memento
                                                ${CMAKE_CURRENT_SOURCE_DIR}/VirtualCatheter
                                                ${CMAKE_CURRENT_SOURCE_DIR}/Utilities
                                                ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/xml
            ${CMAKE_CURRENT_SOURCE_DIR}/AutoDataSample40                                   )

#---------------------------
# vtkPatheter executes a "system" command that invokes the cygwin executable gawk
#  The following bit of macros/code ensures that the dependent dlls and executable
#  are copied to the execution directory.  Probably there is an easier way
#-----------------------------
SET( GAWK_BINS cyggcc_s-1.dll cygiconv-2.dll cygintl-8.dll cygsigsegv-2.dll cygwin1.dll gawk.exe)
# generates custom copy/dependency commands for each of the files in GAWK_BINS
foreach(f ${GAWK_BINS})
ADD_CUSTOM_COMMAND(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${f}
  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../gawkBins/${f} ${CMAKE_CURRENT_BINARY_DIR}/${f}
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../gawkBins/${f}
)
endforeach(f)

SET( GAWK_SCRIPTS ExtractAblationToMs.awk ExtractSheathToMs.awk ExtractMapTimestampRanges.awk ExtractTargetTimestampRanges.awk )
# and lastly for the source awk code, which ends up in the same directory as the executable as well
foreach(f ${GAWK_SCRIPTS})
ADD_CUSTOM_COMMAND(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${f}
  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${f} ${CMAKE_CURRENT_BINARY_DIR}/${f}
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${f}
)
endforeach(f)
# The result of this is an extra project in visual studio that gets built by copying
# I have no idea why I had to do this for the gawk_scripts, but not for the gawk_binaries
ADD_CUSTOM_TARGET(gawkHack DEPENDS ${GAWK_SCRIPTS})

SET(POINT_GROUP_FILES
PointGroupData/PointGroup.cpp
PointGroupData/PointGroup.h
PointGroupData/PointGroupMemento.cpp
PointGroupData/PointGroupMemento.h
PointGroupData/PointGroupOnSurfaceMemento.cpp
PointGroupData/PointGroupOnSurfaceMemento.h
)


SET(FACTORY_FILES
Factory/AutoFactoryRegistrar.h
Factory/Factory.h
Factory/FactoryRegistrar.h
Factory/FactorySingleton.cpp
Factory/FactorySingleton.h
Factory/GenericFactory.h
)

SET(MEMENTO_FILES
Memento/CartoPoint.cpp
Memento/CartoPoint.h
Memento/CartoSurfaceMemento.cpp
Memento/CartoSurfaceMemento.h
Memento/SurfaceMemento.h
Memento/SurfacePointMemento.h
)

SET(UTILITY_FILES
Utilities/Export.h
Utilities/stopwtch.h
Utilities/Color.cpp Utilities/Color.h
Utilities/Material.h
Utilities/supplemental.cpp Utilities/supplemental.h
Utilities/FormatParser.cpp Utilities/FormatParser.h
Utilities/NativeArguments.cpp Utilities/NativeArguments.h
Utilities/StringUtilitiesTuples.h
Utilities/BoundingBox.cpp Utilities/BoundingBox.h
Utilities/ICoordinateTransform.cpp Utilities/ICoordinateTransform.h
Utilities/CoordinateSpaceException.h
Utilities/CoordinateTransformMatrix.cpp Utilities/CoordinateTransformMatrix.h
Utilities/ILockTracker.h
Utilities/LockTracker.cpp Utilities/LockTracker.h
Utilities/Locks.cpp Utilities/Locks.h
Utilities/LoggingStuff.cpp Utilities/LoggingStuff.h
Utilities/ChamberDist.cpp Utilities/ChamberDist.h
Utilities/SurfaceData.cpp Utilities/SurfaceData.h
Utilities/SurfaceUtils.cpp Utilities/SurfaceUtils.h Utilities/KDTree.h
Utilities/Utilities.cpp Utilities/Utilities.h
Utilities/MathUtilities.cpp Utilities/MathUtilities.h
Utilities/StringUtilities.cpp Utilities/StringUtilities.h
Utilities/FileUtilities.cpp Utilities/FileUtilities.h
Utilities/Exception.h
Utilities/
Utilities/IFunctionR1.h
Utilities/IFunctionR2.h
Utilities/IFunctionR3.h
Utilities/Interpolation.cpp Utilities/Interpolation.h
Utilities/InterpolationR2.cpp Utilities/InterpolationR2.h
Utilities/InterpolationR3.cpp Utilities/InterpolationR3.h
Utilities/NaturalSplineInterpolation.cpp Utilities/NaturalSplineInterpolation.h
Utilities/KBSplineInterpolation.cpp Utilities/KBSplineInterpolation.h
Utilities/LinearSplineInterpolation.cpp Utilities/LinearSplineInterpolation.h
Utilities/Constant.cpp Utilities/Constant.h
Utilities/IParametricFunction.h
Utilities/PointAtDistance.cpp Utilities/PointAtDistance.h
Utilities/xml/XmlDocument.cpp Utilities/xml/XmlDocument.h
Utilities/xml/XmlAttribute.cpp Utilities/xml/XmlAttribute.h
Utilities/xml/XmlException.cpp Utilities/xml/XmlException.h
Utilities/xml/XmlNode.cpp Utilities/xml/XmlNode.h
Utilities/xml/XmlReader.cpp Utilities/xml/XmlReader.h
Utilities/xml/XmlWriter.cpp Utilities/xml/XmlWriter.h
Utilities/xml/XmlUtilities.cpp Utilities/xml/XmlUtilities.h
)

SET( vtkPatheter_SRCS
 MainFrm.cpp MainFrm.h
StdAfx.cpp StdAfx.h
vtkSDI.cpp vtkSDI.h
vtkSDI.rc
randomIns.h
vtkSDIDoc.cpp vtkSDIDoc.h
vtkSDIView.cpp vtkSDIView.h
vtkPointGrouper.cpp vtkPointGrouper.h
vtkPointGroupVisibilities.cpp vtkPointGroupVisibilities.h
PatheterInteractor.cpp PatheterInteractor.h
AblationListCtrl.cpp AblationListCtrl.h
AblationRangeDialog.cpp AblationRangeDialog.h
AblationStats.h AblationStats.cpp
AutoDataReader.cpp AutoDataReader.h
AutoDataProcessor.cpp AutoDataProcessor.h
AutoDataWriter.cpp AutoDataWriter.h
ClassifyDialog.cpp ClassifyDialog.h
TriangleParticulator.cpp TriangleParticulator.h
SmoothingDlg.cpp SmoothingDlg.h
BoxFilterDialog.cpp BoxFilterDialog.h
FilterDialog.cpp FilterDialog.h
TargetAttempt.h
TargetFilterDialog.cpp TargetFilterDialog.h
ContactClassificationDlg.h ContactClassificationDlg.cpp
PieChartWnd.cpp PieChartWnd.h
CartoMapInfo.h CartoMapInfo.cpp
resource.h
res/particulator.bmp
res/vtkSDI.ico
res/vtkSDI.rc2
res/vtkSDIDoc.ico
res/Toolbar.bmp
${POINT_GROUP_FILES}
${FACTORY_FILES}
${MEMENTO_FILES}
${UTILITY_FILES}
VirtualCatheter/DeviceManager.cpp VirtualCatheter/DeviceManager.h
VirtualCatheter/DeviceSelection.cpp VirtualCatheter/DeviceSelection.h
VirtualCatheter/CatheterProperties.cpp VirtualCatheter/CatheterProperties.h VirtualCatheter/CatheterSegmentInfo.h
VirtualCatheter/VirtualCatheter.cpp VirtualCatheter/VirtualCatheter.h
VirtualCatheter/BaseData.cpp VirtualCatheter/BaseData.h
VirtualCatheter/VirtualCatheterException.cpp VirtualCatheter/VirtualCatheterException.h
AutoDataSample40/AutoDataSample.cpp AutoDataSample40/AutoDataSample.h
AutoDataSample40/CasStatusInfo.h AutoDataSample40/MagnetData.h AutoDataSample40/MappingGated.h
 AutoDataSample40/RealtimeCatheterData.h AutoDataSample40/MappingNonGated.h AutoDataSample40/Timestamp.h
)

LINK_LIBRARIES(
  vtkRendering
  vtkGraphics
  vtkImaging
  vtkIO
  vtkFiltering
  vtkCommon
  vtkHybrid
  vtkWidgets
  Gdiplus.lib
  Dbghelp.lib
)


# add stuff to use MFC in this executable
ADD_DEFINITIONS(-D_AFXDLL)
SET(CMAKE_MFC_FLAG 6)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
# This line eliminates Visual Studio from constant rebuilding ZERO_CHECK
SET(CMAKE_SUPPRESS_REGENERATION 1)
ADD_EXECUTABLE(vtkPatheter WIN32 ${vtkPatheter_SRCS} ${GAWK_BINS} ${GAWK_SCRIPTS})




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140528/d36b0598/attachment.html>


More information about the vtkusers mailing list