Issue in while compiling VTK6.3 version source code on Ubuntu 22.04 LTS

Hi, I am trying to compile the source code of VTK6.3 version from GITHUB on Ubuntu 22.04 LTS using gcc +14.04 version of the compiler in the machine, but I used get the following error message :

CMake Error at CMake/vtkCompilerExtras.cmake:47 (if):
  if given arguments:

    "cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

  Copyright (C) 2021 Free Software Foundation, Inc.

  This is free software" " see the source for copying conditions.  There is
  NO

  warranty" " not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
  PURPOSE.

  

  " "VERSION_GREATER" "4.2.0" "AND" "BUILD_SHARED_LIBS" "AND"
  "HAVE_GCC_VISIBILITY" "AND" "VTK_USE_GCC_VISIBILITY" "AND" "NOT" "MINGW"
  "AND" "NOT" "CYGWIN"

  Unknown arguments specified
Call Stack (most recent call first):
  CMakeLists.txt:283 (include)

I need this version of VTK to support and compile other source code of TexGen … Could you please let me know the way to succeed the compilation and its installation on Ubuntu 22.04 LTS workstation. Thanks in advance

To get VTK 6.3 to compile with a modern compiler like gcc 11.4 and a modern version of cmake, you’ll have to examine (and fix) the code whenever errors occur during the build.

For the error you reported, CMake/vtkCompilerExtras.cmake needs the following fix at line 35:

-  string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]*"
+  string (REGEX MATCH "[0-9]+\\.[0-9]\\.[0-9]*"
    _gcc_version "${_gcc_version_info}")

After this, there will probably be other errors in other parts of the code. VTK 6.3 is nearly 10 years old, back then it would have compiled with gcc 4.8 or maybe gcc 5.3.

In the comment above, are you saying that you have installed an old compiler on your system? When I first read it, I thought it was a typo since there is no “gcc 14”. But if you mean that you’ve installed a compiler from Ubuntu 14.04 (which would be gcc 4.8?), then that might work if you set the cmake variables so that the VTK build uses that compiler instead of using the system’s default compiler.

Hi, thanks for the response.

My workstation running Ubuntu (22.04 LTS) has the following compiler versions:

  1. GCC (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 → gcc 11.4.0
  2. GCC (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 → g++ 11.4.0

I encountered the mentioned problem while compiling the VTK 6.3 source code from GitHub. Unfortunately, I do not have the option to use a higher version of VTK, such as 9 or 8, because other source codes, like TexGen, currently support only VTK 6.3 or earlier versions.

Is there any method to compile and install the suggested version of VTK (6.3) successfully?
Thanks in advance

Hi, After doing those suggested changes in the CMake/vtkCompilerExtras.cmake, I now used to get the following error while compiling the VTK6.3 :slight_smile:

CMake Error at CMake/vtkCompilerExtras.cmake:35:
  Parse error.  Expected a command name, got unquoted argument with text
  "-string".
Call Stack (most recent call first):
  CMakeLists.txt:283 (include)

Is there any way to compile this VTK6.3 or lower version of VTK with gcc 11.40 version of the compiler ?
Thanks in advance
Pandi P

I think you must have made a mistake doing the fix that I suggested. My suggestion was to replace the [345] in that file with [0-9]+ and then try building again. Is that what you did?

Hi
I observed the following error :slight_smile:

CMake Error at CMake/GenerateExportHeader.cmake:178 (if):
  if given arguments:

    "cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

  Copyright (C) 2021 Free Software Foundation, Inc.

  This is free software" " see the source for copying conditions.  There is
  NO

  warranty" " not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
  PURPOSE.

  

  " "VERSION_LESS" "4.2"

  Unknown arguments specified
Call Stack (most recent call first):
  CMake/GenerateExportHeader.cmake:354 (_test_compiler_hidden_visibility)
  CMake/vtkModuleMacros.cmake:702 (generate_export_header)
  Common/Core/CMakeLists.txt:646 (vtk_module_library)

This error was received after replace this line string (REGEX MATCH “[345]\.[0-9]\.[0-9]" with this line string (REGEX MATCH "[0-9]\.[0-9]\.[0-9]”. Thanks

image

CMake Error at CMake/GenerateExportHeader.cmake:178 (if):
if given arguments:

"cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

Copyright (C) 2021 Free Software Foundation, Inc.

This is free software" " see the source for copying conditions. There is
NO

warranty" " not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

" “VERSION_LESS” “4.2”

Unknown arguments specified
Call Stack (most recent call first):
CMake/GenerateExportHeader.cmake:354 (_test_compiler_hidden_visibility)
CMake/vtkModuleMacros.cmake:702 (generate_export_header)
Common/Core/CMakeLists.txt:646 (vtk_module_library)

The + is needed, otherwise it will not work: "[0-9]+\\.[0-9]\\.[0-9]*"

image
Do I need to put the plus symbol before the string. I made those correction based on the attached image?
Based on the suggested modification as shown in the image, I still get the above mentioned error while doing compilation .
Thanks

Yes, that is correct. So it looks like the first error is fixed.

The new error that you are seeing is from a different file:

CMake/GenerateExportHeader.cmake

It likely has the same problem as the first file. Try fixing it in the same way.

Hi, Many thanks that work for me after modifying those two cmake files using the suggested line in it but while building the same source code VTK6.3 using Make -j$(40), I received another error attached here for the reference :slight_smile:

Thanks in advance

That might be an error related to the c++11 standard. Try compiling with the c++98 standard instead, by setting the CMAKE_CXX_FLAGS in your CMakeCache.txt:

CMAKE_CXX_FLAGS:STRING=-std=c++98

May I know where to find this file " CMakeCache.txt: "to modify the suggsted line.
To make the suggested modification in the named file is missing in the CMAKE folder of VTK6.3

thanks

It’s the file that cmake edits when you run cmake.

So if you use ccmake, then run ccmake and look for CMAKE_CXX_FLAGS. If you use cmake-gui, then run cmake-gui.

It might be necessary to turn on the “Advanced” flag in cmake in order to see the CMAKE_CXX_FLAGS variable.

Hi, I just found that file “CMakeCache.txt” from the build directory folder, where I have seen the CMake_CXX_FLAGS:STRING as empy without any details and attached same for the reference. All this compilation was done Cmake via terminal command . Do I need specify those details at those suggsted location and rerun the make -j$(no process) command again ?

image

Thanks

Yes.

Hi, After doing those modification as shown in the attached image :
image
and installing further I received another error included here for the reference :slight_smile:

I tried to install with root and it does not show any error . May I know how whether I had installed correctly the VTK 6.3 version on my machine .

While checking the version of the installed VTK 6.3 thorugh terminal, it did not show anything
image

Did you read the error and do you understand what it means?

It’s a permission error. So you either need to run a final “make install” as root, or you have to edit your cmake cache again to change the install prefix to a different directory (e.g. your home directory) where you have permissions.