Thread: GSL library

  1. #1
    Registered User
    Join Date
    Aug 2008
    Location
    London and Lyon
    Posts
    26

    GSL library

    Hi everyone!

    I am using a code on a machine, and it works fine.

    I compile with

    gcc -c -g KANT.c
    g77 -c -g tn.f
    g77 -c -g blas.f
    gcc -g KANT.o tn.o blas.o -lgsl -lgslcblas -lg2c


    (Thanks to this forum I found out how to mix fortran and c in the same code).

    Now I want to work on another machine that doesn't have gsl libraries installed and I don't have administration rights.

    So I downloaded gsl localy.

    and I type

    gcc -c -I/data/mtsamado/KANT_8-8-2007/gsl/include/ KANT.c
    gcc -L/data/mtsamado/KANT_8-8-2007/gsl/lib KANT.o -lgsl -lgslcblas

    the executable a.out is generated but when I try to run it I get the error message :

    ./a.out: error while loading shared libraries: libgsl.so.0: cannot open shared object file: No such file or directory

    Any ideas ??
    Thanks a lot.
    Michel

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I expect you haven't actually got the library itself of libgsl - only the devel variant of it. You would need to install the libgsl as well.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Aug 2008
    Location
    London and Lyon
    Posts
    26
    In the working directory I have the directory gsl/ that contains

    include/
    lib/

    where lib/ contains the following
    libgsl.a libgslcblas.la libgslcblas.so.0 libgsl.la libgsl.so.0 pkgconfig
    libgslcblas.a libgslcblas.so libgslcblas.so.0.0.0 libgsl.so libgsl.so.0.9.0


    Is it not enough ??

    Thanks

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Aha, ok. So the quick fix would be to add the path to that local directory to LD_LIBRARY_PATH. However, this is also a possible source of security holes, as someone may add a libc.so that contains some extra code to compromize your account into that directory, so the correct option would be to actually install libgsl into the /usr/lib or some other path that is already in LD_LIBRARY_PATH.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Aug 2008
    Location
    London and Lyon
    Posts
    26
    Thanks I am not expert with linux and all these path things

    I found on the net that I should do something like

    export LD_LIBRARY_PATH=/data/mtsamado/KANT_8-8-2007/gsl/lib

    but when I do that I get

    export: Commande introuvable. (which in english the computer cannot find the command export)

    1) Is it the correct syntax to ling my code to GSL?
    2) Is there another way to link directly the code to the library I need ?

    By the way I have no administrator rights, so I don't think I could instal GSL in /usr/lib ?? Is that right ?

    thanks a lot for the help.

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You probably want to ADD to the existing LD_LIBRARY_PATH, something like:
    Code:
    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:mypath
    You could also try to make a static link - add "-static" at the beginning of your final gcc command (the one that builds the final executable).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Aug 2008
    Location
    London and Lyon
    Posts
    26
    You're a genious !!

    I type

    gcc -c -I/data/mtsamado/KANT_8-8-2007/gsl/include/ KANT.c
    gcc -static -L/data/mtsamado/KANT_8-8-2007/gsl/lib KANT.o -lgsl -lgslcblas -lm

    As you suggested and it works !!
    Thanks

  8. #8
    Registered User
    Join Date
    Aug 2008
    Location
    London and Lyon
    Posts
    26
    Something more occured !

    I run the code everything is fine until a message segmentation fault occured (I run with gdb)


    Program received signal SIGSEGV, Segmentation fault.
    gsl_fit_wlinear (x=0x7fffd06210a0, xstride=1, w=0x7fffd0621000, wstride=1, y=0x7fffd0621050, ystride=1, n=13783292549630263302,
    c0=0x7fffd0621000, c1=0x7fffd0621000, cov_00=0x7fffd0621000, cov_01=0x7fffcfe65420, cov_11=0x7fffd0621000, chisq=0x7fffd0621000)
    at linear.c:131
    131 linear.c: Aucun fichier ou répertoire de ce type.
    in linear.c

    What does this mean ?
    I guess gsl_fit_wlinear is not found ???


    Is it still a library issue or something else ?

    Thanks

  9. #9
    Registered User
    Join Date
    Aug 2008
    Location
    London and Lyon
    Posts
    26
    Any ideas, anyone ??

    Thanks
    Michel

  10. #10
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by mimi1981 View Post
    n=13783292549630263302,
    I find that line highly odd. looks like that function was called with an enormous value for *n*. Now, I don't know what that library does or what n is used for, but that just doesn't look right to me. What's that function supposed to do?

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  11. #11
    Registered User
    Join Date
    Jul 2005
    Posts
    31
    Pete is right. According to the the GSL docs (http://www.csse.uwa.edu.au/programmi...sl-ref_34.html) the 7th argument of that function is the number of elements in the array you are passing to the function. You are getting a seg. fault because GSL is running over the buffer and eating you stack (until it hit projected memory -- or something like that).

    Go to the line in you code where you call the gsl_fit_wlinear function and make sure you have got the function arguments correct. Post you code if you want I have used GSL before.

    Cheers,

    Dan.

  12. #12
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Actually, looking at the value of N as a hex value gives: BF48178C00000006. BF48178C seems like a stack address, 00000006 is a sensible small number.

    My guess would be that the arguments are messed up for this function - something that should be a stack address is taken as a long long int.

    Another alternative is that n is actually a double floating point that is negative.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #13
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by matsp View Post

    My guess would be that the arguments are messed up for this function - something that should be a stack address is taken as a long long int.
    Maybe passing a pointer instead of an integer?

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  14. #14
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by QuantumPete View Post
    Maybe passing a pointer instead of an integer?

    QuantumPete
    Surely a possibility.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  15. #15
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by matsp View Post
    Surely a possibility.

    --
    Mats
    Then it pays to take notice of your sig and compile with -Wall

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What's an import library?
    By chiefmonkey in forum C++ Programming
    Replies: 1
    Last Post: 06-19-2009, 05:00 PM
  2. Property Set Library (PSL) - Announcement
    By vultur_gryphus in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 05-29-2008, 06:04 AM
  3. Makefile for a library
    By sirmoreno in forum Linux Programming
    Replies: 5
    Last Post: 06-04-2006, 04:52 AM
  4. very weird .h problem
    By royuco77 in forum C++ Programming
    Replies: 1
    Last Post: 09-11-2005, 07:55 AM
  5. better c string functions
    By samps005 in forum C Programming
    Replies: 8
    Last Post: 11-04-2003, 01:28 PM