[vtkusers] Re: Linker problems

Paul Tait - OPES Paul at opes.com.au
Tue Jan 10 02:37:46 EST 2006


Its VC6 centric but this works for me

Include it in a .cpp file and adjust paths to taste

#ifdef _DEBUG
#pragma comment(lib, "C:/vtk/vtkbin/bin/Debug/vtkCommon.lib")
#pragma comment(lib, "C:/vtk/vtkbin/bin/Debug/vtkFiltering.lib")
#pragma comment(lib, "C:/vtk/vtkbin/bin/Debug/vtkGraphics.lib")
#pragma comment(lib, "C:/vtk/vtkbin/bin/Debug/vtkImaging.lib")
#pragma comment(lib, "C:/vtk/vtkbin/bin/Debug/vtkIO.lib")
#pragma comment(lib, "C:/vtk/vtkbin/bin/Debug/vtkRendering.lib")
#pragma comment(lib, "C:/vtk/vtkbin/bin/Debug/vtkFreeType.lib")
#pragma comment(lib, "C:/vtk/vtkbin/bin/Debug/vtkftgl.lib")
#pragma comment(lib, "C:/vtk/vtkbin/bin/Debug/vtkHybrid.lib")
#else
#pragma comment(lib, "C:/vtk/vtkbin/bin/RelWithDebInfo/vtkCommon.lib")
#pragma comment(lib, "C:/vtk/vtkbin/bin/RelWithDebInfo/vtkFiltering.lib")
#pragma comment(lib, "C:/vtk/vtkbin/bin/RelWithDebInfo/vtkGraphics.lib")
#pragma comment(lib, "C:/vtk/vtkbin/bin/RelWithDebInfo/vtkImaging.lib")
#pragma comment(lib, "C:/vtk/vtkbin/bin/RelWithDebInfo/vtkIO.lib")
#pragma comment(lib, "C:/vtk/vtkbin/bin/RelWithDebInfo/vtkRendering.lib")
#pragma comment(lib, "C:/vtk/vtkbin/bin/RelWithDebInfo/vtkFreeType.lib")
#pragma comment(lib, "C:/vtk/vtkbin/bin/RelWithDebInfo/vtkftgl.lib")
#pragma comment(lib, "C:/vtk/vtkbin/bin/RelWithDebInfo/vtkHybrid.lib")
#endif

-----Original Message-----
From: vtkusers-bounces+paul=opes.com.au at vtk.org
[mailto:vtkusers-bounces+paul=opes.com.au at vtk.org] On Behalf Of Goodwin
Lawlor
Sent: Tuesday, 10 January 2006 2:44 AM
To: vtkusers at public.kitware.com
Subject: [vtkusers] Re: Linker problems


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
> 

_______________________________________________
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

-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.15/223 - Release Date: 6/01/2006
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.16/225 - Release Date: 9/01/2006
 




More information about the vtkusers mailing list