So I’m trying to build GotoBLAS2 for use in WIEN2k, and after using make, I see that the GotoBLAS build is complete (and of course, no errors as reported by make). A quick check of the files reveals that both libgoto2_prescottp-r1.13.a and libgoto2_prescottp-r1.13.so are contained within the directory /Research/GotoBLAS2. However, using a small test program to double check my work, I encounter the following problem:
labadmin@Gateway:~/Research/Sr2YRuO6-110914$ gfortran Fit-4.2K-0T-110803test.f -L../GotoBLAS2 -lgoto2_prescottp-r1.13 -o Fit-4.2K-0T-110803test.x
labadmin@Gateway:~/Research/Sr2YRuO6-110914$ ./Fit-4.2K-0T-110803test.x
./Fit-4.2K-0T-110803test.x: error while loading shared libraries: libgoto2_prescottp-r1.13.so: cannot open shared object file: No such file or directory
I’ll admit that I am fairly unfamiliar with linking shared libraries, but as far as I can tell the calls I used were appropriate. Can anyone possibly help with this? Thanks!
The problem is that while you told the toolchain where to find the shared library at link time via the -L flag, you have not provided any information to the loader about where to find dependent libraries at runtime. So when you try to run your executable, it fails to find the library.
You don’t say what OS you are running, but I’ll guess Linux, or some other unix-y thing based on your commands. In that case you can either export a value for LD_LIBRARY_PATH (man ld-linux.so for linux, or whatever the name of your runtime linker is) in your environment, or set a DT_RUNPATH entry in your executable at link time to record a library path to be searched (man ld, or whatever your linker is on your system).