[vtkusers] Help with VTK on Xcode
Paulo Alexandre Neves
pneves at ipcb.pt
Tue Jul 19 11:59:26 EDT 2011
Hello all.
My name is Paulo Neves, I am a PhD student at University of Beira Interior.
I am trying to use VTK with Xcode 4 on Mac OS X 10.6.8. For the moment I only want to access the features it provides, not for extension.
I installed VTK 5.6.1 through Macports. As expected, I get a bunch of include files and dylib files.
I create a new project in Xcode (command line, C++) to run a simple
example code:
#include "vtkSphereSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkActor.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkRenderWindowInteractor.h"
int main ()
{
// create sphere geometry
vtkSphereSource *sphere = vtkSphereSource::New();
sphere->SetRadius(1.0);
sphere->SetThetaResolution(18);
sphere->SetPhiResolution(18);
// map to graphics library
vtkPolyDataMapper *map = vtkPolyDataMapper::New();
map->SetInput(sphere->GetOutput());
// actor coordinates geometry, properties, transformation
vtkActor *aSphere = vtkActor::New();
aSphere->SetMapper(map);
aSphere->GetProperty()->SetColor(0,0,1); // sphere color blue
// a renderer and render window
vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren1);
// an interactor
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
// add the actor to the scene
ren1->AddActor(aSphere);
ren1->SetBackground(1,1,1); // Background color white
// render an image (lights and cameras are created automatically)
renWin->Render();
// begin mouse interaction
iren->Start();
// release memory and return
sphere->Delete();
map->Delete();
aSphere->Delete();
ren1->Delete();
renWin->Delete();
iren->Delete();
return EXIT_SUCCESS;
}
The project compiles fine, but gives linking errors. This is the first
time I am using dylibs on Xcode, previously only used static ones.
My question is how can I make Xcode recognize the code inside the
libraries, namely the code referenced by the header files of the example?
I tried copying the /opt/local/lib/vtk-5.6 directory where all dylibs are
to the project, add -L/opt/local/lib/vtk5.6 to other linker flags, to no
avail.
I get the following errors:
"
Undefined symbols for architecture x86_64:
"vtkSphereSource::New()", referenced from:
_main in main.o
"vtkPolyDataMapper::New()", referenced from:
_main in main.o
"vtkPolyDataAlgorithm::GetOutput()", referenced from:
_main in main.o
"vtkPolyDataMapper::SetInput(vtkPolyData*)", referenced from:
_main in main.o
"vtkActor::New()", referenced from:
_main in main.o
"vtkActor::GetProperty()", referenced from:
_main in main.o
"vtkProperty::SetColor(double, double, double)", referenced from:
_main in main.o
"vtkRenderer::New()", referenced from:
_main in main.o
"vtkRenderWindow::New()", referenced from:
_main in main.o
"vtkRenderWindowInteractor::New()", referenced from:
_main in main.o
"vtkRenderWindowInteractor::SetRenderWindow(vtkRenderWindow*)",
referenced from:
_main in main.o
"vtkRenderer::AddActor(vtkProp*)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
"
Sorry for the long post, but I am searching for a solution in the web for
3 days now... It's driving me mad :(. Any help will be much appreciated.
Kind regards.
___________________________________________________________________
Paulo Alexandre Neves
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110719/d6ebc95d/attachment.htm>
More information about the vtkusers
mailing list