0

I am in a situation where I have to link some object files built with GCC to my application which is based on LLVM. The problem is that the application relies on LLVM's OpenMP library while the GCC objects have references to GCC's OpenMP. Thus I am getting a linker error. The command is rather complicated but it boils down to the following:

clang -shared -L../libs -o ../libs/libfoo.so -fopenmp clang_wrapper.o -lgcc_archive -lgfortran -lgcc_s

Undefined symbols for architecture arm64:
  "___aarch64_cas8_acq_rel", referenced from:
      ___foo in libgcc_archive.a(bar.o)
  "___aarch64_ldadd8_relax", referenced from:
      _foo_ in libgcc_archive.a(bar.o)
  "_omp_set_dynamic_8_", referenced from:
      ___foo in libgcc_archive.a(bar.o)
  "_omp_set_nested_8_", referenced from:
      ___foo in libgcc_archive.a(bar.o)
  "_omp_set_num_threads_8_", referenced from:
      ___foo in libgcc_archive.a(bar.o)

The above functions aren't available in LLVM's OpenMP library but are there in the GNU OpenMP library.

Is there some way to make this work even if I use GCC for linker? The end goal is to eliminate the dependency on GCC's OpenMP library and use LLVM instead.

RegedUser00x
  • 2,313
  • 5
  • 27
  • 34
  • Does this answer your question? [Telling GCC to \*not\* link libgomp so it links libiomp5 instead](https://stackoverflow.com/questions/25986091/telling-gcc-to-not-link-libgomp-so-it-links-libiomp5-instead) – Jérôme Richard Feb 21 '22 at 09:42
  • Linking with GCC by removing `-fopenmp` and adding `-lomp` reduces the errors to _omp_set_dynamic_8_, _omp_set_nested_8_ and _omp_set_num_threads_8_ missing. – RegedUser00x Feb 21 '22 at 10:02
  • 1
    @JérômeRichard, thanks! I solved the problem with the information from the link. – RegedUser00x Feb 21 '22 at 15:55
  • If you now have an answer, it's polite to put it here as such so that other people can find it. – Jim Cownie Feb 21 '22 at 17:43

0 Answers0