1

Not sure this is the right forum, but I'll give it a go anyways.

I am trying to compile and install the libeemd library (https://bitbucket.org/luukko/libeemd). My end goal is to include the C library in a Matlab script later on using MEX, however, I have run into a wall.

According to the README file included in the package, I can compile the library using make when in the top level directory, however, when that is done, I get the following result

Alexanders-MacBook-Pro-2:libeemd neergaard$ make
gcc -Wall -Wextra -std=c99 -pedantic -Wno-unknown-pragmas -Wshadow -Wpointer-arith  -g -DEEMD_DEBUG=0 -fopenmp src/eemd.c -fPIC -shared -Wl,-soname,libeemd.so.1.3 -I/opt/local/include -L/opt/local/lib -lgsl -lgslcblas -lm  -DHAVE_INLINE -o libeemd.so.1.3
ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libeemd.so.1.3] Error 1

I'll admit, I do not have that much experience in this sort of thing, but I'm hoping that some of you smart guys could give me some pointers as to how I'm going to work around this.

Any help is appreciated greatly. If I haven't supplied enough information, please let me know.

Thank you!

Neergaard
  • 454
  • 4
  • 16

1 Answers1

0

From a couple of years, the default compiler in OS X is clang (llvm) and not gcc. The linker is telling you that it cannot find openMP (libgomp), this is due to the fact that clang does not yet include it, however the support seems now complete and you can install it by downloading the latest version of llvm: https://clang-omp.github.io

A simpler solution would be to use homebrew and install clang-omp:

brew install clang-omp

which will install a compiler with full support for openMP (clang-omp++).

Then you have to modify the Makefile, first set the PREFIX according to your installation path and then modify the following lines:

gcc $(commonflags) -c $< $(gsl_flags) -o $@

to:

clang-omp $(commonflags) -c $< $(gsl_flags) -o $@

and:

gcc $(commonflags) $< -fPIC -shared -Wl,-soname,$@ $(gsl_flags) -o $@

to:

clang-omp $(commonflags) $< -fPIC -shared -Wl, $(gsl_flags) -o $@

I was able to compile the library and the examples and run one of them on my OS X 10.10.5 with clang-omp version 3.5.0.

The problem here is that while the project states that the library will work with every compiler (c99) the Makefile is adapted to gcc.

Another option is to install and use gcc.

see also this post: Error enabling openmp - "ld: library not found for -lgomp" and Clang errors

Community
  • 1
  • 1
terence hill
  • 3,354
  • 18
  • 31
  • Thanks for the quick reply. I tried using homebrew and installing clang-omp that way, however, the error persists. – Neergaard Dec 13 '15 at 10:31
  • Did you modified the libeemd Makefile to use clang-omp++? – terence hill Dec 13 '15 at 10:40
  • Yes, and that resulted in this error `clang-omp++ -Wall -Wextra -std=c99 -pedantic -Wno-unknown-pragmas -Wshadow -Wpointer-arith -g -DEEMD_DEBUG=0 -fopenmp src/eemd.c -fPIC -shared -Wl,-soname,libeemd.so.1.3 -I/opt/local/include -L/opt/local/lib -lgsl -lgslcblas -lm -DHAVE_INLINE -o libeemd.so.1.3 clang-3.5: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated error: invalid argument '-std=c99' not allowed with 'C++/ObjC++' make: *** [libeemd.so.1.3] Error 1` Should I remove that argument? – Neergaard Dec 13 '15 at 10:51
  • You can give it a try – terence hill Dec 13 '15 at 10:55
  • That opened up all kinds of hell. The execution just stopped because of all the errors that occurred. – Neergaard Dec 13 '15 at 11:06
  • I was able to compile it, first you should use clang-omp and not clang-omp++. I will update the answer with the needed modifications to the Makefile – terence hill Dec 13 '15 at 11:09