Build VTK with MinGW

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Build VTK with MinGW

tobias12345
Hello everybody,

I am trying to build VTK 8.1.1 with MinGW 4.9.4 on Windows. I use the
CMake-GUI, set

OPENGL_gl_LIBRARY="C:\Windows\System32\opengl32.dll"
OPENGL_glu_LIBRARY ="C:\Windows\System32\glu32.dll"

then configure, generate and make. The build fails at 42% while linking the
executable "vtkProbeOpenGLVersion.exe" with many undefined reference errors
as e.g.

../../lib/libvtkRenderingOpenGL2-8.1.a(vtkOpenGLCamera.cxx.obj):vtkOpenGLCamera.cxx:(.text+0xbd0):
undefined reference to `__imp___glewBindFramebuffer'
../../lib/libvtkRenderingOpenGL2-8.1.a(vtkOpenGLPointGaussianMapper.cxx.obj):vtkOpenGLPointGaussianMapper.cxx:(.text+0x53b):
undefined reference to `__imp___glewBlendFuncSeparate'
../../lib/libvtkRenderingOpenGL2-8.1.a(vtkOpenGLPolyDataMapper.cxx.obj):vtkOpenGLPolyDataMapper.cxx:(.text+0xf1d):
undefined reference to `__imp___glewDrawRangeElements'
../../lib/libvtkRenderingOpenGL2-8.1.a(vtkOpenGLPolyDataMapper2D.cxx.obj):vtkOpenGLPolyDataMapper2D.cxx:(.text+0x46ba):
undefined reference to `__imp___glewDrawRangeElements'
../../lib/libvtkRenderingOpenGL2-8.1.a(vtkOpenGLPolyDataMapper2D.cxx.obj):vtkOpenGLPolyDataMapper2D.cxx:(.text+0x48d9):
undefined reference to `__imp___glewDrawRangeElements'
../../lib/libvtkRenderingOpenGL2-8.1.a(vtkOpenGLPolyDataMapper2D.cxx.obj):vtkOpenGLPolyDataMapper2D.cxx:(.text+0x499f):
undefined reference to `__imp___glewDrawRangeElements'
../../lib/libvtkRenderingOpenGL2-8.1.a(vtkOpenGLPolyDataMapper2D.cxx.obj):vtkOpenGLPolyDataMapper2D.cxx:(.text+0x4a6e):
undefined reference to `__imp___glewDrawRangeElements

and hundreds more.

Anyone got an idea why?



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Build VTK with MinGW

bertikrueger
Am Di, 11. Sep, 2018 um 4:00 NACHMITTAGS schrieb tobias12345 <[hidden email]>:
__imp___glewBindFramebuffer

Hi Tobias.

I am not in any way an expert on vtk (still a vtk beginner myself) but from the compiler / linker errors you have posted, vtk seems to use the glew library internaly for enabling the opengl extensions in Windows and the linkage with the glew library seems not to be working correctly in your build environment.

This is often a problem when trying to link the glew library statically to a project without using the appropriate compiler flags. At least in linux the option -DGLEW_STATIC has to be added to the CXX_DEFINES so that glew gets linked statically in projects you want to be build statically.

So maybe you are trying to build vtk statically (.lib) and not dynamically (dlls) under mingw which results in the linker trying to link glew statically too but without the appropriate flags for glew to do so. 

So one thing you could try is to build vtk dynamically or if you have done so, build it statically.

It could also be that you have to install the glew libraries manually first before building vtk (i don't know) or that they are already installed in another version in your mingw installation and that the linker gets confused in which version to take.

I am normally developing under linux but a short time ago, i had to compile a Windows version of one of my vtk projects and i had problems myself building vtk under Windows with mingw. What solved all of my problems was installing msys2 (https://www.msys2.org/), getting a linux-like environment under windows with all the necessesary tools (mingw, cmake, etc.) and just building everythink like in linux. 

This still works like a charm and the executables produced with mingw in the msys2 environment are independent of msys2, have no external dependencies or whatsoever and can be used in every Windows installation.


Cheers

Berti


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Fcs
Reply | Threaded
Open this post in threaded view
|

Re: Build VTK with MinGW

Fcs
In reply to this post by tobias12345
Hello Tobias,

I think the problem you are having is that you are trying to mix two
programs compiled with different toolchains. Programs compiled with MinGW
are NOT compatible/linkable with programs compiled with the MSVC toolchain.
If you look at "C:\Windows\System32\opengl32.dll", it depends on MSVCRT.dll
which is the C standard library for Visual C++ (MSVC).

You have two choices:
 - Either you stick with MinGW, and you compile all your dependencies with
it (VTK, Qt, python, OpenGL..) so that the linking works
 - Or you stick with the MSVC toolchain, and compile all your dependencies
with it (or download them, as the most common libraries are readily
installable with MSVC compatibility), which will allow you to also link to
system libraries / system OpenGL.

From experience, the second option is by far the easiest, especially if you
start doing funky things..

If you choose to go down the MinGW route (good luck..), the Khronos group
has some instructions on their website for OpenGL support with MinGW:
https://www.khronos.org/opengl/wiki/MinGW

If you feel adventurous, their is an experimental third option, using the
excellent clang toolchain. Apparently it has (partial?) MSVC compatibility,
which would allow you to compile and link your code with libraries compiled
with MSVC.

Kind regards,

Francois.





--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Build VTK with MinGW

Allie Vacanti
It's also worth pointing out that VTK does not officially support the MinGW compilers. After you resolve this issue, there will likely be many more problems to fix before you have a working build.

The supported compilers on the Windows platform are currently MSVC 2013 or later.

On Wed, Sep 12, 2018 at 7:36 AM, Fcs <[hidden email]> wrote:
Hello Tobias,

I think the problem you are having is that you are trying to mix two
programs compiled with different toolchains. Programs compiled with MinGW
are NOT compatible/linkable with programs compiled with the MSVC toolchain.
If you look at "C:\Windows\System32\opengl32.dll", it depends on MSVCRT.dll
which is the C standard library for Visual C++ (MSVC).

You have two choices:
 - Either you stick with MinGW, and you compile all your dependencies with
it (VTK, Qt, python, OpenGL..) so that the linking works
 - Or you stick with the MSVC toolchain, and compile all your dependencies
with it (or download them, as the most common libraries are readily
installable with MSVC compatibility), which will allow you to also link to
system libraries / system OpenGL.

From experience, the second option is by far the easiest, especially if you
start doing funky things..

If you choose to go down the MinGW route (good luck..), the Khronos group
has some instructions on their website for OpenGL support with MinGW:
https://www.khronos.org/opengl/wiki/MinGW

If you feel adventurous, their is an experimental third option, using the
excellent clang toolchain. Apparently it has (partial?) MSVC compatibility,
which would allow you to compile and link your code with libraries compiled
with MSVC.

Kind regards,

Francois.





--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Build VTK with MinGW

bertikrueger
That's why i was recommending him to install msys2. With msys2 you get a linux-like environment in Windows with the complete toolchain (bash, cmake, gcc, make, python, openjdk, tcl / tk, etc.) and all the libraries needed (including Qt).  

For the vtk build system it looks like it is running under linux. So when using the vtk build instructions for linux everything works out of the box. 

By simply copying my vtk / qt source project files from linux to windows and running qmake (for qt) i was able to get a Windows build of my program without any additional work. Depending on other factors your mileage may vary of course.

The executable produced by this setup runs in a standard Windows environment without msys2 installed.

But you are right of course, if you don't need to have a consistent runtime behaviour on all platforms you can simply use Visual Studio on Windows since it is free anyway and much better supported.


Regards,

Berti

Am Do, 13. Sep, 2018 um 4:21 NACHMITTAGS schrieb Allie Vacanti <[hidden email]>:
It's also worth pointing out that VTK does not officially support the MinGW compilers. After you resolve this issue, there will likely be many more problems to fix before you have a working build.

The supported compilers on the Windows platform are currently MSVC 2013 or later.

On Wed, Sep 12, 2018 at 7:36 AM, Fcs <[hidden email]> wrote:
Hello Tobias,

I think the problem you are having is that you are trying to mix two
programs compiled with different toolchains. Programs compiled with MinGW
are NOT compatible/linkable with programs compiled with the MSVC toolchain.
If you look at "C:\Windows\System32\opengl32.dll", it depends on MSVCRT.dll
which is the C standard library for Visual C++ (MSVC).

You have two choices:
 - Either you stick with MinGW, and you compile all your dependencies with
it (VTK, Qt, python, OpenGL..) so that the linking works
 - Or you stick with the MSVC toolchain, and compile all your dependencies
with it (or download them, as the most common libraries are readily
installable with MSVC compatibility), which will allow you to also link to
system libraries / system OpenGL.

From experience, the second option is by far the easiest, especially if you
start doing funky things..

If you choose to go down the MinGW route (good luck..), the Khronos group
has some instructions on their website for OpenGL support with MinGW:
https://www.khronos.org/opengl/wiki/MinGW

If you feel adventurous, their is an experimental third option, using the
excellent clang toolchain. Apparently it has (partial?) MSVC compatibility,
which would allow you to compile and link your code with libraries compiled
with MSVC.

Kind regards,

Francois.





--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers