Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

GSL install with mingw_w64

Help
rgnoob
2012-07-16
2013-06-06
  • rgnoob
    rgnoob
    2012-07-16

    Hi,
    I am new to mingw_w64 and i am trying to install GSL to use with it.  I have successfully installed GSL multiple times now, but when i try to compile code, both my msys and the mingw_w64 cannot find the GSL libraries.  I am trying to use GSL and mingw with a utility called gnumex to use with matlab.

    Thank you

     
  • rgnoob
    rgnoob
    2012-07-16

    Oh sorry, I am using the TDM-GCC build for windows 64 bit

     
  • rubenvb
    rubenvb
    2012-07-16

    When you compile GSL from the MSYS shell, you can specify a

    --prefix=
    

    option. What I usually do is make the prefix something like

    --prefix=/gsl
    

    so that make install will copy everything to MSYS' "/gsl". This can then be copied to somewhere GCC can find it, for example

    mingw64/x86_64-w64-mingw32
    

    Make sure you either build statically or you copy the dll's to somewhere in PATH. (like "mingw64/bin").
    You can obviously set the -prefix option to the mingw64 directory directly, but I find that has too much chance of error and soiling the toolchain's install.

     
  • rgnoob
    rgnoob
    2012-07-16

    Thank you for the quick reply!

    "Make sure you either build statically or you copy the dll's to somewhere in PATH. (like "mingw64/bin"). You can obviously set the -prefix option to the mingw64 directory directly, but I find that has too much chance of error and soiling the toolchain's install."

    The dll's you're referencing, are they the dll's for gsl? What does it mean to build statically?Sorry, i know its probably a dumb question.. Once the make install unpackages everything into say the /gsl folder, all i have to do is copy it to the existing mingw_64 folder?

    Thanks

     
  • rgnoob
    rgnoob
    2012-07-16

    I guess another problem i am confused about is which instance of each folder to use?  when i look at my mingw_w64 folder, I see a bin, lib, lib32, …, and a x86_64-w64-mingw32, but the  x86_64-w64-mingw32 folder has all of its own versions of each of the lib, bin, lib32, and include. So should i be using the  x86_64-w64-mingw32 folder for gcc or should i be using the contents in the root folder?

     
  • rubenvb
    rubenvb
    2012-07-17

    he dll's you're referencing, are they the dll's for gsl?

    Yes (libgsl-?.dll and I think also libcblas-?.dll). Of course you'll also need the libgcc dll as well for any program built with GCC not linked with -static

    What does it mean to build statically?

    A static executable is a file that does not depend on any 3rd party DLLs, like libgcc, libgsl, etc… So you won't have to place the respective DLLs in the same directory as your exe when you distribute it.

    Once the make install unpackages everything into say the /gsl folder, all i have to do is copy it to the existing mingw_64 folder?

    Yes, for x86_64-w64-mingw32 (GCC's 64-bit target) you'll need to copy them into the x86_64-w64-mingw32 subfolder so that /gsl/include and /gsl/lib overwrite the …./x86_64-w64-mingw32/include and lib respectively. The "bin" directory should be placed one level higher, in the same place as libgcc and libstdc++ and gcc.exe reside. Obviously, if you want 32-bit libraries as well, you cannot place the dll's in that location, because they would overwrite the 64-bit versions (they will have the same name).

    You can also point the compiler to the include files by using

    -I"../some/path/to/gsl/include
    

    and when linking use

    -L"../some/path/to/gsl/lib -lgsl -lgslcblas
    

    Note I am not sure about the gsl cblas library name, you'll have to double check that.

     

  • Anonymous
    2012-10-02

    Hi all… I am having similar problems with GSL 64 bit being compiled using minGW gcc (TDM 64 bit build) …

    I have tried a few things thus far, including downloading GSL 64 bit binaries via the boost scientific library

    per advice here (http://www.brianomeara.info/tutorials/brownie/gsl)

    …and different gsl 64bit binaries via an installer from
    here: (http://wiki.rglab.org/index.php?title=Public:Installation_of_GSL_from_Windows_binary)

    and now have all the files I need to link up my c program… My compiler is finding all of the .h files, and my linker seems to be finding the -lgsl and -lgslcblas.

    However, despite everything looking rosy from that perspective, when it comes time to link, I get undefined references to all the GSL types.   >:-|

    I am suspecting that the binaries I downloaded are somehow disagreeing with my system? But this is where my knowledge of the c build process begins to falter… Do I really need to compile GSL from source with my gcc 64 bit compiler on THIS system? or is there something else I am missing?

     

  • Anonymous
    2012-10-02

    *methods I mean….

    like: undefined reference to `gsl_matrix_alloc'

     
  • rubenvb
    rubenvb
    2012-10-07

    Hi GratefulTony,

    I have built and uploaded a GSL 1.15 64-bit build that you can use here. Easiest way to install is to extract to your toolchain directory so that the x86_64-w64-mingw32 directories overlap and libgsl.a appears in <toolchain-dir>/x86_64-w64-mingw32/lib. No extra "-I" or "-L" options are needed in this scenario to point your compiler to the library files.

    I tested a simple GSL app:

         #include <stdio.h>
         #include <gsl/gsl_sf_bessel.h>
         
         int
         main (void)
         {
           double x = 5.0;
           double y = gsl_sf_bessel_J0 (x);
           printf ("J0(%g) = %.18e\n", x, y);
           return 0;
         }
    

    which worked when compiled with:

    gcc gsl_test.c -lgsl -o test
    

    I compiled GSL from MSYS like this:

    $ ../gsl-1.15/configure --host=x86_64-w64-mingw32 --prefix=/gsl64 && make -j4 && make -j4 check && make install
    

    Which makes libgsl.a end up in <msys-root>/gsl64/lib

    I hope this helps.