MantisBT - VTK
View Issue Details
0011742VTK(No Category)public2011-01-21 07:302013-04-05 20:35
Christian Lackas 
David Partyka 
normalminoralways
closedfixed 
MSYS/MinGW-w64Windows7 64-bit
 
 
0011742: 64-bit build fails using MinGW-w64
When trying to build VTK (SVN trunk) on Windows 7 using MinGW-w64 (gcc/g++ 4.4.5 20100604) I run into a number of issues, namely:

1) Quite a few places where pointers are converted to integers to
   be used as ids, which on a 64-bit system failed due to loss of precision
   when casting pointers to e.g. long.
   I replaced the casts to intptr_t, which seems to be the natural
   choice for this operation (and should be available on all
   C99/C++0X compatible compilers).
2) On MinGW-w64 one cannot use __int64 type together with long long,
   something that apparently was addressed in CMake/vtkTestTypes.cmake
   (according to the svn history), however, the ruleset there still did
   not work for me and I has to force VTK_TYPE_USE___INT64 to 0.
3) Two Windows symbols (GWL_WNDPROC and HWL_HINSTANCE) were not defined
   for unknown reasons. Since I don't fully understand vtk's mechanism
   of not including windows.h when building vtk itself, I just used a
   big hammer (just defining the symbols on my own).
4) Overwriting _WIN32_WINNT caused problems, just removed that.
5) Removed an apparently obsolete typedef for 'signed char' that lead to
   a redefined error.
I had build VTK with these options when I ran into above problems:

cmake -DDESIRED_QT_VERSION=4
        -DVTK_USE_GUISUPPORT=on
        -DVTK_USE_QT=on
        -DVTK_USE_QVTK=on
        -DVTK_QT_MOC_EXECUTABLE=moc
        -DVTK_QT_QMAKE_EXECUTABLE=qmake
        -DVTK_QT_UIC_EXECUTABLE=uic
        -DBUILD_EXAMPLES=off
   -G "MSYS Makefiles" ..
Rough patch (for 2 and 3 I just cure the symptoms not the cause) which allows successful build attached.
No tags attached.
patch vtk-msys-mingw64.patch (6,797) 2011-01-21 07:31
https://www.vtk.org/Bug/file/8650/vtk-msys-mingw64.patch
Issue History
2011-01-21 07:30Christian LackasNew Issue
2011-01-21 07:31Christian LackasFile Added: vtk-msys-mingw64.patch
2011-01-21 08:23David PartykaAssigned To => David Partyka
2011-01-21 08:23David PartykaStatusbacklog => tabled
2011-06-16 13:12Zack GalbreathCategoryDevelopment => (No Category)
2011-09-19 17:43David PartykaStatusbacklog => todo
2011-09-19 17:43David PartykaStatustodo => active development
2011-09-21 09:21David PartykaNote Added: 0027508
2011-09-21 09:21David PartykaStatusactive development => gatekeeper review
2011-09-21 09:21David PartykaStatusgatekeeper review => customer review
2011-09-21 09:27David PartykaNote Added: 0027509
2012-11-08 09:17eudoxosNote Added: 0029671
2012-11-08 09:18eudoxosNote Edited: 0029671bug_revision_view_page.php?bugnote_id=29671#r529
2012-11-08 10:12eudoxosNote Added: 0029672
2013-04-05 20:35Berk GeveciStatuscustomer review => closed
2013-04-05 20:35Berk GeveciResolutionopen => fixed

Notes
(0027508)
David Partyka   
2011-09-21 09:21   
Merged fixes based on Christian's patch into release and master.

PS C:\Kitware\VTK\source> git merge --no-ff 11742_mingw64_compile_fixes
Merge made by recursive.
 Common/vtkWin32Header.h | 6 +
 Hybrid/vtkVideoSource.cxx | 132 ++++++------
 Rendering/vtkFreeTypeTools.cxx | 2 +-
 Rendering/vtkFreeTypeUtilities.cxx | 2 +-
 Rendering/vtkWin32OpenGLRenderWindow.cxx | 236 ++++++++++----------
 Rendering/vtkWin32RenderWindowInteractor.cxx | 312 +++++++++++++-------------
 6 files changed, 349 insertions(+), 341 deletions(-)
(0027509)
David Partyka   
2011-09-21 09:27   
These fixes will be available for vtk 5.8.1 and future releases. If you want to try then now checkout either master (vtk 5.10) or the release branch (vtk 5.8.1).

The GWL_WNDPROC and HWL_HINSTANCE had to do with the fact that mingw's version of windows.h undefines those two type defs expecting you to use GWLP_<blah> and HWLP_<blah> on 64bit instead.
(0029671)
eudoxos   
2012-11-08 09:17   
(edited on: 2012-11-08 09:18)
Hi, please fix two more pointer-integer casts (those are errors) - patch below.

There is also a warning for the integer-pointer cast. which is not covered by the patch:

c:/src/VTK5.10.1/Hybrid/vtkWin32VideoSource.cxx: In function 'LONG vtkWin32VideoSourceWinProc(HWND, UINT, WPARAM, LPARAM)':
c:/src/VTK5.10.1/Hybrid/vtkWin32VideoSource.cxx:105:44: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

---

--- Hybrid/vtkWin32VideoSource.cxx.orig 2012-11-08 13:34:14 +0000
+++ Hybrid/vtkWin32VideoSource.cxx 2012-11-08 13:35:38 +0000
@@ -274,7 +274,7 @@
     }

   // set the user data to 'this'
