How to build package with OpenMP support on OSX (Mavericks)

1,192 views
Skip to first unread message

damjan dvorsek

unread,
Sep 8, 2014, 8:48:44 AM9/8/14
to rdev...@googlegroups.com
I would like to install a package (xgboost ) that is built with OpenMP enabled on OSX (Mavericks). I have already installed gcc49 via MacPorts, because the clang compiler does not support OpenMP.  The gcc is recognised in the terminal and "gcc --version" command prints correct compiler information.  I would like to know if there is a way to "convince" devtools (i.e install_github()  function ) to use this compiler instead of clang for building the package?  Or if this is not practical, how can I build the xgboost library  manually and then pack it into R package. 

Thanks!

Timothy Bates

unread,
Sep 9, 2014, 10:31:48 AM9/9/14
to rdev...@googlegroups.com
We have some instructions here which seems to work for some people... in the process of improving them, so certainly keen to leanr/share experience.


Does Simon's 4.8.2 fortran have OpenMP support?

Timothy Bates

unread,
Sep 9, 2014, 10:34:29 AM9/9/14
to rdev...@googlegroups.com
We have some instructions here, which work from some if not all users... moving target...

http://openmx.psyc.virginia.edu/wiki/howto-build-openmx-source-repository

Certainly eager to learn how to do this better: Your question might be best posed on R-sig-mac?

PS: does simon's fortran support OpenMP?

damjan dvorsek

unread,
Sep 12, 2014, 8:09:19 AM9/12/14
to rdev...@googlegroups.com
Thanks Timothy,

I researched the issue some more, but didn't resolved it. I tried to
force R to use gcc compiler instead of clang by editing Makeconf  file
in /Library/Frameworks/R.framework/Versions/3.1/Resources/etc . I
replaced clang with gcc and  clang++ with g++. I also tried to force
compilation with OpenMP by adding "-fopenmp" flag to CFLAGS. But it
did not work. The problem I think is that R (specifically command "R
CMD build") uses Xcode for package compilation and Xcode uses gcc and
g++ as symlinks to clang compiler.  In the terminal  gcc links to true
gcc compilers and I can easy build python version of the xgboost
library with OpenMP support.

I did not l researched very much how to convince Xcode to use gcc, but
I think it's not easy thing to do.

Dne torek, 09. september 2014 16:34:29 UTC+2 je oseba Timothy Bates napisala:

damjan dvorsek

unread,
Sep 12, 2014, 10:37:16 AM9/12/14
to rdev...@googlegroups.com
I looked again at the link you provided and noticed that I can provide the whole path to the compilers in CC and CXX variables. I changed Makeconf again: 
CC = /opt/local/bin/gcc
CXX
= /opt/local/bin/g++

and added the "-fopenmp" flag. This time compilation goes trough without complaining  about OpenMP not being used ,  but at the end I get an error:

** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for 'xgboost', details:
  call
: dyn.load(file, DLLpath = DLLpath, ...)
  error
: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.1/Resources/library/xgboost/libs/xgboost.so':
  dlopen
(/Library/Frameworks/R.framework/Versions/3.1/Resources/library/xgboost/libs/xgboost.so, 6): Symbol not found: _GOMP_atomic_end
 
Referenced from: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/xgboost/libs/xgboost.so
 
Expected in: flat namespace
 
in /Library/Frameworks/R.framework/Versions/3.1/Resources/library/xgboost/libs/xgboost.so
Error: loading failed
Execution halted
ERROR
: loading failed
* removing '/Library/Frameworks/R.framework/Versions/3.1/Resources/library/xgboost'
Error: Command failed (1)




Dne petek, 12. september 2014 14:09:19 UTC+2 je oseba damjan dvorsek napisala:

fei...@avantcredit.com

unread,
Nov 19, 2014, 1:52:30 AM11/19/14
to rdev...@googlegroups.com
I experienced the same issue. I am wondering if there is a way to manually compile the R package.

Timothy Bates

unread,
Nov 23, 2014, 10:10:13 AM11/23/14
to rdev...@googlegroups.com
I notice Simon Urbanek posted yesterday that he is looking to build and release an R binary for OS X  with iomp support "possibly as soon as next week"

this might make life a LOT easier!

best, tim
Reply all
Reply to author
Forward
0 new messages