[R-pkg-devel] Package Load fails to find 3rd Party DLL
? Wed, 12 Jul 2023 09:41:11 -0400 Russell Almond <russell.g.almond at gmail.com> ?????:
? C:\rtools43\x86_64-w64-mingw32.static.posix\bin\nm.exe: 'NeticaDLL': No such file
This is where the problem starts. You can retrace the steps that R takes when building and installing the package by running sh configure.win manually and then running something like R_PACKAGE_DIR="$(pwd)" R CMD SHLIB -n *.c in the src subdirectory of the package. That will in turn tell you the exact command lines to be run while building your package, including the following: nm Cases.o Continuous.o Edges.o Experience.o Inference.o Networks.o \ Node.o Random.o Registration.o Session.o NeticaDLL \ | sed -n 's/^.* [BCDRT] / /p' \ | sed -e '/[.]refptr[.]/d' -e '/[.]weak[.]/d' \ | sed 's/[^ ][^ ]*/"&"/g' \ >> tmp.def; That "NeticaDLL" at the end of the list of object files doesn't belong there. I think it gets added because it's among the dependencies of the $(SHLIB) Make target. It would be best to make that target a real object file that nm.exe can process. Otherwise, you could also write your own .def file and skip its automatic generation. After nm fails, you get a crash in the linker (while parsing the resulting incomplete .def file?), which leaves your package without a shared library to use:
C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: internal error: aborting at ../../binutils-2.40/ld/ldlang.c:527 in compare_section C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: please report this bug
There must be a way to streamline this process. Maybe put all the library-downloading and extraction code into a portable tools/configure.R (to be launched manually from the configure shell script), leaving src/Makevars only to compile your own code, link with Netica using PKG_LIBS, then copy the additional Netica DLL from a custom install.libs.R file?
Best regards, Ivan