KWWidgets/Projects/UIDesigner/HOWTOCompileVTK5MinGW: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Compile VTK and KWWidgets using MinGW==
==Compile VTK and KWWidgets using MinGW==


&nbsp;&nbsp;&nbsp;&nbsp;This document describes the procedure followed to compile the VTK and KWWidgets CVS versions listed below, under the Window XP platform using CMake 2.4.2 and the MinGW compiler based on gcc/g++ 3.4.2.<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;This document describes the procedure followed to compile the VTK and KWWidgets CVS versions listed below, under the Window XP platform using CMake and the MinGW compiler based on gcc/g++, versions listed below.<br><br>


{| align="left" border="1"
{| align="left" border="1"
| align="center" | <b>VTK version</b> || align="center" | <b>KWWidgets version</b> || align="center" | <b>Download Date</b> || align="center" | <b>Document's Modification Tag</b>
|+''' Used tools and their versions'''
| <b>CMake</b> || <b>VTK</b> || <b>KWWidgets</b> || <b>MinGW</b> || <b>MSYS</b> || align="center" | <b>Document's Modification Tag</b>
|-
|-
| align="center" | 5.1.x || align="center" | 1.x || align="center" | 05/13/2006 || align="center" | Original Document
| align="center" | 2.4.2 || align="center" | 5.1.x(cvs 05/13/2006) || align="center" | 1.x(cvs 05/13/2006) || align="center" | 5.0.2/gcc-3.4.2 || align="center" | 1.0.10 || align="center" | Original Document
|-
|-
| align="center" | 5.1.x || align="center" | 1.x || align="center" | 08/07/2006 || align="center" | MODIF_JCBA_20060808
| align="center" | 2.4.3 || align="center" | 5.1.x(cvs 08/07/2006) || align="center" | 1.x(cvs 08/07/2006) || align="center" | 5.0.2/gcc-3.4.2 || align="center" | 1.0.10 || align="center" | MODIF_JCBA_20060808
|}
|}


