I faced a problem trying to create static wrapper for some of NPP icc functions, to call them from cGo (Golang) environment.
I'm able to create and compile (C language) executable, with provided static NPP libraries, and it works well. Then I compile it as a library (with necessary flags). But when I try to link that library from another executable (plain C or cGo), I get error message "undefined reference to nppiYCbCr420ToRGB_8u_P3C3R". What I'm doing wrong?
wrapper.c
#include <nppi_color_conversion.h>
#include <cuda_runtime_api.h>
int YCbCr420ToRGB() {
NppiSize oSizeROI;
const Npp8u * const pSrc[3];
int cSrcStep[3];
Npp8u *cDst;
NppStatus ret = nppiYCbCr420ToRGB_8u_P3C3R(pSrc, cSrcStep, cDst, 0, oSizeROI);
return (int)ret; // ret = 14
}
build.sh
nvcc nppGo.c -lib -lnppicc_static -lnppc_static -lculibos -lcudart_static -lpthread -ldl -lrt -I /usr/local/cuda-10.0/include -L /usr/local/cuda-10.0/lib64 -o libnppGo
caller.c
#include <stdio.h>
#include "nppGo.h"
int main() {
int ret = YCbCr420ToRGB();
printf("Return code is: %d\n", ret);
return (int)ret;
}
buildtest.sh
nvcc caller.c -L. -lnppGo -o nppGo
Finally I get this error message
./libnppGo.a(tmpxft_0000204d_00000000-2_nppGo.o): In function `YCbCr420ToRGB':
nppGo.c:(.text+0xf9): undefined reference to `nppiYCbCr420ToRGB_8u_P3C3R'
collect2: error: ld returned 1 exit status
I also tried to use another linker/compiler, with same results:
g++ -c nppGo.c -I /usr/local/cuda-10.0/include
ar rcs nppGo.a nppGo.o libnppicc_static.a libnppc_static.a libculibos.a libcudart_static.a libdl.a