[vtkusers] Compilig VTK 4.2 on WinXP with MinGW

Pete Nagy Peter.Nagy at vexcel.com
Fri Sep 16 12:52:05 EDT 2005


Ooo, are you in for it! ;)  I was asked to do this and eventually
succeeded, but it was not fun.

CMake was a serious pain in the rear.  I took a cue from others compiling
with mingw, and borrowed scripts to modify the cmake generated makefiles
to do things like remove the 'lib' from in front of the python dlls.
But, cmake often regenerates the makefiles, requiring multiple runs of the
script.  Other mingw builds of VTK I was able to locate on the web either
were cross compiling on a linux machine (and bypassed the difficulties
that arise when building in a unix-like shell on windows) or were not
building the python modules.

If you just installed MSYS or cygwin you might want to spend some time
looking at the documentation for building dlls with mingw.  Here are a
couple hints that I admit won't tell you everything but may help get you
past some VTK stumbling blocks:

- Install vtk in a location that will be identical whether using a windows
path or a cygwin unix path.  I put it into c:/opt/vtk, and used the cygwin
mount command to make c:/opt look like /opt; this way the cygwin (MSYS?)
shell can use /opt instead of /cygdrive/c/opt, because the latter will
choke anything looking for a windows path and the former won't.  You might
also have to tell cmake the exact location of mingw gcc using "c:..",
otherwise somewhere in there it will try to call `which gcc`, which might
be something like "/cygdrive/c/MinGW/bin/gcc", which might not be valid
for windows.

- I had to comment out the '#define CMAKE_NO_STD_NAMESPACE' line in
vtkConfigure.h.

- I commented out the java wrappers.  I only needed python, and did not
want to mess with the java errors.

- Make sure you use the -mms-bitfields flag

- When you do finally succeed in building dlls, and they don't work for
you at runtime, make sure you get 'Dependency Walker' for windows
(depends.exe).  This helps you figure out what the dll problems are.

- Use the -D__CYGWIN__ flag (at least in Rendering), or you will have
trouble with the wgl opengl functions.

- Use the -Wl flags like the below script.  You might try to get cmake to
generate the proper makefiles, but I got lazy and annoyed with cmake and
stopped trying to get it to do the right thing.

I apologize that I was unable to spend time cleaning up my mingw build.
At least you can take heart that it's been done before, and the proper
combination of flags will get you where you need to go without needing to
embark on a major code hack.  The following two links have some more info:

http://public.kitware.com/pipermail/vtkusers/2005-March/079054.html
http://www.tele.ucl.ac.be/~nicovic/#Cross-compiling

a hack I used:

#! /bin/sh
echo "Removing bad libvtk libs in bin"
rm -f /opt/vtk/bin/libvtk*
echo "Fixing makefiles in $PWD"
FILES="`find $PWD -name Makefile`"
for file in $FILES
do
echo "Fixing $file"
perl -pi.bak -e 's/libvtk/vtk/g' $file
perl -pi.bak -e 's/-shared  -o/-shared -Wl,--out-implib=$@.a
-Wl,--export-all-symbols -Wl,--enable-auto-import -o/' $file
perl -pi.bak -e 's/-Lc:\/windows\/system32/-Lc:\/Python24\/libs
-lpython24/g' $file
perl -pi.bak -e 's/c:\/windows\/system32//g' $file

done


Hope this all helps.

 -> Pete

--------------------------------------------------------------------

====================================================================
Pete Nagy                                        tel: (303) 583-0248
Vexcel Corporation                               fax: (303) 583-0246
http://www.vexcel.com                           home: (303) 823-2336
====================================================================


On Fri, 16 Sep 2005, Martin Baumann wrote:

> Hi,
>
> I searched the vtkuser archiv, but no mail could help me.
>
> I have the latest version of MinGW, CMake and VTK (4.2). Also I installed MSYS. I don't know if
> I really need MSYS.
>
> Did anyone made it to compile VTK 4.2 with MinGW? I mean without using any
> linux. Today I read alot of compiling VTK in Linux for Windows.
>
> Is there a HOWTO for this problem?
>
> I found this link http://www.dpinson.com/software/vtk/index.php where you can download makefiles
> that you can copy in your VTK-source directory and it is said that all you have to do is enter 'make'.
> In my case it doesn't work.
>
>
> Thanks, Martin



More information about the vtkusers mailing list