Linking OpenMP Statically on Mac

Ángel González
Mon May 11 19:04:00 GMT 2015

Sending answer to the list for the benefit of future searchers.

On Fri, May 8, 2015 at 3:11 PM, Ángel González wrote:
>  On 01/05/15 05:50, Rob McDonald wrote:
>>  When I specify -fopenmp, the program is dynamically linked to
>>  libgomp.1.dylib.  I read that -static is not supported on OSX, as the
>>  Apple system libraries are not provided with static variants.
>>  So, is there a way to statically link libgomp in this situation?
>  If you have/build libgomp as a static library, it should be possible to only
>  link libcomp statically. If -fopenmp flag insists on linking dynamically,
>  you may need to call the linker manually. But I think it could be done.

As it turns out, there was a simple solution....

-static-libgcc -static-libstdc++

also forces static linking of libgomp for OpenMP.  I couldn't find
this documented anywhere, but it is good enough for me.

Thanks for the reply,


More information about the Gcc-help mailing list