diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index 0ed43fc52..e8cee6448 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -56,28 +56,48 @@ example.c is the name of the file with the functions in them
 swig -r example.i
-PKG_LIBS="example.c" R CMD SHLIB example_wrap.c
+R CMD SHLIB example_wrap.c example.c
 

-The corresponding comments for C++ mode are +The corresponding options for C++ mode are

 swig -c++ -r -o example_wrap.cpp example.i
-PKG_LIBS="example.cxx" R CMD SHLIB example_wrap.cpp
+R CMD SHLIB example_wrap.cpp example.cpp
 

-Note that R is sensitive to the name of the file and to the file -extension in C and C++ mode. The name of the wrapper file must be the -name of the library. Also in C++ mode, the file extension must be .cpp -rather than .cxx for the R compile command to recognize it. +Note that R is sensitive to the names of the files. +The name of the wrapper file must be the +name of the library unless you use the -o option to R when building the library, for example:

+
+
+swig -c++ -r -o example_wrap.cpp example.i
+R CMD SHLIB -o example.so example_wrap.cpp example.cpp
+
+
+ +

+R is also sensitive to the name of the file +extension in C and C++ mode. In C++ mode, the file extension must be .cpp +rather than .cxx for the R compile command to recognize it. If your C++ code is +in a file using something other than a .cpp extension, then it may still work using PKG_LIBS: +

+ +
+
+swig -c++ -r -o example_wrap.cpp example.i
+PKG_LIBS="example.cxx" R CMD SHLIB -o example example_wrap.cpp
+
+
+

The commands produces two files. A dynamic shared object file called example.so, or example.dll, and an R wrapper file called example.R. To load these diff --git a/Examples/Makefile.in b/Examples/Makefile.in index cb8b7f4d4..9dee0347f 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1129,11 +1129,11 @@ RRSRC = $(INTERFACE:.i=.R) r: $(SRCS) $(SWIG) -r $(SWIGOPT) $(INTERFACEPATH) - +( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -fPIC -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) ) + +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(SRCS) ) r_cpp: $(CXXSRCS) $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH) - +( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -fPIC -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) ) + +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(SRCS) $(CXXSRCS)) r_clean: rm -f *_wrap* *~ .~* diff --git a/Examples/r/class/Makefile b/Examples/r/class/Makefile index 6bed3ce53..0cd8ed3d3 100644 --- a/Examples/r/class/Makefile +++ b/Examples/r/class/Makefile @@ -3,16 +3,13 @@ SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i -LIBS = -lm -ARGS = SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r_cpp clean:: - $(MAKE) -f $(TOP)/Makefile $(ARGS) r_clean + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' r_clean check: all R CMD BATCH runme.R diff --git a/Examples/r/simple/Makefile b/Examples/r/simple/Makefile index e01d35925..5ef29565a 100644 --- a/Examples/r/simple/Makefile +++ b/Examples/r/simple/Makefile @@ -3,14 +3,13 @@ SWIG = $(TOP)/../preinst-swig SRCS = example.c TARGET = example INTERFACE = example.i -ARGS = SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' all:: - $(MAKE) -f $(TOP)/Makefile $(ARGS) r + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r clean:: - $(MAKE) -f $(TOP)/Makefile $(ARGS) r_clean + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' r_clean check: all R CMD BATCH runme.R