How to compile VTK 8.2.0 with gcc-7 and Qt 5.9.1 on MacOS 10.14?

@seanm
Thank you very much. I’ve got some good progress over here! I successfully compiled VTK 8.2.0 using clang.

Now, I tried to run the Cylinder Example with Qt Creator, which works like a charm as long as I compile it with clang as well.

However, in our project we are using GCC, so I tried to compile the example with the latter (using the VTK library compiled with clang) and it indeed compiles and links. Unfortunately, I only get a black screen as output then.

Do you have any idea or hint to solve that?

This is the *.pro file I used (which I created by myself):

TEMPLATE = app
SOURCES += CylinderExample.cxx
INCLUDEPATH += /Users/Shared/Development/VTK-8.2.0_clang/install/include/vtk-8.2
LIBS += \
  -L/Users/Shared/Development/VTK-8.2.0_clang/install/lib \
  -lvtkCommonColor-8.2 \
  -lvtkCommonCore-8.2 \
  -lvtkFiltersSources-8.2 \
  -lvtkInteractionStyle-8.2 \
  -lvtkRenderingContextOpenGL2-8.2 \
  -lvtkRenderingCore-8.2 \
  -lvtkRenderingFreeType-8.2 \
  -lvtkRenderingGL2PSOpenGL2-8.2 \
  -lvtkRenderingOpenGL2-8.2 \
  -lvtkCommonExecutionModel-8.2 \

This is the CylinderExample.cxx with an added define in the beginning to make it work:

#define vtkRenderingCore_AUTOINIT 2(vtkRenderingOpenGL2, vtkInteractionStyle)

#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkCylinderSource.h>
#include <vtkNamedColors.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>

#include <array>

int main(int, char *[]) {
  vtkSmartPointer<vtkNamedColors> colors =
      vtkSmartPointer<vtkNamedColors>::New();

  // Set the background color.
  std::array<unsigned char, 4> bkg{{26, 51, 102, 255}};
  colors->SetColor("BkgColor", bkg.data());

  // This creates a polygonal cylinder model with eight circumferential facets
  // (i.e, in practice an octagonal prism).
  vtkSmartPointer<vtkCylinderSource> cylinder =
      vtkSmartPointer<vtkCylinderSource>::New();
  cylinder->SetResolution(8);

  // The mapper is responsible for pushing the geometry into the graphics
  // library. It may also do color mapping, if scalars or other attributes are
  // defined.
  vtkSmartPointer<vtkPolyDataMapper> cylinderMapper =
      vtkSmartPointer<vtkPolyDataMapper>::New();
  cylinderMapper->SetInputConnection(cylinder->GetOutputPort());

  // The actor is a grouping mechanism: besides the geometry (mapper), it
  // also has a property, transformation matrix, and/or texture map.
  // Here we set its color and rotate it around the X and Y axes.
  vtkSmartPointer<vtkActor> cylinderActor = vtkSmartPointer<vtkActor>::New();
  cylinderActor->SetMapper(cylinderMapper);
  cylinderActor->GetProperty()->SetColor(
      colors->GetColor4d("Tomato").GetData());
  cylinderActor->RotateX(30.0);
  cylinderActor->RotateY(-45.0);

  // The renderer generates the image
  // which is then displayed on the render window.
  // It can be thought of as a scene to which the actor is added
  vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
  renderer->AddActor(cylinderActor);
  renderer->SetBackground(colors->GetColor3d("BkgColor").GetData());
  // Zoom in a little by accessing the camera and invoking its "Zoom" method.
  renderer->ResetCamera();
  renderer->GetActiveCamera()->Zoom(1.5);

  // The render window is the actual GUI window
  // that appears on the computer screen
  vtkSmartPointer<vtkRenderWindow> renderWindow =
      vtkSmartPointer<vtkRenderWindow>::New();
  renderWindow->SetSize(300, 300);
  renderWindow->AddRenderer(renderer);
  renderWindow->SetWindowName("Cylinder");

  // The render window interactor captures mouse events
  // and will perform appropriate camera or actor manipulation
  // depending on the nature of the events.
  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
      vtkSmartPointer<vtkRenderWindowInteractor>::New();
  renderWindowInteractor->SetRenderWindow(renderWindow);

  // This starts the event loop and as a side effect causes an initial render.
  renderWindow->Render();
  renderWindowInteractor->Start();

  return EXIT_SUCCESS;
}