0

Have been trying to compile and run a simple OpenMP program (Hello World) on OSX 10.12. I installed gcc 6 using brew. I have been building using the '-fopenmp' flag. The program compiles fine, but when I try to execute the program I get the following:

dyld: lazy symbol binding failed: Symbol not found: ___emutls_get_address
  Referenced from: /usr/local/opt/gcc/lib/gcc/6/libgomp.1.dylib (which was built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: ___emutls_get_address
  Referenced from: /usr/local/opt/gcc/lib/gcc/6/libgomp.1.dylib (which was built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib

Abort trap: 6

Any ideas?

1 Answers1

0

Here's an example that runs on my iMac with g++-6, compiled as follows:

g++-6 -std=c++11 -fopenmp -O3 demo.cpp -o demo

Run as follows:

./demo
Time: 4.132ms, 1000000 elements.

Code as follows:

#include "omp.h"
#include <iostream>
#include <cmath>
#include <cstdio>
#include <chrono>

int main()
{
   const int size = 1000000;
   int i;
   double sinTable[size];
   std::chrono::time_point<std::chrono::high_resolution_clock> start = std::chrono::high_resolution_clock::now(); 

   #pragma omp parallel for
   for(int n=0; n<size; ++n)
      sinTable[n] = sqrt(std::sin(2 * M_PI * n / size));

   std::chrono::time_point<std::chrono::high_resolution_clock> end = std::chrono::high_resolution_clock::now();
   std::uint64_t duration = std::chrono::duration_cast<std::chrono::nanoseconds>(end-start).count();
   float ms=duration/1000000.0;
   std::cout << "Time: " << ms << "ms, " << size << " elements." << std::endl;
}
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • So, you have uninstalled **Xcode**, uninstalled **g++** and reinstalled **Xcode** and re-installed its command-line tools and installed **g++** with the `--without-multilib` option and recompiled the code above and it still fails? – Mark Setchell Apr 30 '17 at 15:45