[vtkusers] Re: Linker problems

Goodwin Lawlor goodwin.lawlor at ucd.ie
Mon Jan 9 13:43:38 EST 2006


Hi Rhys,

There's 3 things to check

1. That the vtkIO.lib has been added to the linker input box.
2. That the folder where vtkIO.lib resides is listed as a linker directory
3. That vtkIO.lib has been built correctly and exports the 
vtkStructuredPointsReader object.

Why not use cmake to correctly set up your VC++ project for you? Create 
a file CMakeLists.txt (in the same folder as you source file) with this 
text:

PROJECT (test_project)

FIND_PACKAGE(VTK REQUIRED)
IF(NOT VTK_USE_RENDERING)
   MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires 
VTK_USE_RENDERING.")
ENDIF(NOT VTK_USE_RENDERING)
INCLUDE(${VTK_USE_FILE})

ADD_EXECUTABLE(test_project test_project.cxx)
TARGET_LINK_LIBRARIES(test_project vtkRendering vtkIO)

and now run cmake

hth

Goodwin



Rhys Thomas wrote:
> Hello one and all, I would very much appreciate it if somebody could 
> help me with the following problem. When I attempt to build the 
> following program in Microsoft Visual Studio 6 I get back error messages 
> from the linker complaining of an unresolved external symbol, however I 
> believe that I have set the linker to link to all of the necessary code.
> 
> My code is thus:
> 
> #include "vtkActor.h"
> #include "vtkRenderer.h"
> #include "vtkRenderWindow.h"
> #include "vtkStructuredPoints.h"
> #include "vtkStructuredPointsReader.h"
> 
> int main(int argc, char**argv)
> {
>    vtkStructuredPointsReader *reader = vtkStructuredPointsReader::New();
>    reader->SetFileName("c:/abdomen.vtk");
>    reader->Delete();
>    return 0;
> }
> 
> and produces the following output when a build attempt is made:
> 
> --------------------Configuration: RenderData - Win32 
> Debug--------------------
> Linking...
> RenderData.obj : error LNK2001: unresolved external symbol "public: 
> static class vtkStructuredPointsReader * __cdecl 
> vtkStructuredPointsReader::New(void)" 
> (?New at vtkStructuredPointsReader@@SAPAV1 at XZ)
> Debug/RenderData.exe : fatal error LNK1120: 1 unresolved externals
> Error executing link.exe.
> 
> RenderData.exe - 2 error(s), 0 warning(s)
> 
> Thanks for your time
> 
> Rhys Thomas
> _______________________________________________
> This is the private VTK discussion list. Please keep messages on-topic. 
> Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 




More information about the vtkusers mailing list