cstrato
2008-Mar-02 22:02 UTC
[Rd] Problem creating Makefile.win to build package using Visual C++
Dear all, For testing purposes I have created a package "MyClass" containing C++ classes, which runs "R CMD check" on MacOS X and Linux w/o warnings. Now I want to create a Windows binary using MS Visual C++. Using the "Makefile.win" shown below, I can compile the source code with Visual C++ using: >NMAKE /f "Makefile.win" CFG="Release" However, when I modified the $(MYDLL) part to include "MyClass.def", and did: >R CMD INSTALL -l C:/home/CRAN/myRlib MyClass_0.3.2.tar.gz I got the build error: ---------- Making package MyClass ------------ adding build stamp to DESCRIPTION installing NAMESPACE file and metadata running src/Makefile.win ... Makefile.win:3: *** missing separator. Stop. make[2]: *** [srcDynlib] Error 2 make[1]: *** [all] Error 2 make: *** [pkg-MyClass] Error 2 I have tried the following modification to include "MyClass.def": $(MYDLL): $(MYOBJ) $(RLIB) $(MAINR).def $(LD) $(SOFLAGS) $(LDFLAGS) $(MYOBJ) $(OutPutOpt)$@ Please can someone tell me what might be wrong? I know from the readme file that I need to do something like: link /dll /def:mypkg.def /out:mypkg.dll *.obj Rdll.lib but it is not clear to me how to convert this example to my makefile? Thank you in advance Best regards Christian _._._._._._._._._._._._._._._._ C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a V.i.e.n.n.a A.u.s.t.r.i.a e.m.a.i.l: cstrato at aon.at _._._._._._._._._._._._._._._._ Makefile.win (adapted from another program): !IF "$(CFG)" != "Release" && "$(CFG)" != "Debug" !MESSAGE Invalid configuration "$(CFG)" specified. !ENDIF ObjSuf = obj SrcSuf = cxx ExeSuf = .exe DllSuf = dll OutPutOpt = -out: # Win32 system with Microsoft Visual C/C++ !include <win32.mak> CC = $(cc) CXX = $(cc) CXXFLAGS = $(cvarsdll) -EHsc -nologo -GR -DWIN32 \ -DVISUAL_CPLUSPLUS -D_WINDOWS LD = $(link) !IF "$(CFG)" == "Release" CXXOPT = -O2 -MD LDOPT = -opt:ref !ELSEIF "$(CFG)" == "Debug" CXXOPT = -Z7 -MDd LDOPT = -debug !ENDIF !if ("$(_NMAKE_VER)" == "8.00.50727.42") || ("$(_NMAKE_VER)" == "8.00.50727.762") || ("$(_NMAKE_VER)" == "9.00.21022.08") MT_EXE = mt -nologo -manifest $@.manifest -outputresource:$@;1 MT_DLL = mt -nologo -manifest $@.manifest -outputresource:$@;2 EXTRAFLAGS = -D_CRT_SECURE_NO_DEPRECATE !else MT_EXE MT_DLL EXTRAFLAGS = -G5 !endif LDFLAGS = $(LDOPT) $(conlflags) -nologo SOFLAGS = $(dlllflags:-pdb:none=) #------------------------------------------------------------------------------ R_HOME = C:\\PROGRA~1\\R\\R-2.6.2 R_INCLUDES = $(R_HOME)\\include RLIB = $(R_HOME)\\src\\gnuwin32\\Rdll.lib #------------------------------------------------------------------------------ MAIN = MyClassA MAINR = MyClass MYHDR = $(MAIN).h rwrapper.h MYOBJ = $(MAIN).$(ObjSuf) rwrapper.$(ObjSuf) MYSRC = $(MAIN).$(SrcSuf) rwrapper.$(SrcSuf) MYDLL = $(MAINR).$(DllSuf) OBJS = $(MYOBJ) PROGRAMS = $(MYDLL) all: $(PROGRAMS) $(MYDLL): $(MYOBJ) $(LD) $(SOFLAGS) $(LDFLAGS) $(MYOBJ) $(OutPutOpt)$@ $(MT_DLL) $(MAIN).$(ObjSuf): $(MYHDR) .$(SrcSuf).$(ObjSuf): $(CXX) $(CXXFLAGS) $(EXTRAFLAGS) $(CXXOPT) -c $< clean: @del *.obj *.def *.exp *.d *.log .def *.pdb *.ilk *.manifest distclean: clean @del *.exe *.ps *.lib *.dll