Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Install properly? #28

Closed
JesusSave opened this issue Nov 6, 2019 · 2 comments
Closed

How to Install properly? #28

JesusSave opened this issue Nov 6, 2019 · 2 comments

Comments

@JesusSave
Copy link

JesusSave commented Nov 6, 2019

Someone else install FGSL on my desktop, I can use FGSL in such an easy way:

gfortran -I/usr/include/fgsl bessel.f90 -lfgsl

However I installed FGSL on my Laptop, the same test does not work properly.

chen@jesuslovesme:~/Documents/numerical/fortran/fgsl$ gfortran -I/usr/include/fgsl bessel.f90 -lfgsl

Errors:
/usr/bin/ld: /tmp/cceiCL9M.o: in function MAIN__': bessel.f90:(.text+0x1d): undefined reference to gsl_sf_bessel_Kn'
/usr/bin/ld: bessel.f90:(.text+0xc3): undefined reference to `gsl_sf_bessel_Knu'
collect2: error: ld returned 1 exit status

The method I install is like this, doese there any problem?

export FC=gfortran
export PKG_CONFIG_PATH=/usr/include/gsl/lib/pkgconfig
export gsl_LIBS=/usr/include/gsl
[ -f ./fgsl.tar.gz ] && echo "No need to download fgsl" || wget https://github.com/reinh-bader/fgsl/archive/v1.3.0.tar.gz -O fgsl.tar.gz
mkdir -p fgsl_build
cd fgsl_build
tar -xzf ../fgsl.tar.gz --strip 1
autoreconf -fi
./configure CFLAGS="-Wall" FCFLAGS="-Wall" --prefix=${gsl_LIBS}
make
make check
make install
cd ..
rm -rf fgsl_build

@JesusSave
Copy link
Author

I don't why the two computers differ. However I find a universal way to compile:

To check the linkers first

pkg-config --libs fgsl

e.g. the linkers are printed

-L/usr/local/lib -lfgsl -lgsl -lgslcblas -lm

Then use the flags as a universe solution.
gfortran -I/usr/include/fgsl example.f90 -lfgsl -lgsl -lgslcblas -lm

@reinh-bader
Copy link
Owner

Since you seem to have found the solution, I will close this ticket. Generally note that the gsl_LIBS need to contain the library linkage spec, not the include path.

Regards
Reinhold

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants