C/C++ Libraries for Windows

From MRC Centre for Outbreak Analysis and Modelling
Revision as of 15:04, 23 January 2017 by Admin (talk | contribs) (Created page with "Work in progress. Not all C/C++ library-writers are particularly helpful when in comes to producing versions that work pleasant across different platforms and compilers. But...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Work in progress.

Not all C/C++ library-writers are particularly helpful when in comes to producing versions that work pleasant across different platforms and compilers. But often it's not as difficult or impossible as it's made out to be - in fact, sometimes it's really very easy. On this page, I'm gathering some libraries that I've rebuilt for Visual Studio, which hopefully will make life easier.

GSL

Vs gsl1.jpg
Vs gsl2.jpg
Vs gsl3.jpg

I used the instructions provided by Brian Gladman here, to build binaries of GSL 1.16, for Visual Studio 2013 and 2015. To use them in Visual Studio, do the following steps. I'm assuming you vaguely know what you're doing in Visual Studio.

  • Download the GSL binaries for VS2013 or VS2015.
  • Unzip them somewhere - purely for example in these steps, I'll assume you unzipped them into C:\VSGSL.
  • Open your Visual Studio project. On the drop-downs at the top, note whether you're in Release or Debug mode, and whether you're compiling for x64 or Win32. The final step is different depending on these selections, and you may want to repeat the following steps for each combination you're going to use.
  • From the Project, go to the "Project" Preferences at the bottom - where "Project" is whatever your Project is called.
  • Choose C/C++, General, and look at the Additional Include Directories field. It's semi-colon separated. Insert (for example) C:\VSGSL\include; at the start.
  • Choose Linker, Input, and insert gsl.lib;cblas.lib; into the semi-colon separated list of libraries.
  • Choose Linker, General, and look for Additional Library Directories. Now, depending on your configuration, insert one of the following:-
    • Release-mode, 64-bit (x64). Insert C:\VSGSL\lib\x64_release;
    • Debug-mode, 64-bit (x64). Insert C:\VSGSL\lib\x64_debug;
    • Release-mode, Win32 (a.k.a x86). Insert C:\VSGSL\lib\x86_release;
    • Debug-mode, Win32. Insert C:\VSGSL\lib\x86_debug;
  • Done. Build your code. I suggest also in C/C++, Code Generation, set Runtime Library to either Multi-threaded if you're in the release configuration, or Multi-threaded Debug if you're in the debug configuration - that is, remove the dependency on DLLs. That will make things easier all round.