Reputation: 11
I am trying to use R CMD SHLIB for a C program written using Lapack and Blas. I am using the command prompt in Windows. But it seems unable to link to the external libraries. How can I link these libraries?
D:\R\testR>Rcmd SHLIB fmpc.c
c:/Rtools/mingw_64/bin/gcc -shared -s -static-libgcc -o fmpc.dll tmp.def fmpc.o
-Ld:/Compiler/gcc-4.9.3/local330/lib/x64 -Ld:/Compiler/gcc-4.9.3/local330/lib -L
D:/R/R-3.3.2/bin/x64 -lR
fmpc.o:fmpc.c:(.text+0x76d): undefined reference to `dposv_'
fmpc.o:fmpc.c:(.text+0x800): undefined reference to `dtrtrs_'
fmpc.o:fmpc.c:(.text+0x83b): undefined reference to `dtrtrs_'
fmpc.o:fmpc.c:(.text+0x92f): undefined reference to `dposv_'
fmpc.o:fmpc.c:(.text+0x9bf): undefined reference to `dtrtrs_'
fmpc.o:fmpc.c:(.text+0x9fa): undefined reference to `dtrtrs_'
fmpc.o:fmpc.c:(.text+0xb19): undefined reference to `dgemm_'
Upvotes: 1
Views: 862
Reputation: 368647
You have a linker error and not a compiler error. The compilation step passed fine.
Solution: Tell R to link against the missing library, most by adding a file src/Makevars.win
with the following:
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
It is a variable declaration using other variable which R knows.
Upvotes: 1