KWWidgets/Projects/UIDesigner/HOWTOCompileVTK5MinGW: Difference between revisions
Line 1: | Line 1: | ||
==Compile VTK using MinGW== | ==Compile VTK and KWWidgets using MinGW== | ||
This document describes the procedure followed to compile VTK, CVS version 5.X.X, under the Window XP platform using CMake 2.4.2 and the MinGW compiler | This document describes the procedure followed to compile VTK, CVS version 5.X.X, and KWWidgets, CVS version of May the 13th 2006, under the Window XP platform using CMake 2.4.2 and the MinGW compiler based on gcc 3.4.2.<br><br> | ||
''<u><b>Note</b></u>: This is only a description, and only enounces how to compile a specific version of VTK. This is NOT a generic HOWTO. Every platform and every VTK version might have different requirements. The process might be similar, but not the same.'' | ''<u><b>Note</b></u>: This is only a description, and only enounces how to compile a specific version of VTK. This is NOT a generic HOWTO. Every platform and every VTK version might have different requirements. The process might be similar, but not the same.''<br><br> | ||
<b><u>Summary</u></b><br><br> | |||
This summary lists the steps to take in order to compile VTK and KWWidgets using the MinGW compiler under Windows XP.<br> | |||
:• Follow the instructions found on this site http://www.dpinson.com/software/vtk/index.php to download and install MinGW and MSYS. Please <u><b>DO NOT</b></u> go through the 'Configure and Build VTK' section.<br> | |||
:• Download and install a Tcl/Tk distribution for Windows. The MinGW specific distribution is found here: http://prdownloads.sourceforge.net/mingw/tcltk-8.4.1-1.exe?download.<br> | |||
:• Make sure the Tcl/Tk distribution was not build using the _cdecl calling convention:<br> | |||
::Open the MinGW console, go to the directory where your Tk library file is found and type : objdump -t libtk84.a | grep -i winchild. The output should contain the following: '__imp__TkWinChildProc@16' and '_TkWinChildProc@16'. If the output looks different, i.e. '@16' is missing, you will not be able to use this Tcl/Tk distribution to compile VTK. This is why the MinGW specific Tcl/Tk version is recommended.<br> | |||
:• Download and install CMake version 2.4.2.<br> | |||
:• Download the lattest CVS version of VTK.<br> | |||
:• Lauch CMakeSetup.exe from the same directory where your compiler executables are.<br> | |||
:• Configure VTK with TCL wrapping enabled. Make sure you specify the 'libtcl84.a' and 'libtk84.a' libraries, instead of their correpondant .dll.<br> | |||
:• On the MinGW console type 'make' and wait for the sources to compile.<br> | |||
:• Add to your path the directory where the binaries and libraries were built.<br> | |||
:• Download the lattest CVS version of KWWidgets.<br> | |||
:• Use CMake to configure.<br> | |||
:• Edit the following file 'CMakeFiles/KWWidgets.dir/build.make'. At line 5676 you should append '-lcomdlg32', without the quotes. This step might not be necessary in later versions of KWWidgets/CMake.<br> | |||
:• On the MinGW console type 'make' and wait for the sources to compile.<br> | |||
:• Add to your path the directory where the binaries and libraries were built.<br><br> | |||
<u><b>In-detail process</b></u> | |||
The following lines list the steps taken and the encountered problems in order to compile VTK and KWWidgets under Windows XP using MinGW.<br><br> | |||
• The first steps were taken by following the instructions found in this site: http://www.dpinson.com/software/vtk/index.php. The site explains what are the necessary tools and where to retrieve them. As the site does not take into account the wrapping of TCL, which is indispensable for KWWidgets, the <u>Configure and Build VTK</u> section was not followed.<br><br> | |||
• The next step was to retrieve and install a Tcl/Tk distribution for Windows. ActiveTcl, found on this site was chosen: http://www.activestate.com/Products/ActiveTcl/ . <br><br> | |||
• Having all the necessary tools installed, the next step was to run CMake to configure VTK. At this stage the first problem was encountered. This error was shown by CMake 'The C compiler "F:/MinGW/bin/mingw32-gcc.exe" is not able to compile a simple test program.'. This problem is described in this post http://public.kitware.com/pipermail/cmake/2004-January/004635.html. The solution consists in invoking CMakeSetup.exe from the same directory where the compiler binaries are.<br><br> | |||
• The second problem was encountered, after TCL wrapping was enabled. This error was shown by CMake : 'CMake Error: Error in cmake code at ...vtkLoadCMakeExtensions.cmake: LOAD_COMMAND Attempt to load command failed from file: cmVTK_WRAP_TCL2.dll'. The solution consisted in renaming all the libcm*.dll files, found in the 'CMake' directory of the build folder, to cm*.dll and to reconfigure with CMake.<br><br> | |||
• The third problem was encountered, while compiling the sources. The 'TKWinChildProc@16' symbol could not be found. After having taken a look into this page http://www.barre.nom.fr/vtk/tcltk8-win.html, where Sebastien Barre explains how to compile VTK 2.0 under Windows, the problem was found: ActiveTcl was compile with the _cdecl call convention. The MinGW Tcl/Tk specific distribution, found here http://prdownloads.sf.net/mingw/tcltk-8.4.1-1.exe?download, was retrieved and installed. Following the example described by Sebastien Barre, the Tk library was inspected to determine whether or not it was compiled using the _cdecl calling conventions. Mr. Barre uses 'dumpbin' for this purpose, which is a VisualStudio utility. In our case we opted for the 'objdump' utility, since we want to assume VisualStudio is not available in our system. The command 'objdump -t libtk84.a | grep -i winchild' was used, which showed the libraries were not compiled using the _cdecl calling convention, so they can be used to compile VTK.<br> | |||
• CMake was used to reconfigure VTK in order to specify that the Tcl/Tk distribution to use would be the MinGW version and not ActiveTcl. The compile process was relaunched, but the following error was encountered: 'F:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -ltcl84.lib | |||
collect2: ld returned 1 exit status'. The 'Common/CMakeFiles/vtkCommonTCL.dir/build.make' file was edited and at line 2942 '-ltcl84.lib' was changed to '-ltcl84'.<br> | |||
• The compile process was relaunched, but a long list of error messages was displayed, of which the first line was: | |||
'CMakeFiles/vtkCommonTCL.dir/vtkCharArrayTcl.obj(.text$_ZN12vtkCharArray8SetArrayEPcii[vtkCharArray::SetArray(char*, int, int)]+0x22):vtkCharArrayTcl.cxx: undefined reference to `vtkDataArrayTemplate<char>::SetArray(char*, int, int)''. The solution at this stage consited in downloading and installing CMake version 2.4.2 and downloading the VTK CVS version<br> | |||
• VTK was once again reconfigure using CMake. The compile process was relaunched, but the following errors were encountered: | |||
'Linking CXX shared library ../bin/libvtkRenderingTCL.dll | |||
Creating library file: ../bin/libvtkRenderingTCL.dll.a | |||
CMakeFiles/vtkRenderingTCL.dir/vtkTkRenderWidget.obj(.text+0x185d):vtkTkRenderWidget.cxx: undefined reference to `_imp__TkWinChildProc@16' | |||
CMakeFiles/vtkRenderingTCL.dir/vtkTkRenderWidget.obj(.text+0x1897):vtkTkRenderWidget.cxx: undefined reference to `_imp__TkWinChildProc@16' | |||
CMakeFiles/vtkRenderingTCL.dir/vtkTkRenderWidget.obj(.text+0x19c8):vtkTkRenderWidget.cxx: undefined reference to `_imp__TkWinChildProc@16' | |||
CMakeFiles/vtkRenderingTCL.dir/vtkTkRenderWidget.obj(.text+0x1a02):vtkTkRenderWidget.cxx: undefined reference to `_imp__TkWinChildProc@16' | |||
CMakeFiles/vtkRenderingTCL.dir/vtkTkImageViewerWidget.obj(.text+0xa61):vtkTkImageViewerWidget.cxx: undefined reference to `_imp__TkWinChildProc@16' | |||
CMakeFiles/vtkRenderingTCL.dir/vtkTkImageViewerWidget.obj(.text+0xbb1):vtkTkImageViewerWidget.cxx: more undefined references to `_imp__TkWinChildProc@16''. Having determined the Tcl/Tk distribution was not compiled using the _cdecl calling convention, the problem was because by default CMake uses the 'tcl84.dll' and 'tk84.dll' libraries. The solution consisted in making sure to specify the use of the 'libtcl84.lib' and 'libtk84.lib' libraries, while configuring VTK with CMake.<br> | |||
• Reconfigured VTK with CMake taken into account all the information gathered in the previous points. The compile process was relaunched and this time it ended successfully.<br> | |||
• The next step was to retrieve the CVS sources of KWWidgets, configure with CMake and start the compile process.<br> | |||
• The follwing error was encountered: 'Linking CXX shared library bin/libKWWidgets.dll | |||
Creating library file: bin/libKWWidgets.dll.a | |||
CMakeFiles/KWWidgets.dir/vtkKWSelectionFrameLayoutManager.obj(.text+0x6c0d):vtkKWSelectionFrameLayoutManager.cxx: undefined reference to `PrintDlgA@4''. The post found on this site talks about this error:http://www.experts-exchange.com/Programming/Programming_Platforms/Win_Prog/Q_21181454.html. It explains that the flag '-lcomdlg32' should be passed to the linker. The file 'CMakeFiles/KWWidgets.dir/build.make' was edited at line 5676, where the linker flag '-lcomdlg32' was added.<br> | |||
• The compile process was relaunched and ended up successfully.<br> | |||
• To run the VTK and KWWidgets examples you have to add to your executable s' path the built binaries and libraries directories. |
Revision as of 03:55, 10 June 2006
Compile VTK and KWWidgets using MinGW
This document describes the procedure followed to compile VTK, CVS version 5.X.X, and KWWidgets, CVS version of May the 13th 2006, under the Window XP platform using CMake 2.4.2 and the MinGW compiler based on gcc 3.4.2.
Note: This is only a description, and only enounces how to compile a specific version of VTK. This is NOT a generic HOWTO. Every platform and every VTK version might have different requirements. The process might be similar, but not the same.
Summary
This summary lists the steps to take in order to compile VTK and KWWidgets using the MinGW compiler under Windows XP.
- • Follow the instructions found on this site http://www.dpinson.com/software/vtk/index.php to download and install MinGW and MSYS. Please DO NOT go through the 'Configure and Build VTK' section.
- • Download and install a Tcl/Tk distribution for Windows. The MinGW specific distribution is found here: http://prdownloads.sourceforge.net/mingw/tcltk-8.4.1-1.exe?download.
- • Make sure the Tcl/Tk distribution was not build using the _cdecl calling convention:
- Open the MinGW console, go to the directory where your Tk library file is found and type : objdump -t libtk84.a | grep -i winchild. The output should contain the following: '__imp__TkWinChildProc@16' and '_TkWinChildProc@16'. If the output looks different, i.e. '@16' is missing, you will not be able to use this Tcl/Tk distribution to compile VTK. This is why the MinGW specific Tcl/Tk version is recommended.
- Open the MinGW console, go to the directory where your Tk library file is found and type : objdump -t libtk84.a | grep -i winchild. The output should contain the following: '__imp__TkWinChildProc@16' and '_TkWinChildProc@16'. If the output looks different, i.e. '@16' is missing, you will not be able to use this Tcl/Tk distribution to compile VTK. This is why the MinGW specific Tcl/Tk version is recommended.
- • Download and install CMake version 2.4.2.
- • Download the lattest CVS version of VTK.
- • Lauch CMakeSetup.exe from the same directory where your compiler executables are.
- • Configure VTK with TCL wrapping enabled. Make sure you specify the 'libtcl84.a' and 'libtk84.a' libraries, instead of their correpondant .dll.
- • On the MinGW console type 'make' and wait for the sources to compile.
- • Add to your path the directory where the binaries and libraries were built.
- • Download the lattest CVS version of KWWidgets.
- • Use CMake to configure.
- • Edit the following file 'CMakeFiles/KWWidgets.dir/build.make'. At line 5676 you should append '-lcomdlg32', without the quotes. This step might not be necessary in later versions of KWWidgets/CMake.
- • On the MinGW console type 'make' and wait for the sources to compile.
- • Add to your path the directory where the binaries and libraries were built.
In-detail process
The following lines list the steps taken and the encountered problems in order to compile VTK and KWWidgets under Windows XP using MinGW.
• The first steps were taken by following the instructions found in this site: http://www.dpinson.com/software/vtk/index.php. The site explains what are the necessary tools and where to retrieve them. As the site does not take into account the wrapping of TCL, which is indispensable for KWWidgets, the Configure and Build VTK section was not followed.
• The next step was to retrieve and install a Tcl/Tk distribution for Windows. ActiveTcl, found on this site was chosen: http://www.activestate.com/Products/ActiveTcl/ .
• Having all the necessary tools installed, the next step was to run CMake to configure VTK. At this stage the first problem was encountered. This error was shown by CMake 'The C compiler "F:/MinGW/bin/mingw32-gcc.exe" is not able to compile a simple test program.'. This problem is described in this post http://public.kitware.com/pipermail/cmake/2004-January/004635.html. The solution consists in invoking CMakeSetup.exe from the same directory where the compiler binaries are.
• The second problem was encountered, after TCL wrapping was enabled. This error was shown by CMake : 'CMake Error: Error in cmake code at ...vtkLoadCMakeExtensions.cmake: LOAD_COMMAND Attempt to load command failed from file: cmVTK_WRAP_TCL2.dll'. The solution consisted in renaming all the libcm*.dll files, found in the 'CMake' directory of the build folder, to cm*.dll and to reconfigure with CMake.
• The third problem was encountered, while compiling the sources. The 'TKWinChildProc@16' symbol could not be found. After having taken a look into this page http://www.barre.nom.fr/vtk/tcltk8-win.html, where Sebastien Barre explains how to compile VTK 2.0 under Windows, the problem was found: ActiveTcl was compile with the _cdecl call convention. The MinGW Tcl/Tk specific distribution, found here http://prdownloads.sf.net/mingw/tcltk-8.4.1-1.exe?download, was retrieved and installed. Following the example described by Sebastien Barre, the Tk library was inspected to determine whether or not it was compiled using the _cdecl calling conventions. Mr. Barre uses 'dumpbin' for this purpose, which is a VisualStudio utility. In our case we opted for the 'objdump' utility, since we want to assume VisualStudio is not available in our system. The command 'objdump -t libtk84.a | grep -i winchild' was used, which showed the libraries were not compiled using the _cdecl calling convention, so they can be used to compile VTK.
• CMake was used to reconfigure VTK in order to specify that the Tcl/Tk distribution to use would be the MinGW version and not ActiveTcl. The compile process was relaunched, but the following error was encountered: 'F:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -ltcl84.lib
collect2: ld returned 1 exit status'. The 'Common/CMakeFiles/vtkCommonTCL.dir/build.make' file was edited and at line 2942 '-ltcl84.lib' was changed to '-ltcl84'.
• The compile process was relaunched, but a long list of error messages was displayed, of which the first line was:
'CMakeFiles/vtkCommonTCL.dir/vtkCharArrayTcl.obj(.text$_ZN12vtkCharArray8SetArrayEPcii[vtkCharArray::SetArray(char*, int, int)]+0x22):vtkCharArrayTcl.cxx: undefined reference to `vtkDataArrayTemplate<char>::SetArray(char*, int, int). The solution at this stage consited in downloading and installing CMake version 2.4.2 and downloading the VTK CVS version
• VTK was once again reconfigure using CMake. The compile process was relaunched, but the following errors were encountered:
'Linking CXX shared library ../bin/libvtkRenderingTCL.dll
Creating library file: ../bin/libvtkRenderingTCL.dll.a
CMakeFiles/vtkRenderingTCL.dir/vtkTkRenderWidget.obj(.text+0x185d):vtkTkRenderWidget.cxx: undefined reference to `_imp__TkWinChildProc@16'
CMakeFiles/vtkRenderingTCL.dir/vtkTkRenderWidget.obj(.text+0x1897):vtkTkRenderWidget.cxx: undefined reference to `_imp__TkWinChildProc@16'
CMakeFiles/vtkRenderingTCL.dir/vtkTkRenderWidget.obj(.text+0x19c8):vtkTkRenderWidget.cxx: undefined reference to `_imp__TkWinChildProc@16'
CMakeFiles/vtkRenderingTCL.dir/vtkTkRenderWidget.obj(.text+0x1a02):vtkTkRenderWidget.cxx: undefined reference to `_imp__TkWinChildProc@16'
CMakeFiles/vtkRenderingTCL.dir/vtkTkImageViewerWidget.obj(.text+0xa61):vtkTkImageViewerWidget.cxx: undefined reference to `_imp__TkWinChildProc@16'
CMakeFiles/vtkRenderingTCL.dir/vtkTkImageViewerWidget.obj(.text+0xbb1):vtkTkImageViewerWidget.cxx: more undefined references to `_imp__TkWinChildProc@16. Having determined the Tcl/Tk distribution was not compiled using the _cdecl calling convention, the problem was because by default CMake uses the 'tcl84.dll' and 'tk84.dll' libraries. The solution consisted in making sure to specify the use of the 'libtcl84.lib' and 'libtk84.lib' libraries, while configuring VTK with CMake.
• Reconfigured VTK with CMake taken into account all the information gathered in the previous points. The compile process was relaunched and this time it ended successfully.
• The next step was to retrieve the CVS sources of KWWidgets, configure with CMake and start the compile process.
• The follwing error was encountered: 'Linking CXX shared library bin/libKWWidgets.dll
Creating library file: bin/libKWWidgets.dll.a
CMakeFiles/KWWidgets.dir/vtkKWSelectionFrameLayoutManager.obj(.text+0x6c0d):vtkKWSelectionFrameLayoutManager.cxx: undefined reference to `PrintDlgA@4. The post found on this site talks about this error:http://www.experts-exchange.com/Programming/Programming_Platforms/Win_Prog/Q_21181454.html. It explains that the flag '-lcomdlg32' should be passed to the linker. The file 'CMakeFiles/KWWidgets.dir/build.make' was edited at line 5676, where the linker flag '-lcomdlg32' was added.
• The compile process was relaunched and ended up successfully.
• To run the VTK and KWWidgets examples you have to add to your executable s' path the built binaries and libraries directories.