Llinking ITK (Insight Toolkit) to C++ VS2008 solut

2019-01-25 00:47发布

问题:

Question

Is there an easy, straight forward way of including the ITK libraries into my project (VS2008 solution) without using CMake?

Background

I have just started looking into ITK this week. So far I successfully compiled ITK & VTK and got the WikiExamples to compile (and run) as well. My next goal is to include any ITK functionality into my own project. I have no experiences with CMake except the use of it during the documented installation process.

My own project codebase is in itself a rather complicated, SDK environment in rather large, complex VS2008 solution to which I only want to add a bit of ITK functionality. As I have built ITK already, can I simply set includes to the .h files and add the lib directories to the linker?

Is there a good way to do this, as the .h files are spread over the whole ITK code tree?

I've realized that this question is similar, but the given answer was too cryptic for me, sorry.

Edit: After a 2nd and 3rd read, it actually wasn't. It led to my answer below.

回答1:

When configuring ITK with CMake (or cmake-gui) one can set the variable CMAKE_INSTALL_PREFIX to a destination for all output. The default value is C:/Programm Files (x84)/itk

After Configure and Generate have been performed successfully, the solution file (ITK.sln) has been created in the given "Where to build the binaries" directory and can be opened in Visual Studi0 2008. The solution has the default project ALL_BUILD which builds the solution, but it also has a INSTALL project which is skipped by default.

Building this solution (after ALL_BUILD) copies all required lib, .h, .dll etc. files into the path specified before.

This folder structure is the place to link my own project up to.

Linking in your own project

In your own project of VS Studio (I'm on VS 2008) you have to modify your project properties to include the include files:

And you have to modify your project properties to include the library files for linking: