[vtkusers] installing VTK on Linux - Help!

M. Thompson mthompsn at science.uva.nl
Sat Sep 22 10:23:51 EDT 2001


Hi everyone,

I've just about finished installing vtk3.2 on my debian 2.2 Linux system;
configuring, building etc. all worked fine. I can now even run some of the
example tcl-scripts in vtk3.2/Graphics/examplesTcl .

However, when I try to make a simple C++ program (see attatchment) using
some vtk-classes, I get an error.

This is the command I use to compile simple.cxx (no errors):

$ gcc -O2 -w  -I/usr/share/vtk3.2/common -I/usr/share/vtk3.2/contrib
-I/usr/share/vtk3.2/graphics -I/usr/share/vtk3.2/imaging
-I/usr/share/vtk3.2/patented  -c simple.cxx -o simple.o

This is the command I use to link (results in error):

$ gcc simple.o -L/usr/lib/vtk -lVTKPatented -lVTKImaging -lVTKGraphics
-lVTKCommon -lVTKContrib -lpthread -lGL -L/usr/X11R6/lib -lX11 -lXt -lXext
-o simple
/usr/lib/vtk/libVTKCommon.so: undefined reference to `dlerror'
/usr/lib/vtk/libVTKCommon.so: undefined reference to `dlclose'
/usr/lib/vtk/libVTKCommon.so: undefined reference to `dlopen'
/usr/lib/vtk/libVTKCommon.so: undefined reference to `dlsym'
collect2: ld returned 1 exit status


I've found out that the functions dlerror, dlclose etc. have something to
do with an include file dlfcn.h (/usr/include/dlfcn.h) . But I don't know
how to go further from here.

Does anyone know what's going wrong?

Thanx,
	Mark Thompson
-------------- next part --------------
.SUFFIXES: .cxx

# A Makefile to compile and link Vtk C++ programs.
#
# CAUTION: Use "gmake" instead of "make" to build your programs!!
# If "gmake" is not in your current path; it's in /usr/local/gnu/bin
#
# $Id$

# Specify the name of the program you want created on this line:
TARGET = simple

# Specify the objects that make up your program in this line:
OBJECTS = simple.o



###########################################################
# You should not have to change anything below this line. #
###########################################################

${TARGET}: ${OBJECTS}

# Compiler and linker definitions for the different libraries we need:

# The Visualization Toolkit (Vtk):
#
VTK_HOME      = /usr/share/vtk3.2
VTK_INC       = -I${VTK_HOME}/common   \
                -I${VTK_HOME}/contrib  \
                -I${VTK_HOME}/graphics \
                -I${VTK_HOME}/imaging  \
                -I${VTK_HOME}/patented
VTK_LIB       = -L/usr/lib/vtk
VTK_LIBS      = ${VTK_LIB} -lVTKPatented -lVTKImaging \
                -lVTKGraphics -lVTKCommon -lVTKContrib \
                -lpthread

# OpenGL:
#
OGL_LIBS      = -lGL

# X Windows:
#
X11_LIB       = -L/usr/X11R6/lib
X11_LIBS      = ${X11_LIB} -lX11 -lXt -lXext


# Compiler and linker flags:

CXX           = gcc
DEFINES       =
INCLUDES      = ${VTK_INC} 
LDFLAGS       = ${VTK_LIBS} ${OGL_LIBS} ${X11_LIBS}
#CXX_FLAGS     = -O2 -Wall ${DEFINES} ${INCLUDES}
CXX_FLAGS     = -O2 -w ${DEFINES} ${INCLUDES}

# Automatic generator rules:

.cxx.o:
	${CXX} ${CXX_FLAGS} -c $< -o $@

.o:
	$(CXX) $^ ${LDFLAGS} -o $*

# Other targets:

clean:
	$(RM) ${OBJECTS}
-------------- next part --------------
// A simple C++ program that visualizes a cone using Vtk.

// Compile and link this program by typing "make".
// Run this program by typing "./simple".

#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkConeSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"

int main(void)
{

  // Create the renderwindow, renderer and interactor
  vtkRenderer *ren1 = vtkRenderer::New();
  vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin->AddRenderer(ren1);
  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
    iren->SetRenderWindow(renWin);

  // Create a polygonal cone
  vtkConeSource *cone = vtkConeSource::New();
    cone->SetRadius(1.0);
    cone->SetHeight(1.0);
    cone->SetAngle(30.0);
    cone->SetResolution(15);

  // Map the polygons to graphics data
  vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
    coneMapper->SetInput(cone->GetOutput());

  // Create an actor for this graphics object
  vtkActor *coneActor = vtkActor::New();
    coneActor->SetMapper(coneMapper);
    coneActor->GetProperty()->SetColor(0.8, 0.2, 0.2);

  // Add the actor to the renderer
  ren1->AddActor(coneActor);

  // Set the background colour to gray
  ren1->SetBackground(0.5, 0.5, 0.5);

  // Render the image
  renWin->Render();

  //  Begin mouse interaction
  iren->Start();

  // Code at this line and below is never reached

}


More information about the vtkusers mailing list