GSL 1.15 and 1.16 building with Visual Studio 2010

Update 05/02/2014: A good book for GSL (updated with 1.16 version) is GNU Scientific Library Reference Manual – Third Edition.

Update 14-11-2013: Building GSL 1.16 with Visual Studio 2010 (VC++ 10): In July, GSL 1.16 was released, the source code files can be obtained from this. If one wants to build it with Visual Studio 2012 (VC++ 11), the VS solution file can be downloaded from this URL and the same steps (from 1 to 6) as doing with GSL 1.15 and VS 2010 are needed. Based on VC++ 11 solution files, I have created solution for some one who still works with Visual Studio 2010 (VC++ 10), and that file can be downloaded from this address.

Today I build GSL 1.15 for using with Visual Studio 2010. After downloading GSL 1.15 source code, I download VS 2010 solution files and start building GSL’s .dll and .lib for my own. And these are the steps:
1. Exatracting file gsl-1.15-vc10.zip into a folder (GSL_build for example). You should have the folder GSL_build\gsl-1.15-vc10 after this step.
2. Exatracting file gsl-1.15.tar.gz into folder GSL_build\gsl-1.15.
3. Copy all gsl_*.h files from GSL_build\gsl-1.15 folder to GSL_build\gsl-1.15-vc10\gsl folder (you should do a search here and make a copy on the found files).
4. Copy all files from folder GSL_build\gsl-1.15 to GSL_build\gsl-1.15-vc10 folder, do not overwrite the two file templates_on.h and env.c or you will encounter errors with Release build.
5. Open file GSL_build\gsl-1.15-vc10\build.vc10\gsl.lib.sln with VS 2010 and start Debug and Release build.
6. Open file GSL_build\gsl-1.15-vc10\build.vc10\gsl.dll.sln with VS 2010 and start Debug and Release build. You may need to copy cblas.lib file from folder build.vc10\lib\Win32 to folder build.vc10\dll\Win32 (Debug or Release sub folder) to make this step runs.
7. If you encounter errors (like me), then these are the fixings:
+ file bspline.c: moving variables declarations to the first part of the function: gsl_bspline_greville_abscissa(size_t i, gsl_bspline_workspace *w)
+ file rk4imp.c: replacing sqrt(3) with M_SQRT3.
It’s done now. You should have your .dll in gsl_build\gsl-1.15-vc10\build.vc10\dll and .lib in the folder gsl_build\gsl-1.15-vc10\build.vc10\lib.
8. Notes:
+ When copying these above files and folders, do not over write any files.
+ You can build GSL with other blas library like Goto Blas, Atlas. Just replacing the cblas.lib with the suitable .lib file in building gsl.dll.
+ For using GSL, you need both .lib file in the gsl_build\gsl-1.15-vc10\build.vc10\lib folder and .dll file in the gsl_build\gsl-1.15-vc10\build.vc10\dll folder. Do not use .lib files from gsl_build\gsl-1.15-vc10\build.vc10\dll folder.
+ You can use examples from Physics 780.20 Computational Physics course for testing your .dll and .lib files.
+ Another source you can use is located at: Data Analysis with Open source Tools. This is a good book with good examples.

+ Even though I did not test the above process of building GSL with other Visual Studio versions (VS Express, VS 2008, VS 2012) but I strongly believe that the same details can be applied.

