Skip to content

a package installation problem on windows

2 messages · Gang Liang, Brian Ripley

#
Dear all,

I encountered a problem when test installing a package of my own under
the windows platform. The latest Rtools is installed, and Makefile.win
is used for directing the compilation of C++ codes under the src
directory. A sketch of the Makefile.win is as follows:

--- Makefile.win (old) ---------
all: part1.dll part2.dll

%.dll: %.cpp
	R CMD SHLIB $<
---------------------------------------

When I run "R CMD build --binary pakname", the Makefile.win is
executed without error, but to my surprise, the wanted dll files are
not produced as expected; thus, the binary package will be created
without dlls. While if I run make in the src directory manually, all
dll files will be created. This problem can be by-passed using my
updated Makefile.win,

--- Makefile.win (new) ---------
all: part1.dll part2.dll copy

%.dll: %.cpp
	R CMD SHLIB $<

copy: part1.dll part2.dll
	mkdir -p ../inst/libs
	cp *.dll ../inst/libs
---------------------------------------

It is ugly because I have to access the libs directory directly. My
question is what is the right syntax to compile codes using Makefile
then? Thanks very much!

Gang Liang

PS: Re the missing dll problem, my guess is that the command "R CMD
SHLIB ..." is doing the compilation on a memory disk, and the final
result is discarded right away. I even interrupted the compilation
midway, and am still not able to find any intermediate files on my
harddrive. On the other hand, the compilation is clearly done.
#
Nothing in the documentation says that DLLs created in the source 
directory will be installed -- this applies only to pkgname.dll.

We recommend you use R CMD INSTALL [--build], not R CMD build --binary.

It is very rare to need a src/Makefile.win, but it you choose to use one 
yo do need to ensure that you do understand the package installation 
mechanism.  Being surprised that undocumented things do not work is a sure 
sign that you have not studied the mechanism and documentation.
On Mon, 28 Jul 2008, Gang Liang wrote: