Open guozhizou opened 8 years ago
It seems that your compiler or R might not have been set up properly. Would you please try whether you can properly compile any C code using R CMD SHLIB?
Many thanks! Bee-Chung
It works well using R CMD SHLIB to compile C code.
Appreciated! guozhi.zou
Could you copy paste the output of a successful run of R CMD SHLIB of any C code? Could you try R CMD SHLIB src/C/util.c?
nalideMacBook-Pro:C nali$ R CMD SHLIB util.c clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o util.so util.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
It runs well with R CMD SHLIB src/C/util.c
Thanks! guozhi.zou
It's so weird! I can compile util.c or factor_model_util.c under directory src/C, but it got a error when Under root directory.
Got it! Editing R Makeconf to specify your own compiler directory.
Hi @xinyuwuhenZZ , I got the same issue compiling C in Terminal Program. Would you mind expanding a bit more how you sorting out this error?
I edited R Makeconf (/Library/Frameworks/R.framework/Versions/3.3/Resources/etc/Makeconf ) to my own gcc name (CC = gcc-5 )
Good luck!
I am not sure what I did wrong - I tried compiling the program under directory src/C, it runs well. Yet, it doesn't work under top level directory (following is error shown up from the Terminal:)
ld: warning: directory not found for option '-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [lib/c_funcs.so] Error 1
make: *** [c_funcs] Error 1
i have made changes in R makeconf from like
# configure
...
'CC=clang' 'CXX=clang++' 'OBJC=clang' 'F77=gfortran-4.8' 'FC=gfortran-4.8' 'CFLAGS=-Wall -mtune=core2 -g -O2' 'CXXFLAGS=-Wall -mtune=core2 -g -O2' 'OBJCFLAGS=-Wall -mtune=core2 -g -O2' 'FCFLAGS=-Wall -g -O2' 'F77FLAGS=-Wall -g -O2' '--with-system-zlib' '--enable-memory-profiling' 'CPPFLAGS=-I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include' '--x-libraries=/opt/X11/lib' '--x-includes=/usr/local/include' '--enable-R-framework'/
....
CC = clang
to become as follows
# configure
...
'CC=gcc-6.1.0' 'CXX=clang++' 'OBJC=clang' 'F77=gfortran-4.8' 'FC=gfortran-4.8' 'CFLAGS=-Wall -mtune=core2 -g -O2' 'CXXFLAGS=-Wall -mtune=core2 -g -O2' 'OBJCFLAGS=-Wall -mtune=core2 -g -O2' 'FCFLAGS=-Wall -g -O2' 'F77FLAGS=-Wall -g -O2' '--with-system-zlib' '--enable-memory-profiling' 'CPPFLAGS=-I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include' '--x-libraries=/opt/X11/lib' '--x-includes=/usr/local/include' '--enable-R-framework'/
....
CC = gcc-6.1.0
Yet it still could not compile the C program. This is my setup gcc:
gcc: stable 6.1.0 (bottled), HEAD
GNU compiler collection
https://gcc.gnu.org
and my systems :
ProductName: Mac OS X
ProductVersion: 10.11.1
BuildVersion: 15B42
CXX=gcc++-6.1.0
finally thanks @xinyuwuhenZZ , it did work now. Really appreciate ur help!
Hi, Follow the tutorial and I got this issue:
R CMD SHLIB src/C/util.c src/C/factor_model_util.c src/C/pagerank.c src/C/hierarchical.c src/C/factor_model_multicontext.c src/C/factor_model_util2.cpp -o lib/c_funcs.so clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o lib/c_funcs.so src/C/util.o src/C/factor_model_util.o src/C/pagerank.o src/C/hierarchical.o src/C/factor_model_multicontext.o src/C/factor_model_util2.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm -Wall -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation ld: warning: directory not found for option '-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2' ld: library not found for -lgfortran clang: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: * [lib/c_funcs.so] Error 1 make: * [c_funcs] Error 1
Thanks!