Line 16: Line 17:
<b><u>Summary</u></b><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>
This summary lists the steps to take in order to compile VTK and KWWidgets using the MinGW compiler under Windows XP.<br>
:&bull; (''MODIF_JCBA_20060808'') Download and install MinGW-5.0.2, found at http://, and MSYS-1.0.10, found at http://. Use install-directories whose names don't contain white spaces, like C:\mingw for MinGW and C:\msys for MSYS.<br><strike>(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.)</strike><br><br>
:&bull; (''MODIF_JCBA_20060808'') Download and install MinGW-5.0.2, found at http://prdownloads.sourceforge.net/mingw/MinGW-5.0.2.exe?download, and MSYS-1.0.10, found at http://prdownloads.sourceforge.net/mingw/MSYS-1.0.10.exe?download. Use install-directories whose names don't contain white spaces, like C:\mingw for MinGW and C:\msys for MSYS.<br><strike>(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.)</strike><br>
:&bull; 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>
:&bull; 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>
:&bull; Make sure the Tcl/Tk distribution was not build using the _cdecl calling convention:<br>
:&bull; Make sure the Tcl/Tk distribution was not build using the _cdecl calling convention:<br>
Line 24: Line 25:
:&bull; (''MODIF_JCBA_20060808'') Opend the Windows command-line interpreter, cmd, cd to the directory where your compiler executables are, e.g. C:\mingw\bin, and lauch CMakeSetup.exe from there, e.g C:\mingw\bin>C:\cmake\bin\CMakeSetup.exe<br>
:&bull; (''MODIF_JCBA_20060808'') Opend the Windows command-line interpreter, cmd, cd to the directory where your compiler executables are, e.g. C:\mingw\bin, and lauch CMakeSetup.exe from there, e.g C:\mingw\bin>C:\cmake\bin\CMakeSetup.exe<br>
:&bull; Choose 'MSYS Makefile' as the type of makefiles to generate.<br>
:&bull; Choose 'MSYS Makefile' as the type of makefiles to generate.<br>
:&bull; (''MODIF_JCBA_20060808'') Turn on 'BUILD_SHARED_LIBS'. Change MAKE_PROGRAM: instead of using '-i' as the options passed to make, use '-d --unix', e.g MAKE_PROGRAM: C:\msys\bin\make -d --unix.
:&bull; (''MODIF_JCBA_20060808'') Turn on 'BUILD_SHARED_LIBS'. Change MAKECOMMAND: instead of using '-i' as the options passed to make, use '-d --unix', e.g MAKECOMMAND: C:\msys\bin\make -d --unix.
:&bull; Configure VTK with TCL wrapping enabled. Make sure you specify the 'libtcl84.a' and 'libtk84.a' libraries, instead of their correpondant .dll.<br>
:&bull; Configure VTK with TCL wrapping enabled. Make sure you specify the 'libtcl84.a' and 'libtk84.a' libraries, instead of their correpondant .dll.<br>
:&bull; (''MODIF_JCBA_20060808'') Open the MSYS terminal, i.e. C:\msys\bin\msys.bat, if not already there prepend to PATH the folder where the MSYS binaries are, i.e. PATH="/usr/bin:$PATH", cd to the VTK build directory, e.g. 'cd /c/VTK-build', launch make by typing '/usr/bin/make', without the quotes <strike>On the MinGW console type 'make'</strike> and wait for the sources to compile</strike>.<br>
:&bull; (''MODIF_JCBA_20060808'') Open the MSYS terminal, i.e. C:\msys\bin\msys.bat, if not already there prepend to PATH the folder where the MSYS binaries are, i.e. PATH="/usr/bin:$PATH", cd to the VTK build directory, e.g. 'cd /c/VTK-build', launch make by typing '/usr/bin/make', without the quotes <strike>On the MinGW console type 'make'</strike> and wait for the sources to compile</strike>.<br>
:&bull; Add to your path the directory where the VTK binaries and libraries were built, e.g. PATH="$PATH:/c/VKT-build/bin".<br>
:&bull; Add to your path the directory where the VTK binaries and libraries were built, e.g. PATH="$PATH:/c/VKT-build/bin".<br>
:&bull; Download the lattest CVS version of KWWidgets.<br>
:&bull; Download the lattest CVS version of KWWidgets.<br>
:&bull; Use CMake to configure as done for the VTK sources(''MODIF_JCBA_20060808''), pay close attention to generate MSYS Makefiles and the MAKE_PROGRAM options '-d --unix'.<br>
:&bull; Use CMake to configure as done for the VTK sources(''MODIF_JCBA_20060808''), pay close attention to generate MSYS Makefiles and the MAKECOMMAND options '-d --unix'.<br>
:&bull; (''MODIF_JCBA_20060808'') Launch make just like with for the VTK sources.   
:&bull; (''MODIF_JCBA_20060808'') Launch make just like with for the VTK sources.   
:&bull; (''MODIF_JCBA_20060808'') If you get an error message about an undefined reference to 'PrintDlgA@4', at about 84% way through the build process, then you need to modify one file. Do the following:
:&bull; (''MODIF_JCBA_20060808'') If you get an error message about an undefined reference to 'PrintDlgA@4', at about 84% way through the build process, then you need to modify one file. Do the following:
Line 38: Line 39:
:::CMakeFiles/KWWidgets.dir/vtkKWSelectionFrameLayoutManager.obj(.text+0x6c0d):vtkKWSelectionFrameLayoutManager.cxx: undefined reference to 'PrintDlgA@4'
:::CMakeFiles/KWWidgets.dir/vtkKWSelectionFrameLayoutManager.obj(.text+0x6c0d):vtkKWSelectionFrameLayoutManager.cxx: undefined reference to 'PrintDlgA@4'
:::collect2: ld returned 1 exit status
:::collect2: ld returned 1 exit status
::&bull; Open a second MSYS terminal, cd to the KWWidgets build directory, e.g. 'cd /c/KWWidgets-build', then grep for the line stating the linking of libKWWidgets.dll, i.e. grep -rn 'Linking CXX shared library bin/libKWWidgets.dll. In the case of the 08/07/2006 KWWidgets CVS sources and with my CMake configuration, that line was found in the file CMakeFiles/KWWidgets.dir/build.make at line 6167, but it could be in another line depending on  the configuration and sources' version.
::&bull; Open a second MSYS terminal, cd to the KWWidgets build directory, e.g. 'cd /c/KWWidgets-build', then grep for the line stating the linking of libKWWidgets.dll, i.e. grep -rn 'Linking CXX shared library bin/libKWWidgets.dll. In the case of the 08/07/2006 KWWidgets CVS sources and with my CMake configuration, that line was found in the file CMakeFiles/KWWidgets.dir/build.make at line 6167, but it could be in another line depending on  the configuration and sources' version. ''Note'': Download the [http://unxutils.sourceforge.net/ GNU utilities for Win32] unxutils, to use grep and many more great GNU tools.<br>
::&bull; Open in a text-editor the file returned by grep and append to the line invoking the g++ compiler, which should be just two lines below the line indicated by grep, the following: '-lcomdlg32', without the quotes, i.e. edit line number 6169 as this : C:/mingw/bin/g++.exe <....> -lcomdlg32<END_OF_LINE>, where <...> is the original command arguments and <END_OF_LINE> indicates the end of the line/command arguments. <strike>Edit the following file 'CMakeFiles/KWWidgets.dir/build.make'. At line 5676 you should append '-lcomdlg32', without the quotes.</strike> This step might not be necessary in later versions of KWWidgets/CMake.<br>
::&bull; Open in a text-editor the file returned by grep and append to the line invoking the g++ compiler, which should be just two lines below the line indicated by grep, the following: '-lcomdlg32', without the quotes, i.e. edit line number 6169 as this : C:/mingw/bin/g++.exe <....> -lcomdlg32<END_OF_LINE>, where <...> is the original command arguments and <END_OF_LINE> indicates the end of the line/command arguments. <strike>Edit the following file 'CMakeFiles/KWWidgets.dir/build.make'. At line 5676 you should append '-lcomdlg32', without the quotes.</strike> This step might not be necessary in later versions of KWWidgets/CMake.<br>
::&bull; On the MinGW console relaunch make, i.e. type '/usr/bin/make' <strike>'make'</strike> and wait for the sources to compile.<br>
::&bull; On the MinGW console relaunch make, i.e. type '/usr/bin/make' <strike>'make'</strike> and wait for the sources to compile.<br>

Latest revision as of 05:05, 8 August 2006

Compile VTK and KWWidgets using MinGW

    This document describes the procedure followed to compile the VTK and KWWidgets CVS versions listed below, under the Window XP platform using CMake and the MinGW compiler based on gcc/g++, versions listed below.

Used tools and their versions
CMake VTK KWWidgets MinGW MSYS Document's Modification Tag
2.4.2 5.1.x(cvs 05/13/2006) 1.x(cvs 05/13/2006) 5.0.2/gcc-3.4.2 1.0.10 Original Document
2.4.3 5.1.x(cvs 08/07/2006) 1.x(cvs 08/07/2006) 5.0.2/gcc-3.4.2 1.0.10 MODIF_JCBA_20060808







    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.

• (MODIF_JCBA_20060808) Download and install MinGW-5.0.2, found at http://prdownloads.sourceforge.net/mingw/MinGW-5.0.2.exe?download, and MSYS-1.0.10, found at http://prdownloads.sourceforge.net/mingw/MSYS-1.0.10.exe?download. Use install-directories whose names don't contain white spaces, like C:\mingw for MinGW and C:\msys for MSYS.
(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 that Tcl/Tk distribution to compile VTK. This is why the MinGW specific Tcl/Tk versions are recommended.
• Download and install CMake version (MODIF_JCBA_20060808) 2.4.3, which has a new cool feature CMAKE_COLOR_OUTPUT: Enable/Disable color output during build. 2.4.2.
• Download the lattest CVS version of VTK (MODIF_JCBA_20060808) and eventually the CVS version of VTKData, if you want to build the examples.
• (MODIF_JCBA_20060808) Opend the Windows command-line interpreter, cmd, cd to the directory where your compiler executables are, e.g. C:\mingw\bin, and lauch CMakeSetup.exe from there, e.g C:\mingw\bin>C:\cmake\bin\CMakeSetup.exe
• Choose 'MSYS Makefile' as the type of makefiles to generate.
• (MODIF_JCBA_20060808) Turn on 'BUILD_SHARED_LIBS'. Change MAKECOMMAND: instead of using '-i' as the options passed to make, use '-d --unix', e.g MAKECOMMAND: C:\msys\bin\make -d --unix.
• Configure VTK with TCL wrapping enabled. Make sure you specify the 'libtcl84.a' and 'libtk84.a' libraries, instead of their correpondant .dll.
• (MODIF_JCBA_20060808) Open the MSYS terminal, i.e. C:\msys\bin\msys.bat, if not already there prepend to PATH the folder where the MSYS binaries are, i.e. PATH="/usr/bin:$PATH", cd to the VTK build directory, e.g. 'cd /c/VTK-build', launch make by typing '/usr/bin/make', without the quotes On the MinGW console type 'make' and wait for the sources to compile.
• Add to your path the directory where the VTK binaries and libraries were built, e.g. PATH="$PATH:/c/VKT-build/bin".
• Download the lattest CVS version of KWWidgets.
• Use CMake to configure as done for the VTK sources(MODIF_JCBA_20060808), pay close attention to generate MSYS Makefiles and the MAKECOMMAND options '-d --unix'.
• (MODIF_JCBA_20060808) Launch make just like with for the VTK sources.
• (MODIF_JCBA_20060808) If you get an error message about an undefined reference to 'PrintDlgA@4', at about 84% way through the build process, then you need to modify one file. Do the following:
• The context and full error message is
[ 84%] Building C object CMakeFiles/KWWidgets.dir/Utilities/ApplicationIcon/vtkKWSetApplication
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'
collect2: ld returned 1 exit status
• Open a second MSYS terminal, cd to the KWWidgets build directory, e.g. 'cd /c/KWWidgets-build', then grep for the line stating the linking of libKWWidgets.dll, i.e. grep -rn 'Linking CXX shared library bin/libKWWidgets.dll. In the case of the 08/07/2006 KWWidgets CVS sources and with my CMake configuration, that line was found in the file CMakeFiles/KWWidgets.dir/build.make at line 6167, but it could be in another line depending on the configuration and sources' version. Note: Download the GNU utilities for Win32 unxutils, to use grep and many more great GNU tools.
• Open in a text-editor the file returned by grep and append to the line invoking the g++ compiler, which should be just two lines below the line indicated by grep, the following: '-lcomdlg32', without the quotes, i.e. edit line number 6169 as this : C:/mingw/bin/g++.exe <....> -lcomdlg32<END_OF_LINE>, where <...> is the original command arguments and <END_OF_LINE> indicates the end of the line/command arguments. 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 relaunch make, i.e. type '/usr/bin/make' '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.