Compiling GSL (Gnu Scientific Library) natively with Visual Studio 2013 Express
- Install GSL
- Download GSL 1.16 and unpack it.
- Download VS sln files from Brian Gladmann's page
GSL for Windows. Unpack it into the same directory as GSL. It will add a new directory (
build.vc11) and replace a couple files. - If compiling for 64-bit Intel, you might need to change
build.vc11/fp-win.cbecause 64-bit Intel does not allow setting the precision of floating point (see Boost Ticket #4964). On line 40, replace
withmask |= _MCW_PC;#ifndef _WIN64 mask |= _MCW_PC; #endif - Read
build.vc11/gsl.vc11.readme.txtfile. It contains detailed instructions. Basically there will be 4 solution files inbuild.vc11directory:
Building any of these is similar so I will go through the steps for buildinggsl.dll.sln gsl.lib.sln test.gsl.dll.sln test.gsl.lib.slngsl.lib.sln. - Double click
gsl.lib.slnto bring up MSVS. Select the solution and change the Solution Platform from Win32 to x64. Then for each project, change the Platform toolset to v120 (in Configuration Properties-->General). - Since I choose to use
gslhdrs, I add the project as a dependency of thecblaslibproject. And in Configuration Manager, I uncheck thegsldefsproject so it won't get built. - Select "Build Solution" and it should build hopefully with no errors.
- The default code generation flag is Multi-threaded static runtime (ie,
/MTd,/MT). If you switch to a Multi-threaded DLL runtime build (ie,/MDd,/MD), you might encounter errors similar to this:error C2375: 'gsl_acosh' : redefinition; different linkagein the filemath.hThis is because thebuild.vc11/config.h(which is normally generated byconfigureon Unix-type systems) tells the compiler it (ie, the compiler itself) doesn't have an implementation ofacoshwhen it actually does and therefore does not need a GSL implementation. To fix this, go intobuild.vc11/config.hand change
to/* Define to 1 if you have the declaration of `acosh', and to 0 if you don't. */ #undef HAVE_DECL_ACOSH
And repeat for similar problems referring to/* Define to 1 if you have the declaration of `acosh', and to 0 if you don't. */ #define HAVE_DECL_ACOSH 1math.h. Then rebuild the Solution. - I recommend building
test.gsl.lib.slnas well. After building, choose any of the projects to run.
- Using GSL
- If you plan to use the DLL version of GSL in your application, you must pass
-DGSL_DLLto the compiler (in Configuration Properties-->C/C++-->Preprocessor-->Preprocessor Definitions) when building your application.
- If you plan to use the DLL version of GSL in your application, you must pass