Starting New Visual Studio Projects using MKL
Here are the steps for how I start a new project under Windows,
for Kevin Brown's network code. Most of the subtle parts involve
Intel's MKL libraries, so this may be of more general interest.
My recommendation is to have each project
linked to both in the main "WinDigitalCell" solution and in it's own
solution folder. That way someone who is altering a shared library class can
compile all the different projects. (The same ".vcproj" file will be
linked to in both solutions, so changes in settings and such don't have to be
done twice.)
I'm typing the steps I'm using to try to compile the Minimal Cell model.
- Launch WinDigitalCell.sln. (We'll build the new project there first,
where it's easy to copy settings from existing projects.)
- File -> New -> Project...
- Visual C++ Projects -> Win 32 Project
- Name: MinimalCell
- Location: ...SerialNetworkCode\
- Add to Solution
- OK
- Application Settings -> Console Application, Empty Project
- Finish
- Delete folders for Source Files, Header Files, and Resources under Solution Explorer
- Save all, exit
- Make a directory "MinimalCell\WinBuild" and move
MinimalCell/MinimalCell.vcproj into WinBuild. (It's neater to keep the
windows-specific stuff in a subdirectory, and I don't know how to trick
the Visual Studio wizard into putting it there directly.)
- If you are using MKL 5.2 or earlier, there is a dll file which needs to be linked to at runtime for calling LAPACK routines since they are in FORTRAN. Newer versions of MKL have a alternative, more transparent, fix for this issue but for 5.2 or earlier the computer needs to know at runtime where to find mkl_support.dll. There are two ways to accomplish this: either copy mkl_support.dll from the MKL installation to WinBuild or add to your PATH environment variable the path to where the file resides. In at least some versions of Windows the way to do this is right click on My Computer -> Properties -> Advanced -> Environment Variables -> User Variables -> New... : %PATH%;C:\directory_where_mkl_support.dll_is.
- Start up WinDigitalCell.sln again, delete MinimalCell (which can't be found
because we moved it), and then File->Open->Project, browse for
MinimalCell.vcproj, Add to Solution, Open.
- Right click on MinimalCell project in Solution Explorer. Add New Folder
named MinimalCell. (This seems dumb: maybe we should do the Source/Header
default, and just erase "Resources" in step (3). On the other hand,
I'm always switching between the .h and .cpp files, so keeping them in
different folders seems inconvenient.)
- Right click on MinimalCell folder, Add Existing Item, browse to directory
with source code (here MinimalCell/src, for some reason). Select all the source.
Repeat as necessary. (I added a MinimalCellInterface directory, with main.cpp
copied from TranslationDynamics.) If this is a new project, obviously
skip adding files and create new ones after changing the settings below.
- Right click on MinimalCell project, and select Properties. Change
them, both for Debug and Release, to agree with those of TranslationDynamics.
(This is facilitated by the fact that clicking on the TranslationDynamics
project in the Solution Explorer while the Property Pages box is open
switches you to the corresponding page for TranslationDynamics. Say "yes"
to saving changes). The properties I changed were:
- C/C++, General->Additional Include Directories. Cut and paste: added
../src
- All Configurations:
- C:\Program Files\Intel\MKL\include;
- ../../Infrastructure;
- ../../Infrastructure/GnuPlotter;
- ../../Infrastructure/Minimizer;
- ../../Infrastructure/Mover;
- ../../Reactions;
- ../src
- C/C++, Code Generation -> Runtime Library,
- Release: Multi-Threaded DLL (/MD)
- Debug: Multi-Threaded Debug DLL (/MDd)
- C/C++, Language -> Enable Run-Time Type Info,
- All Configurations: Yes (/GR)
- Linker, General, Additional Library Directories
- Release:
- C:\Program Files\Intel\MKL\ia32\lib;
- ..\..\DigitalCellLibrary\Release
- Debug:
- C:\Program Files\Intel\MKL\ia32\lib;
- ..\..\DigitalCellLibrary\Debug
- Linker, Input, Additional Dependencies
- All Configurations:
- mkl_c.lib mkl_p4.lib mkl_lapack.lib DigitalCellLibrary.lib
- I did not have to ignore msvcrt or whatever.
- Note that if your machine has MKL 6.1 installed replace MKL above with MKL61 and omit mkl_p4.lib from step 5
- Save all, exit
- Start up MinimalCell.vcproj, right click on Solution 'MinimalCell' in the Solution Explorer, then Add->Existing Project. Select .../SerialNetworkCode/DigitalCellLibrary/DigitalCellLibrary.vcproj
- Right click on Solution 'MinimalCell' again, then Project Dependencies. Set MinimalCell to depend on DigitalCellLibrary
- Start debugging, and changing main.cpp to turn it into the Minimal Cell
project.
Last Modified: October 31, 2003
by Josh Waterfall
James P. Sethna
Statistical Mechanics: Entropy, Order Parameters, and Complexity,
now available at
Oxford University Press
(USA,
Europe).