Search code examples
c++gsl

gsl undefined symbol: gsl_multifit_nlinear_trs_lmaccel


I'm having some troubles with the GNU Scientific Lbrary (GSL). After having intalled it, I tested it with the example here and it works when compiling with:

gcc -Wall -c main.cpp ; gcc -L/usr/local/lib main.o -lgsl -lgslcblas -lm -libtemt

Next, I tried to compile that with no change in the source code nor the compiling command. But here is the problem, when I try to run the result, I get :

./a.out: symbol lookup error: ./a.out: undefined symbol: gsl_multifit nlinear_trs_lmaccel

I tried to comment it out, but it's making other issues. I found that variable in the fulle doc, but I can't find where it's defined.

As the first example is working, I think GSL was installed successfully, and as the same variableis used in different codes, I think it's a global variable, defined in th library.

Does anyone have an idea why I can't access it?

Thank's a lot!


Solution

  • Well, after a lot of tears (no, it's a joke) I found a sort of answer:

    I copy and paste libgsl.a and libgslcblas.a in my directory, i wrote that makefile:

    CC=gcc
    CXXFLAGS=-W -Wall -ansi -pedantic
    LIBS=libgsl.a libgslcblas.a -lm
    main:main.o
        $(CC) -o main main.o $(LDFLAGS) $(LIBS)
    
    main.o: main.cpp 
        $(CC) -o main.o -c main.cpp $(CXXFLAGS)
    

    I'm happy with that answer even if there is 2 weaknesses: 1) I don't know how to use shared library (at this moment) 2) I don't know how to make it by command line

    Hope it will help someone