2

I am using a Window 32-bit machine to compile an R package developed using Rcpp and compiled with Rtools 3.4 in RStudio 1.0.28. I keep getting an error about the @ signs within the 32-bit external dll (NYCgeo.dll):

thefile.o:thefile.cpp:(.text+0x913): undefined reference to `_imp__NYCgeo@8' collect2.exe: error: ld returned 1 exit status

Sure enough, when I opened the 32-bit NYCgeo.dll in a text editor, I found @8 suffix. This is weird because when I developed the 64-bit version, the 64-bit NYCgeo.dll did not contain @8 suffix and I did not have any errors. Anyway, I read about the --kill-at command and was wondering where I would include it. I tried RStudio's Configure Build Tools settings as well as my makevars.win.in file but had no luck.

Response to @Dirk

  1. Updated title as requested.
  2. I am compiling the package from within RStudio using Rtools so I assumed it might have something to do with RStudio's Project Options.
  3. I have spent the past week checking existing documentation. This post, this post, and this post describe the issue I am having. My issue is that I do not know where to specify either "--kill-at" or "--add-stdcall-alias"
  4. The whole point of my package is to leverage NYC Dept of City Planning's geocoding software. I did not "just throw" the binary NYCgeo.dll "into the mix." In fact, my 64-bit version of the package works fine. My issue is with developing the 32-bit version... specifically, the presence of an @8 suffix in the NYCgeo.dll binary which is causing an error.
  5. NYCgeo.dll is a C binary. I am not using Visual Studio.
  6. The previous question you mentioned dealt with creating Makevars files for the 64-bit version of my package (thanks again, @Coatless for providing useful information). The 64-bit NYCgeo.dll binary did not contain an @8 suffix.

UPDATE: I tried to create a better title for this question. The question pertains to creating an R package which utilizes functionality from another piece of software... in my case, geocoding software. Specifically, the issue I experienced is that the 32-bit version of the geocoding software has a decorated dll files while the 64-bit version does not. A decorated binary contains @ symbols which trigger an error during compiling. My task was to devise a way to demangle (not sure if that is a real word) the 32-bit dll but leave the 64-bit dll alone.

Many thanks.

Gretchen

Community
  • 1
  • 1
gmculp
  • 135
  • 1
  • 10
  • Thanks for expanding the question. You should have come to the `rcpp-devel` mailing list: low volume, mostly patient replies, more Rcpp users than here. Your problem is a _hard_ one. – Dirk Eddelbuettel Sep 30 '16 at 20:55
  • That said, for a [similar package around a given dll](https://github.com/Rblp/Rblpapi/) I used two upstream DLLs, one each for 32 and 64 bit. – Dirk Eddelbuettel Sep 30 '16 at 20:56

1 Answers1

3

The rJava package was incredibly helpful in understanding how to deal with decorated binaries.

I created a def file named NYCgeo.def and saved it in my src directory:

LIBRARY     NYCGEO.DLL

EXPORTS
    NYCgeo@8

I then updated my Makevars.win.in file which is also in my src directory:

GBAT_PATH = @GBAT_PATH@
GBAT_DLL = @GBAT_DLL@

PKG_LIBS =  -L"$(GBAT_PATH)/Bin" -l$(GBAT_DLL)
PKG_CPPFLAGS =  -I"$(GBAT_PATH)/Include"


ifeq "${R_ARCH}" "/i386"
  $(SHLIB): $(OBJECTS) NYCGEO.a

  NYCGEO.a: NYCGEO.def
    $(DLLTOOL) -k -d NYCGEO.def -l NYCGEO.a -D "$(GBAT_PATH)/Bin/$(GBAT_DLL)" $(DT_ARCH)
endif

I am now able to compile the package on both 32-bit and 64-bit machines running Windows.

gmculp
  • 135
  • 1
  • 10