Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Use GSL library with Qt



  • Hi,
    I know this question was asked many times before, but I still have troubles in solving this issue.
    what I have done so far:

    • i managed to successfully compile the library using MinGW according the procedure described in this link. As a result, I obtained "C:\gsl-2.6" with four folders in it: bin, include, lib and share. the bin folder contains libgsl-25.dll and libgslcblas-0.dll and lib folder contains: libgsl.a and libgslcblas.a. And the include contains gsl folder with the required headers of the library in it.
    • I made a Qt Widget Application named gslTest and added to it
    win32{
       INCLUDEPATH += C:/gsl-2.6/include/
       INCLUDEPATH += C:/gsl-2.6/lib
       LIBS += -LC:/gsl-2.6/lib -llibgsl -llibgslcblas -lm
    }
    

    So far the project builds without any problem.

    • finally, I tried to implement this example.
    double x = 5.0;
    double y = gsl_sf_bessel_J0 (x);
    

    When I add #include <gsl/gsl_sf_bessel.h> qt recognizes it but i get error message in double y = gsl_sf_bessel_J0 (x);

    gslTest\gslTest\mainwindow.cpp:11: error: undefined reference to `gsl_sf_bessel_J0'
    

    I tried many ways to run this example and this the best I've got.
    Please, any ideal about what is wrong here.
    Thanks in advance.


  • Lifetime Qt Champion

    Hi,

    The lib in -llibgsl shall be dropped (same for the other libraires.)



  • @SGaist Thanks for the reply.
    Sorry but If i understand correctly. Should I rename the libraries without lib and keep the pro as it is or its the opposite? I tried both and still the same result.
    Please advise.


  • Lifetime Qt Champion

    No, you should modify your .pro file.

    Are you sure these libraries architecture matches the one from the Qt version you are using ?



  • @SGaist That was my problem. I compiled the libraries with MinGW 32 while my Qt's is MinGW 64. I changed the compiler and the problem is solved.
    Thanks for the help.