Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22456

Link the OpenMP library statically in C/C++

$
0
0

I have a simple C++ program that does nothing:

int main() { return 0; }

I am trying to build this program completely statically using the following command:

g++ -o c c.cc -static

Everything works fine. However, when I try to link OpenMP, which is not actually a library, using the -fopenmp flag in static mode like this:

g++ -o c c.cc -fopenmp -static

The compiler gives an error:

/usr/bin/ld: cannot find -lgomp: No such file or directorycollect2: error: ld returned 1 exit status

This issue occurs with clang++ as well. The same happens with gcc and g++. However, other libraries that have static versions, such as curl, link correctly in static mode.

(I am on Arch Linux)


Viewing all articles
Browse latest Browse all 22456

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>