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.

  1. Launch WinDigitalCell.sln. (We'll build the new project there first, where it's easy to copy settings from existing projects.)
  2. File -> New -> Project...
  3. Delete folders for Source Files, Header Files, and Resources under Solution Explorer
  4. Save all, exit
  5. 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.)
  6. 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.
  7. 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.
  8. 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.)
  9. 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.
  10. 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:
    1. 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
    2. C/C++, Code Generation -> Runtime Library,
      • Release: Multi-Threaded DLL (/MD)
      • Debug: Multi-Threaded Debug DLL (/MDd)
    3. C/C++, Language -> Enable Run-Time Type Info,
      • All Configurations: Yes (/GR)
    4. 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
    5. Linker, Input, Additional Dependencies
      • All Configurations:
      • mkl_c.lib mkl_p4.lib mkl_lapack.lib DigitalCellLibrary.lib
    6. I did not have to ignore msvcrt or whatever.
    7. Note that if your machine has MKL 6.1 installed replace MKL above with MKL61 and omit mkl_p4.lib from step 5
  11. Save all, exit
  12. Start up MinimalCell.vcproj, right click on Solution 'MinimalCell' in the Solution Explorer, then Add->Existing Project. Select .../SerialNetworkCode/DigitalCellLibrary/DigitalCellLibrary.vcproj
  13. Right click on Solution 'MinimalCell' again, then Project Dependencies. Set MinimalCell to depend on DigitalCellLibrary
  14. 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).