0

I am very new to programming and having difficulties with creating packages in R. I'm trying to make source codes in Fortran to help me build a R package. I wrote a program in Fortran which gives me a simple epidemic, later I wrapped it as a subroutine to call from R. Now when I compile the wrapper to make it as .so file, it gives the following error.

$ R CMD SHLIB random_epi.f95

Error:

gfortran-4.8 -fPIC -Wall -g -O2 -c random_epi.f95 -o random_epi.o make: gfortran-4.8: No such file or directory make: *** [random_epi.o] Error 1

I'm using a Mac OS X El Capitan and gfortran 6.1. I have searched a lot, but couldn't find a solution. I would really appreciate any help to resolve my issue.

Vineetha
  • 157
  • 1
  • 2
  • 13
  • Possible duplicate of [Mac OS X R error "ld: warning: directory not found for option"](http://stackoverflow.com/questions/35999874/mac-os-x-r-error-ld-warning-directory-not-found-for-option) – coatless Jun 07 '16 at 18:46
  • You are using `gfortran-6.1` while the error message states that the system cannot find `gfortran-4.8`. I don't know much about creating packages, but I'd suspect that you need to correct a compiler flag in the Makefile and specify that either `gfortran` or `gfortran-6.1` should be used, and not `gfortran-4.8`. – RHertel Jun 07 '16 at 18:49
  • OS X uses `.dylib` for libraries, not `.so` ... – l'L'l Jun 07 '16 at 18:50
  • @RHertel : I download R from home brew and it automatically shows fortran 4.8 – Vineetha Jun 07 '16 at 18:53
  • What is the output of `otool -L random_epi.f95`? – l'L'l Jun 07 '16 at 18:55
  • @I'L'I I just wrote R CMD SHLIB and it showing .so How can I change to .dylib? The output says random_epi.f95: is not an object file – Vineetha Jun 07 '16 at 18:56
  • `.so` might still work (as they are somewhat interchangeable), although `.dylib` is the native OS X format for dynamic (shared) libs. – l'L'l Jun 07 '16 at 18:58
  • I don't know, sorry. Maybe take a look at the use of [Makevars](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Using-Makevars). I strongly suspect that it's an incompatibility of the compiler versions, but there are certainly more knowledgeable users on this topic that can guide you in the right direction. – RHertel Jun 07 '16 at 19:02
  • I think the problem is in your compile command as it's showing `make` on the end of it; The error shows that OS X thinks it's referring to another file, not a command. If it's the `Makefile` you are targeting (?) then try using that instead, or remove `make` off the end. – l'L'l Jun 07 '16 at 19:07
  • Thanks all. I still have the issue. need another direction. – Vineetha Jun 07 '16 at 21:27
  • I reinstalled everything and tried. The issue seems to be resolved now. http://stackoverflow.com/questions/37753941/os-x-package-installation-issue-cant-find-gfortran-4-8-to-build-package – Vineetha Jun 14 '16 at 19:07

1 Answers1

0

Solved the issue by adding few lines in the Makevar file. Refer:

OS X package installation issue: Can't find gfortran 4.8 to build package

Community
  • 1
  • 1
Vineetha
  • 157
  • 1
  • 2
  • 13