VTK 9.1, MINGW64 and Windows 10

I upgraded from gcc 8.3 (MSYS2/MinGW64), which compiled VTK 9.1 just fine, to 11.2 and I started to get those redefinition errors. I confirm that adding -fcommon to the compiler flags works. Did any of you start an issue in libtiff site already?

Hello friends, I am also updating VTK recently, but when I check the BUILD_SHARED_LIBS, mingw32-make process will generate a lot of inline function errors, which will eventually cause the compilation to fail. I wonder if you have encountered such a problem?

Hello,

Did you try the -fcommon compiler flag? There was a change in GCC behavior meaning that fno-common is now the default.

regards,

Paulo

Thanks, I’ll try

failed again…

What were the errors?

That’s a warning, not an error. I get lots of those when I link my programs against VTK. Although warnings signal potential problems, I think, in this case, you can safely ignore them as they are caused by double/multiple declarations of the same function: one with and other without the __declspec(dllimport) . Either this or you tweak VTK code to add __declspec(dllimport) to all declarations of the offending functions or make them different symbols by adding inline, for instance.

this is template

“template
class VTKIMAGINGCORE_EXPORT vtkImageStencilIterator : public vtkImagePointDataIterator
{
public:
…”

and I’m not good at Template

Hi,

A template, as the name implies, is a code for a class or a function with a few parts missing. These parts are automatically filled by the preprocessor to make complete C++ code. A template helps the programmer such that writing code is minimized. For example, suppose you need to implement array classes for scalar types in your program. In classic C++ you need to write (and maintain!) one class for each data type: myArrayOfInt, myArrayOfFloat, myArrayOfDouble, etc. With templates, you simply declare just once:

template <class AnyType>
class Array{
    AnyType sum( AnyType a, AnyType b ){
       return a + b;
    }
};

The code above is ignored by the compiler. But, when you write elsewhere something like Array<int> array_of_integers;, the preprocessor takes the template above and writes something like this on the fly for the compiler to compile:

class ArrayOfInt{
    int sum( int a, int b ){
       return a + b;
    }
};

This is called generic programming. With templates, you improve productivity and maximize code reuse. Does this make sense?

regards,

Paulo

:sweat_smile: :joy: :joy: :joy: :joy:

What’s so funny?

1 Like

This is VTK source, I just wanna build VTK with Mingw64.

Ok. We can start by you telling us what is the error you’re getting.

1 config everything with CMAKE-gui, because I use Qt make UI,so I confige GCC ,


2 I do this when I built VTK 9.0.1, It’s ok.
3 now, I wann upgrade VTK9.1.0

4 then , build VTK ,

5 but failed. This part file no change from VTK 9.0.1 !!! really???

As I’m not very experienced with cmake, I was wondering how to do this. I believe I got it to work now, so I’m answering for future visitors who are wondering the same.

  • I believe the flags could be changed in the ccmake (Linux) or cmake-gui (Windows) command. That was not an option for me for reasons that are irrelevant here.

  • What I did was modify VTK-9.1.0\CMake\vtkCompilerPlatformFlags.cmake to contain

  set(VTK_REQUIRED_CXX_FLAGS "${VTK_REQUIRED_CXX_FLAGS} -fcommon" )
  set(VTK_REQUIRED_C_FLAGS "${VTK_REQUIRED_C_FLAGS} -fcommon" )
  set(VTK_REQUIRED_EXE_LINKER_FLAGS "${VTK_REQUIRED_EXE_LINKER_FLAGS} -fcommon" )

and VTK-9.1.0\ThirdParty\tiff\CMakeLists.txt to contain

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcommon" )
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcommon" )
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fcommon" )

This is probably overkill, but it worked.

Hello. Sorry for the late response. I didn’t like that much. You do you mean by upgrade? You have to configure and build VTK 9.1 from scratch. If you’re reusing something from VTK 9.0.1 (e.g. build directory, libraries, CMakeLists.txt, etc.) you will likely run into problems. Forget VTK 9.0.1.

Hello,

Overkill indeed.

This is how to set the -fcommon flag properly:

Or, if command lines suit you: cmake (...) -DCMAKE_CXX_FLAGS=-fcommon -DCMAKE_C_FLAGS=-fcommon.

regards,

Paulo

1 Like

I, have tried many things to build vtk using MINGW64. but getting below error.

anybody can help me or any one can share the installed vtk folder which is build using the MINGW64.

Hi @PRJ

MINGW64 is not officially supported by VTK, why not using visual studio compilers ?

Hi @mwestphal
We have project which are build using MINGW64 and when I use vtk libraries which are build using visual studio compiler, it gives linkers errors.