[vtkusers] Compiling sphere program on Cygwin

Ryan Mitchley ryan at peralex.com
Tue Sep 25 06:53:10 EDT 2001


Hi

I have just managed to compile VTK on Cygwin after checking it out using
CVS. It seemed to build OK after running configure --with-opengl, and then
editing user.make to define the compilation flags as follows:

USER_CFLAGS = -mno-cygwin -nostdinc -I/usr/local/mingw/include \
  -I/usr/local/mingw/include/g++-3 \
  -I/usr/local/mingw/lib/gcc-lib/mingw32/2.95.3-5/include
USER_CXXFLAGS
= -mno-cygwin -nostdinc -fpermissive -I/usr/local/mingw/include \
  -I/usr/local/mingw/include/g++-3 \
  -I/usr/local/mingw/lib/gcc-lib/mingw32/2.95.3-5/include \
  -L/usr/local/mingw/lib/gcc-lib/mingw32/2.95.3-5 -lstdc++

My next step was to try and build an example program. I took the sphere
example code off the kitware website and changed the include to:

#include "vtkWin32OpenGLRenderWindow.h"
#include "vtkSphereSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"

I had to fiddle with the makefile to get rid of numerous compilation
problems. The relevant parts of the makefile are currently as follows:

# Makefile for VTK test program
CC = g++
MY_HOME = /home/ryan
INC = -I$(MY_HOME)/VTKtest -I/usr/include/mingw \
  -I/usr/local/mingw/include/g++-3 \
  -I/usr/include/mingw/sys \
  -I$(MY_HOME)/vtk/graphics -I$(MY_HOME)/vtk/common \
  -I$(MY_HOME)/vtk/imaging
OBJ = sphere.o
WIN_LIB = -L/usr/local/mingw/lib/gcc-lib/mingw32/2.95.3-5 -lstdc++ \
  -L$(MY_HOME)/vtk/graphics -lVTKGraphics \
  -L$(MY_HOME)/vtk/common -lVTKCommon \
  -L/lib/w32api -lglui -lglut32 -lglu32 -lopengl32 -lgdi32
CC_OPTS = -fpermissive -mno-cygwin -nostdinc

# Main program
sphere.exe: $(OBJ)
 $(CC) -Wall $(CC_OPTS) $(OBJ) -o sphere.exe $(WIN_LIB)

# Implicit rules
%.o: %.cpp
 $(CC) -Wall $(CC_OPTS) $(INC) $< -c -o $@

My problem is that when linking, I get several undefine references:

sphere.o(.text+0x3617):sphere.cpp: undefined reference to `import stub for
vtkRenderWindow::New(void)'
sphere.o(.text+0x3629):sphere.cpp: undefined reference to `import stub for
vtkRenderer::New(void)'
etc.

Each error message is for the New methods of the various classes used. Any
idea what is happening?

Thanks for any replies!

Ryan




More information about the vtkusers mailing list