[R-pkg-devel] Package Load fails to find 3rd Party DLL

Russell Almond ru@@e||@g@@|mond @end|ng |rom gm@||@com
Fri Jul 14 19:29:32 CEST 2023


Thanks.  I know know the problem is in the Makevars.win; however, I'm 
still confused.

My `Makevars.win` had

| .PHONY:   all NeticaDLL clean

| all: $(SHLIB)
| $(SHLIB): NeticaDLL
|
| NeticaDLL:
|    mkdir -p "$(INSTALL_LIB)"
|    cp "${NETICA_LIB}/Netica.dll" "${INSTALL_LIB}"
|    cp "${NETICA_LIB}/Netica.lib" "${INSTALL_LIB}"

[BTW, I tried change this to

| all: NeticaDLL $(SHLIB)

and got the same problem.]

This looks very much like the `mylibs` example in 
https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Using-Makevars

So I'm confused.  Why is the Makevars -> Makefile conversion assuming 
that all targets of $(SHLIB) (or all) are executable files, ignoring the 
PHONY declaration?

Also, does the example in the Writing R Extensions manual still work?

     --Russell



On 7/14/23 11:14 AM, Ivan Krylov wrote:
> В Wed, 12 Jul 2023 09:41:11 -0400
> Russell Almond<russell.g.almond using 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?
>
-- 
Russell Almond
https://ralmond.net/

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list