Closed vebjoro closed 1 year ago
Hi @vebjoro!
First, generally the way to use openmp is not to add -lomp
, but rather use the compiler flag -fopenmp
, see the examples here: https://github.com/anderkve/FYS3150/tree/master/code_examples/omp_parallelization (OpenMP support is sort of a built-in feature of most compilers.)
If that doesn't work, here are some questions and things you can try:
Which compiler version are you using? Try running g++ --version
.
Have you tried explicitly installing the libomp-dev
package? If not, try sudo apt install libomp-dev
To find the path of an installed libomp.so
library, you can try this: First, run the command
apt list --installed | grep "libomp"
Then you might get a list looking something like this:
libomp-14-dev/jammy,now 1:14.0.0-1ubuntu1 amd64 [installed,automatic]
libomp-dev/jammy,now 1:14.0-55~exp2 amd64 [installed]
libomp5-14/jammy,now 1:14.0.0-1ubuntu1 amd64 [installed,automatic]
Now try running commands like
dpkg -L libomp-14-dev | grep ".so"
and similar for other variants of the libomp package names found above. That should give output of this sort:
/usr/lib/llvm-14/lib/libarcher.so
/usr/lib/llvm-14/lib/libompd.so
/usr/lib/llvm-14/lib/libomptarget.rtl.amdgpu.so
/usr/lib/llvm-14/lib/libomptarget.rtl.cuda.so
/usr/lib/llvm-14/lib/libomptarget.rtl.x86_64.so
/usr/lib/llvm-14/lib/libomptarget.so
/usr/lib/llvm-14/lib/libgomp.so
/usr/lib/llvm-14/lib/libiomp5.so
/usr/lib/llvm-14/lib/libomp.so
/usr/lib/x86_64-linux-gnu/libiomp5.so
/usr/lib/x86_64-linux-gnu/libomp5.so
So here it looks like the libomp library lives in the folder /usr/lib/llvm-14/lib
. So that means you could try to add -L /usr/lib/llvm-14/lib
to your g++
command, i.e. g++ prob_8.o state.o -larmadillo -L /usr/lib/llvm-14/lib -lomp -o main
.
Hi,
I am trying to link the code for problem 8: g++ prob_8.o state.o -larmadillo -lomp -o main
but I get the following error message:
/usr/bin/ld: cannot find -lomp: No such file or directory collect2: error: ld returned 1 exit status make: *** [makefile:12: prob_8] Error 1
Does anyone have a fix for this?