Search code examples
openmpautotoolsautoconfautomake

Enable OpenMP checks and flags in autoconf and automake


I cannot for the life of me find any information on the internet about using openMP with the autotools! I find vague references to macros like AC_OPENMP and AX_OPENMP, neither of which work. AC_OPENMP causes a "possibly undefined macro error". AX_OPENMP gets past autoconf, but causes configure to complain that AX_OPENMP is undefined. It is my understanding that these macros should check for openMP and set OPENMP_CFLAGS to the appropriate value.

Over in my Makefile.am, I can't even get foo_CXXFLAGS (it's a C++ project) to work right for OpenMP. If I manually set foo_CXXFLAGS = -fopenmp in Makefile.am, the -fopenmp flag is added to all the compile commands except for the (link) stage that combines the object files together, of course causing undefined reference errors. This one may be my misunderstanding. setting AM_CXXFLAGS = -fopenmp works, but its not the best thing to do. Actually neither is setting foo_CXXFLAGS without checking but I can't seem to get that to work.

Please, can anyone help me here? This seems like such a simple, common task that there ought to be oodles of documentation out there on the web about it. To clarify a few things, yes, the code compiles fine if I do it manually, and it runs without error. It's only in this autoconfiscating stage that things are screwing up. If you could point me to documentation on using openMP with autoconf, you'd be my new best buddy. Thanks.

Autoconf version 2.59, automake version 1.9.6


Solution

  • As to your first question regarding "possibly undefined macro error", AC_OPENMP was added to autoconf in 2.62, so you'll need to upgrade. As to the second question, if you want a flag added at linktime, you want to specify it in AM_LDFLAGS