Reputation: 752
I've read a bit from the Writing R Extensions manual but I can't quite figure this out - where do I put the -fopenmp flag in makevars? I can set
PKG_FCFLAGS = -fopenmp
which compiles fine. But I'm not sure if I should also be setting it for PKG_LIBS
and PKG_CPPFLAGS
?
When I try for PKG_LIBS
it gives me an error
i686-apple-darwin8-gfortran-4.2: libgomp.spec: No such file or directory
But if I just use it in PKG_FCFLAGS
then even though it compiles fine, when I try to use the routine in R, it says
Error in dyn.load("correlate.so") :
unable to load shared object '/Users/Steven/Documents/PhD/npsR/correlate.so':
dlopen(/Users/Steven/Documents/PhD/npsR/correlate.so, 6): Symbol not found: _GOMP_parallel_end
Referenced from: /Users/Steven/Documents/PhD/npsR/correlate.so
Expected in: dynamic lookup
So obviously the gomp library has not been linked correctly. Any ideas?
Cheers.
Upvotes: 1
Views: 1203
Reputation: 752
So I have solved this issue (though I have opened up another can of worms now...). I'm not sure exactly what I did which solved the issue but I'll list what I did do here.
After finding that the fortran program itself would not compile and link with openMP (not counting in R at all) I figured it was something to do with the gfortran installation. So what I did was:
PATH = /usr/bin:$PATH
in my .bash_profile
PKG_FCFLAGS = -fopenmp
and PKG_LIBS = -fopenmp
. It seems both of these are necessary.Then it worked! By the way, this is on OS X 10.7 (Lion).
Thanks for everyone's help.
Upvotes: 0
Reputation: 94307
Luke Tierney's pnmath package http://homepage.stat.uiowa.edu/~luke/R/experimental/ uses OpenMP and has the following in its Makevars:
PKG_CFLAGS=-fopenmp
PKG_LIBS=-lgomp
and Makevars.win:
PKG_CFLAGS=-fopenmp
PKG_LIBS=-mthreads -lgomp -lpthreadGC2
You seem to be on a Mac so maybe neither work. But setting PKG_LIBS=-lgomp
looks critical.
Upvotes: 3