Linking OpenMP Statically on Mac

Rob McDonald rob.a.mcdonald@gmail.com
Fri May 1 03:50:00 GMT 2015


Apologies if this is not the best place to post this question,
redirection appreciated.

My program requires OpenMP and uses some somewhat modern C++ features.
Consequently, on OSX, I can't use Apple's GCC (too old for C++11
stuff), and I can't use Apple's XCode (or anyone's) CLang/LLVM based
compilers (no OpenMP).

I am currently using GCC 4.8 as installed via MacPorts.  The exact
version isn't that important to me, I can upgrade/downgrade slightly
if required.  I also use CMake heavily, so CMake aware solutions are
appreciated, but not required.  I keep an old OSX 10.7.5 machine
around to build my distributable files on, the resulting binaries
generally work on a broad range of versions of OSX.

This works for me, but I would like to distribute precompiled binaries
to my users.   My program is open source, but not GPL.

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?

Or, will I need to distribute libgomp.1.dylib with my program?  Does
the license allow this?  Being a good citizen, where should I put the
file?  I would prefer my users not to have to use sudo to install if
they don't absolutely have to.  My program is currently not a Package,
it is just an executable and some data files distributed in a *.zip.

I would rather not force my users to install MacPorts, would using the
hpc.sourceforge.net built GCC provide an easier path?

Thanks for any advice,

Rob



More information about the Gcc-help mailing list