[Dune] including vtk-libraries in the dune-build system

egleiss at iup.uni-heidelberg.de egleiss at iup.uni-heidelberg.de
Wed Nov 12 14:42:46 CET 2014


Dear Dune Developers,

I have some problems with including libraries from the visualization
toolkit (vtk) into the dune build system. I have created a new dune module
as described in the tutorials and copied an example from the vtk-wiki
(http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/SimplePointsReader) into the
code:


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <iostream>
#include <dune/common/parallel/mpihelper.hh> // An initializer of MPI
#include <dune/common/exceptions.hh> // We use exceptions
#include <vtkSmartPointer.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkSimplePointsReader.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkProperty.h>

int main(int argc, char** argv)
{
  try{
    //Maybe initialize Mpi
    Dune::MPIHelper& helper = Dune::MPIHelper::instance(argc, argv);
    std::cout << "Hello World! This is Root-Architecture." << std::endl;
    if(Dune::MPIHelper::isFake)
      std::cout<< "This is a sequential program." << std::endl;
    else
      std::cout<<"I am rank "<<helper.rank()<<" of "<<helper.size()
        <<" processes!"<<std::endl;


// Verify input arguments
  if ( argc != 2 )
    {
    std::cout << "Usage: " << argv[0]
              << " Filename(.xyz)" << std::endl;
    return EXIT_FAILURE;
    }

  // Read the file
  vtkSmartPointer<vtkSimplePointsReader> reader =
    vtkSmartPointer<vtkSimplePointsReader>::New();
  /*reader->SetFileName ( argv[1] );
  reader->Update();

  // Visualize
  vtkSmartPointer<vtkPolyDataMapper> mapper =
    vtkSmartPointer<vtkPolyDataMapper>::New();
  mapper->SetInputConnection(reader->GetOutputPort());

  vtkSmartPointer<vtkActor> actor =
    vtkSmartPointer<vtkActor>::New();
  actor->SetMapper(mapper);
  actor->GetProperty()->SetPointSize(4);

  vtkSmartPointer<vtkRenderer> renderer =
    vtkSmartPointer<vtkRenderer>::New();
  vtkSmartPointer<vtkRenderWindow> renderWindow =
    vtkSmartPointer<vtkRenderWindow>::New();
  renderWindow->AddRenderer(renderer);
  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
    vtkSmartPointer<vtkRenderWindowInteractor>::New();
  renderWindowInteractor->SetRenderWindow(renderWindow);

  renderer->AddActor(actor);
  renderer->SetBackground(.3, .6, .3); // Background color green

  renderWindow->Render();
  renderWindowInteractor->Start();*/

  return EXIT_SUCCESS;

    //return 0;
  }
  catch (Dune::Exception &e){
    std::cerr << "Dune reported error: " << e << std::endl;
  }
  catch (...){
    std::cerr << "Unknown exception thrown!" << std::endl;
  }
}


I then run  $ dune-common/bin/dunecontrol --only=Root-Architecture
--opts=parallel.opts all
in order tu build my module.
My opts-file looks as follows:

CONFIGURE_FLAGS="--prefix=/Users/ericgleiss/opt --disable-documentation
--disable-mpiruntest --enable-parallel
--with-alugrid=/Users/ericgleiss/opt/alugrid
--with-alberta=/Users/ericgleiss/opt/alberta
--with-ug=/Users/ericgleiss/opt/ug-install CXX=g++-mp-4.8 CC=gcc-mp-4.8
F77=gfortran-mp-4.8 CXXFLAGS=\"-O3  -g0 -funroll-loops -ftree-vectorize
-fno-strict-aliasing -Wall -Wno-deprecated-declarations 
-I/usr/local/include/vtk-6.1/ -L/Users/ericgleiss/VTK-build/lib \"
CFLAGS=\"-O3 -g0 -funroll-loops -ftree-vectorize -fno-strict-aliasing
-Wall -Wno-deprecated-declarations\""
MAKE_FLAGS="all"


It seems that the header files are included correctly. However, I get the
following error message (the complete output is in the attachment):

Undefined symbols for architecture x86_64:
  "vtkSmartPointerBase::vtkSmartPointerBase(vtkObjectBase*,
vtkSmartPointerBase::NoReference const&)", referenced from:
      _main in Root_Architecture-Root_Architecture.o
  "vtkSmartPointerBase::~vtkSmartPointerBase()", referenced from:
      _main in Root_Architecture-Root_Architecture.o
  "vtkSimplePointsReader::New()", referenced from:
      _main in Root_Architecture-Root_Architecture.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[3]: *** [Root_Architecture] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
--- Failed to build Root-Architecture ---
Terminating dunecontrol due to previous errors!

I do not really understand, what's happening here. I suppose that the
libraries are not recognized correctly. If I run the example outside the
dune environment it works without problems. The libraries are some .dylib
files in the folder /Users/ericgleiss/VTK-build/lib, which I include in my
opts-file.
Does anyone have a clue what is going on here?
How can I correctly link the libraries to the dune build system?
Thank you beforehand.

Best regards,
Eric
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: terminal-output.txt
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20141112/2b97796d/attachment.txt>


More information about the Dune mailing list