2
votes

I am using visual studio 2008 in my MFC + vtk project. There I am getting a linking error as below:

vtkPBFEAView.obj : warning LNK4217: locally defined symbol ?DrawDC@vtkMFCWindow@@QAEXPAVCDC@@@Z (public: void __thiscall vtkMFCWindow::DrawDC(class CDC *)) imported in function "protected: virtual void __thiscall CvtkPBFEAView::OnDraw(class CDC *)" (?OnDraw@CvtkPBFEAView@@MAEXPAVCDC@@@Z)

1>vtkMDIView.obj : warning LNK4049: locally defined symbol ?DrawDC@vtkMFCWindow@@QAEXPAVCDC@@@Z (public: void __thiscall vtkMFCWindow::DrawDC(class CDC *)) imported 1>vtkPBFEAView.obj : warning LNK4217: locally defined symbol ??0vtkMFCWindow@@QAE@PAVCWnd@@@Z (public: __thiscall vtkMFCWindow::vtkMFCWindow(class CWnd *)) imported in function "public: void __thiscall vtkPBFEAViewImpl::initialize(class CWnd *)" (?initialize@vtkPBFEAViewImpl@@QAEXPAVCWnd@@@Z)

1>vtkMDIView.obj : warning LNK4049: locally defined symbol ??0vtkMFCWindow@@QAE@PAVCWnd@@@Z (public: __thiscall vtkMFCWindow::vtkMFCWindow(class CWnd *)) imported 1>vtkPBFEAView.obj : warning LNK4217: locally defined symbol ??1vtkMFCWindow@@UAE@XZ (public: virtual __thiscall vtkMFCWindow::~vtkMFCWindow(void)) imported in function "public: virtual void * __thiscall vtkMFCWindow::`scalar deleting destructor'(unsigned int)" (??_GvtkMFCWindow@@UAEPAXI@Z)

1>vtkMDIView.obj : warning LNK4217: locally defined symbol ??1vtkMFCWindow@@UAE@XZ (public: virtual __thiscall vtkMFCWindow::~vtkMFCWindow(void)) imported in function "public: void __thiscall vtkMDIViewImpl::adjust_contours(int,double,double)" (?adjust_contours@vtkMDIViewImpl@@QAEXHNN@Z)

1>vtkMFCWindow.obj : error LNK2019: unresolved external symbol "_declspec(dllimport) const vtkMFCWindow::`vftable'" (_imp_??_7vtkMFCWindow@@6B@) referenced in function "public: __thiscall vtkMFCWindow::vtkMFCWindow(class CWnd *)" (??0vtkMFCWindow@@QAE@PAVCWnd@@@Z)

Can anyone explain me the reason for this error?

Thanks in advance.

2
There's a similar question asked here, see if it helps you.sashoalm
Thanks for the link @satuon. I am building vtk with dll files now but it has udes static libs earlier. May be this is the problem, so I am trying to build vtk with static libs, which I found dificult to build earlier. Do you have any suggestions? Thanks again.gishara
In the link I gave the solution was to build with shared libraries instead of static libs (they turn on BUILD_SHARED_LIBS). Did you do that?sashoalm
Yes.I am using SHARED_LIBS option and I am linking all the libraries.gishara
So, are you building with shared libraries now, or with static libraries? I'm asking because you said earlier "so I am trying to build vtk with static libs".sashoalm

2 Answers

1
votes

Finally I found the answer for the problem. It was that vtkMFCWindow was configured with /MD option and my main project was configured with /MTd option. And therefore I got the error. Once I removed the __declspec( dllexport ) lines and it worked well. Thanks for the help.

0
votes

For anyone else that might find this solution and be upset that their DLL Function is no longer exported to be used by the client app:

MSVC's DLL template provides the following bit of boilerplate:

#ifdef DLLNAME_EXPORTS
  #define DLLNAME_API __declspec(dllexport)
#else
  #define DLLNAME_API __declspec(dllimport)
#endif

If you forget to define the DLLNAME_EXPORTS in the project settings, you'll get this message. This can happen if you rename these #defines