1
votes

I have been stuck with a MFC-related problem for quite some time now. I have read through many forums, VTK-Users posts, etc. without any luck.

My basic problem is that vtkMFC.lib is not getting built; no matter how I build my project or configure it.

These are the steps I have followed:

  1. Generate VTK.sln using CMake 2.8.9 with VTK_USE_GUISUPPORT, BUILD_SHARED_LIBS, VTK_USE_MFC, BUILD_EXAMPLES turned ON and VTK_USE_VIDEO_FOR_WINDOWS turned OFF.
  2. Open VTK.sln on VS-2008 and build ONLY vtkMFC.sln.
  3. Build entire solution. {I have also tried with points 2 and 3 inter-changed with no result}
  4. There are 6 erros; of which 3 are to do with the fact that vtkMFC.lib isn't there (for the examples. obviously). The rest are regarding a couple of resolved external symbols,

error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class vtkDataSetReader * _cdecl vtkDataSetReader::New(void)" (_imp_?New@vtkDataSetReader@@SAPAV1@XZ) referenced in function "protected: __thiscall CSampleDoc::CSampleDoc(void)" (??0CSampleDoc@@IAE@XZ) in SampleDoc.obj

error LNK2019: unresolved external symbol "__declspec(dllimport) public: class vtkDataSet * _thiscall vtkDataSetReader::GetOutput(void)" (_imp_?GetOutput@vtkDataSetReader@@QAEPAVvtkDataSet@@XZ) referenced in function "public: virtual int __thiscall CSampleDoc::OnOpenDocument(char const *)" (?OnOpenDocument@CSampleDoc@@UAEHPBD@Z) in SampleDoc.obj

The files generated in Debug/bin for vtkMFC solution are vtkMFC.dll, vtkMFC.idb, vtkMFC.ilk, vtkMFC.pdb.

I have also added vtkIO.lib to the projects that generated the error and the same erros continue along with another which says that vtkIO.lib isn't found.

Any help in this regard would be much appreciated.

Best, Sarthak

1
Turns out, there is some issue with vtk 5.10.1 build. Using 5.8.0 solved the problem.scap3y
Certain things to be kept in mind while building VTK: If BUILD_SHARED_LIBS is selected (you want DLLs to be generated), then make sure all flags are set to /MD. If BUILD_SHARED_LIBS is UNselected (you don't want DLLs to be generated and are linking via static libs), then make sure all flags are set to /MT.scap3y
scap3y Can you please create an answer and accept it so that the question does not show up as unanswered?David Doria
@DavidDoria - Sure thing.scap3y

1 Answers

0
votes

Answer as of February 2013:

Turns out, there is some issue with VTK 5.10.1. Using 5.8.0 solved the problem.

Certain things to be kept in mind while building VTK from CMake:

If BUILD_SHARED_LIBS is selected (i.e., you want DLLs to be generated), then make sure all flags are set to /MD. If BUILD_SHARED_LIBS is unselected (i.e., you don't want DLLs to be generated and are linking via static libs), then make sure all flags are set to /MT.