24 Responses to “GSL 1.15 and 1.16 building with Visual Studio 2010”

  1. Marc Says:

    When I try to build gsl.dll.sln, the build seems to be successful but I get at the end Unable to start program ‘C:\gsl-1.15\build.vc10\gsllib\lib\x64\Debug\gsl.lib’ The specified file is an unrecognized or unsupported binary format. The lib folder (C:\gsl-1.15\build.vc10\lib) is still empty afterwards.

  2. Marc Says:

    Sorry that was gsl.lib.sln not gsl.dll.sln

    • Border Crosser Says:

      I got the same problem with you. However, did you build on only for gslhdr project only recommended by gsl.vc10.readme.txt in “gsl-1.15-vc10.zip”? And afterwards did you build for cblaslib project or gsllib project inside “gsl.lib.sln”?

      • Border Crosser Says:

        sorry let me proof-read the above message: I got the same problem with you. However, did you build for only gslhdr project recommended by “gsl.vc10.readme.txt” inside “gsl-1.15-vc10.zip”? And afterwards did you build for “cblaslib” project or “gsllib” project inside “gsl.lib.sln”?

  3. Chao Ding Says:

    seems there is a dir mismatch. Should copy files in gsl-1.15 folder to gsl-1.15-vc10 folder

  4. Ron Says:

    Hi,

    I was not able to make the above work. I tried several times following the instructions above, but even when all seem to be in place, the #include directives do not find any of the header files (for example
    #include does not work because gsl_bspline.h is under gsl\bspline\) I was wondering if someone could help me. I did not want to do a global replace throughout the project since this would cause other issues. Perhaps I have issues with my setup, I am not experienced enough to verify that.

    I appreciate the help.

    • 4fire Says:

      Hello Ron,
      I have just rebuilt GSL with VS 2010 and found some errors with the instructions in this post. I am sorry for that because this post was long time ago and my current work does not use GSL. So I updated it and it should work smoothly now, hope this will help you. If you find any errors, I am willing to help.

      • Ron Says:

        Thanks so much, I appreciate the patience.

        I followed the new instructions and now it seems to find all of the files. However I get huge amount of errors looking like:

        1>…\gsl_build\gsl-1.15-vc10\gsl/gsl_precision.h(67): error C2054: expected ‘(‘ to follow ‘SL_VAR’
        1>…\gsl_build\gsl-1.15-vc10\gsl/gsl_precision.h(67): error C2082: redefinition of formal parameter ‘gsl_prec_eps’
        1>…\gsl_build\gsl-1.15-vc10\gsl/gsl_precision.h(68): error C2082: redefinition of formal parameter ‘gsl_prec_sqrt_eps’
        1>…\gsl_build\gsl-1.15-vc10\gsl/gsl_precision.h(69): error C2082: redefinition of formal parameter ‘gsl_prec_root3_eps’
        1>…\gsl_build\gsl-1.15-vc10\gsl/gsl_precision.h(70): error C2082: redefinition of formal parameter ‘gsl_prec_root4_eps’
        1>…\gsl_build\gsl-1.15-vc10\gsl/gsl_precision.h(71): error C2082: redefinition of formal parameter ‘gsl_prec_root5_eps’
        1>…\gsl_build\gsl-1.15-vc10\gsl/gsl_precision.h(72): error C2082: redefinition of formal parameter ‘gsl_prec_root6_eps’
        1>…\gsl_build\gsl-1.15-vc10\gsl/gsl_precision.h(78): fatal error C1070: mismatched #if/#endif pair in file ‘…\gsl_build\gsl-1.15-vc10\gsl\gsl_precision.h’ ccopy.c

        It seems like the same set of errors appears for every file. It may be a configuration problem.

        • 4fire Says:

          Hi Ron, there is one thing you might miss: overwrite all duplicate files when you copy. Because I did not encounter that error. I am willing to discuss with you on this topic. Or may be I can send you the whole project so you can build on your machine?

          • Ron Says:

            I tried to copy the files and this time I overwrote duplicates. I left with the same problem. It will be best if you could send me the whole project, I would really appreciate it (I hope it will work) !!!

          • 4fire Says:

            Hello, I could not send email (attached the zipped project folder-over 2000 file and only 3.1 Mb) to your email address. May be the attached file exceeded your email rules.

          • Ron Says:

            Thanks a lot!

            Can you try to send it to rshalev@gmail.com? Or maybe through yousendit.com?

            Ron

  5. Bereket Says:

    (Windows 7, Pygsl 0.9.5, GSL 1.15, Python 2.7, GCC 4.5.2)
    Hey thanks for the guide. So I followed your instructions word for word and the solution files built successfully. However, I tried to build the test files and test.gsl.lib worked but test.gsl.dll failed on all tests. Something to do with linking. Example:
    1>test.obj : error LNK2019: unresolved external symbol _gsl_nan referenced in function _rhs_xsin
    1>test.obj : error LNK2019: unresolved external symbol _gsl_odeiv2_driver_free referenced in function
    _test_odeiv_stepper

    Anyway, do you have any ideas? I can send you more information if you need. Or if you just have the dll and lib files I would love to have those. Thanks!
    Cheers,
    Bereket

    • 4fire Says:

      Hello Bereket, thanks for your comments. I have checked the problem you mentioned and found the solution: Go to Property Manager of the test.gsl.dll Solution, choose any project, right click on the Microsoft.Cpp.Win32.user and choose Properties. In the dialog appeared, in the Linker tree, choose Input and add two files: gsl.lib
      cblas.lib
      Also in the same dialog, in the VC++ Directoties, you need to add the path to the folder of the two above .lib files. Almost projects can be compiled now, except two ones with an error that you can find the solution at: http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/b1cf8b8e-7904-4d30-b472-4470e2ce8f86/
      Hope this help.

  6. Border Crosser Says:

    I think there is typing mistake, right?
    For “3. Copy all gsl_*.h files from GSL_build\gsl-1.15 folder to GSL_build\gsl-1.15-vc10\gsl folder (you should do a search here and make a copy on the found files).”, it should be “3. Copy all gsl_*.h files from GSL_build\gsl-1.15 folder to GSL_build\gsl-1.15\gsl folder (you should do a search here and make a copy on the found files).”

  7. Michael Says:

    Hi! thanks for your tutorial! I tried to use it with GSL 1.16 and VS2012 but without success. When I try to build the gsl dll I get 145 errors like that:
    Error 1 error C1083: File (Source) couldn’t be opened “..\..\cblas\caxpy.c”: No such file or directory C:\Users\Michael\Downloads\GSL_build\build.vc11\cblaslib\c1 cblaslib

    Could you help me or send me the dll and lib?
    Thanks,

    Michael

  8. zarda Says:

    I find a way out finally…
    select the project that will call the routine->open the project property pages->configuration preperties->c/c++->advanced
    now, to the right, there is a ” compile as” option.
    DON’T select “compile as C++ code (/TP)”, which is assumed by the compiler.
    select the “compile as C code (/TC)”.
    then rebuild.

  9. 4fire Says:

    Thank you for your comment. But it should be clearer: in which case your comment may be helpful? Because on my machine, that kind of option is predefined by the project files by Brian Gladman (http://gladman.plushost.co.uk/oldsite/computing/gsl-1.16-vc11.zip or http://gladman.plushost.co.uk/oldsite/computing/gsl-1.15-vc10.zip), it is not changed by me to get the building process works.

  10. Neeq Says:

    Hi, I followed the instructions above and up to step 5 everything was ok. However I get the following errors when I implement step 6:

    Error 2243 error C2375: ‘gsl_acosh’ : redefinition; different linkage C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\math.h 475 1 gsldll
    Error 2244 error C2375: ‘gsl_asinh’ : redefinition; different linkage C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\math.h 477 1 gsldll
    Error 2245 error C2375: ‘gsl_atanh’ : redefinition; different linkage C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\math.h 479 1 gsldll
    Error 2246 error C2375: ‘gsl_expm1’ : redefinition; different linkage C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\math.h 490 1 gsldll
    Error 2247 error C2375: ‘gsl_log1p’ : redefinition; different linkage C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\math.h 503 1 gsldll

    The error is associated with the gsl_sys.h. I am not that familiar with this library and I am also building using visual studio 2013. Any help to solve this will be greatly appreciated. Thanks

    • Zeeshan Says:

      To compile, you need to change “#define HAVE_DECL_ACOSH 0” to “#define HAVE_DECL_ACOSH 1” for all the method that are defined in math.h and displayed in the error message.


Leave a reply to 4fire Cancel reply