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.
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:$PATHin my.bash_profilePKG_FCFLAGS = -fopenmpandPKG_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.