So, I have a program that runs with OpenBlas and I want to compile it. The linking process looks like this:
gcc -o prog prog.o -O3 -I/opt/OpenBLAS/include -L/opt
On linux, it is also possible to use $ORIGIN in rpath to mean the directory path to the application and build a relative rpath from there. You would then move the library to a known relative path to the binary.
gcc -o prog prog.o -O3 -I/opt/OpenBLAS/include -Wl,-rpath=\$ORIGIN/lib -L/opt/OpenBLAS/lib -lopenblas
You can also use the full path to the libary, and it will be linked in:
gcc -o prog prog.o -O3 -I/opt/OpenBLAS/include /opt/OpenBLAS/lib/libopenblas.so
If you run "ldd" on the executable, you should see the full path encoded.
Add the path to the runtime library search path.
gcc -Wl,-rpath=/opt/OpenBlas/lib ...
What the -L
option does at link time, the -rpath
option does at run time.