0

I have a cpp file with openMP functions and I want to link it statically. I have already tried solution proposed here but without success.

If I use the following commands:

g++ -c main.cpp -fopenmp -o main.o
g++ -static -lgomp -lpthread main.o -o main

I get errors saying that there is no reference to "dlopen, dlsym, dlclose, dlerror".

So, I tried also to add -fopenmp flag in linking command:

g++ -c main.cpp -fopenmp -o main.o
g++ -static -lgomp -lpthread -fopenmp main.o -o main

Now I don't receive linking errors, but I get this warning:

/usr/lib/gcc/x86_64-linux-gnu/7/libgomp.a(target.o): in function "gomp_target_init":
(.text+0x8b): attention: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

This warning suggest me that static linking has not been successful (even if ldd main states is not a dynamic executable.

Any suggestion?

  • 1
    This message is just a warning, not an error. do `ldd main` and you should get `not a dynamic executable` – Gilles Apr 16 '22 at 16:35
  • @Gilles thanks for your response. My problem is that I have to run the binary with a simulator [gem5](https://www.gem5.org/documentation/) in which it is not possible to have dynamic linking. That warning it is okay if I execute the application in my Ubuntu OS, but it can be ignored if I have to run the application on that simulator. – Mirco Mannino Apr 16 '22 at 16:58
  • just try it. It is very likely it will work, although it is not guaranteed. You'll know immediately anyway. – Gilles Apr 21 '22 at 17:26

0 Answers0