- vtkSetWindowLong(this->Internal->ParentWnd,vtkGWL_USERDATA,(vtkLONG)this);
+ vtkSetWindowLong(this->Internal->ParentWnd,vtkGWL_USERDATA,(intptr_t)this);

   // Create the capture window
   this->Internal->CapWnd = capCreateCaptureWindow("Capture",
@@ -339,7 +339,7 @@
     }

   // set user data for callbacks
- if (!capSetUserData(this->Internal->CapWnd,(long)this))
+ if (!capSetUserData(this->Internal->CapWnd,(intptr_t)this))
     {
     vtkErrorMacro(<< "Initialize: couldn't set user data for callback"\
                     << " (" << GetLastError() << ")");

(0029672)
eudoxos   
2012-11-08 10:12   
FWIW, all other warnings related to pointer conversions:

c:/src/VTK5.10.1/Utilities/vtktiff/tif_fax3.c: In function 'vtk__TIFFFax3fillruns':
c:/src/VTK5.10.1/Utilities/vtktiff/tif_fax3.c:393:42: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
c:/src/VTK5.10.1/Utilities/vtktiff/tif_fax3.c:428:42: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
c:/src/VTK5.10.1/Utilities/vtktiff/tif_fax3.c: In function 'find0span':
c:/src/VTK5.10.1/Utilities/vtktiff/tif_fax3.c:803:25: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
c:/src/VTK5.10.1/Utilities/vtktiff/tif_fax3.c: In function 'find1span':
c:/src/VTK5.10.1/Utilities/vtktiff/tif_fax3.c:862:25: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
c:/src/VTK5.10.1/Utilities/vtktiff/tif_fax3.c: In function 'Fax3Encode1DRow':
c:/src/VTK5.10.1/Utilities/vtktiff/tif_fax3.c:937:22: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
c:/src/VTK5.10.1/Utilities/vtktiff/tif_fax3.c: In function 'Fax3DecodeRLE':
c:/src/VTK5.10.1/Utilities/vtktiff/tif_fax3.c:1515:48: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]



c:/src/VTK5.10.1/Utilities/vtktiff/tif_win32.c: In function 'vtk_TIFFFdOpen':
c:/src/VTK5.10.1/Utilities/vtktiff/tif_win32.c:162:42: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/src/VTK5.10.1/Utilities/vtktiff/tif_win32.c: In function 'vtk_TIFFOpen':
c:/src/VTK5.10.1/Utilities/vtktiff/tif_win32.c:217:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
c:/src/VTK5.10.1/Utilities/vtktiff/tif_win32.c: In function 'vtk_TIFFOpenW':
c:/src/VTK5.10.1/Utilities/vtktiff/tif_win32.c:272:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]


c:/src/VTK5.10.1/Rendering/vtkWin32OpenGLRenderWindow.cxx: In static member function 'static LRESULT vtkWin32OpenGLRenderWindow::WndProc(HWND, UINT, WPARAM, LPARAM)':
c:/src/VTK5.10.1/Rendering/vtkWin32OpenGLRenderWindow.cxx:162:72: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/src/VTK5.10.1/Rendering/vtkWin32OpenGLRenderWindow.cxx: In member function 'void vtkWin32OpenGLRenderWindow::InitializeApplication()':
c:/src/VTK5.10.1/Rendering/vtkWin32OpenGLRenderWindow.cxx:878:94: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/src/VTK5.10.1/Rendering/vtkWin32OpenGLRenderWindow.cxx: In member function 'virtual void vtkWin32OpenGLRenderWindow::SetWindowInfo(char*)':
c:/src/VTK5.10.1/Rendering/vtkWin32OpenGLRenderWindow.cxx:1321:26: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/src/VTK5.10.1/Rendering/vtkWin32OpenGLRenderWindow.cxx: In member function 'virtual void vtkWin32OpenGLRenderWindow::SetNextWindowInfo(char*)':
c:/src/VTK5.10.1/Rendering/vtkWin32OpenGLRenderWindow.cxx:1331:31: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/src/VTK5.10.1/Rendering/vtkWin32OpenGLRenderWindow.cxx: In member function 'virtual void vtkWin32OpenGLRenderWindow::SetParentInfo(char*)':
c:/src/VTK5.10.1/Rendering/vtkWin32OpenGLRenderWindow.cxx:1357:26: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]


c:/src/VTK5.10.1/Rendering/vtkWin32RenderWindowInteractor.cxx: In destructor 'virtual vtkWin32RenderWindowInteractor::~vtkWin32RenderWindowInteractor()':
c:/src/VTK5.10.1/Rendering/vtkWin32RenderWindowInteractor.cxx:88:90: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/src/VTK5.10.1/Rendering/vtkWin32RenderWindowInteractor.cxx: In member function 'virtual void vtkWin32RenderWindowInteractor::Enable()':
c:/src/VTK5.10.1/Rendering/vtkWin32RenderWindowInteractor.cxx:178:76: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/src/VTK5.10.1/Rendering/vtkWin32RenderWindowInteractor.cxx:179:86: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/src/VTK5.10.1/Rendering/vtkWin32RenderWindowInteractor.cxx: In member function 'virtual void vtkWin32RenderWindowInteractor::Disable()':
c:/src/VTK5.10.1/Rendering/vtkWin32RenderWindowInteractor.cxx:229:88: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
c:/src/VTK5.10.1/Rendering/vtkWin32RenderWindowInteractor.cxx: In function 'LRESULT vtkHandleMessage(HWND, UINT, WPARAM, LPARAM)':
c:/src/VTK5.10.1/Rendering/vtkWin32RenderWindowInteractor.cxx:701:76: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]