Undefined reference to `cuGraphicsEGLRegisterImage'

hi,

I’m writing a DeepStream plugin now. I wish it can work in CUDA. So, I use the function cuGraphicsEGLRegisterImage and cuGraphicsResourceGetMappedEglFrame in c++ code gstdsexample.cpp. The following error prompt appears when compiling:

gstdsexample.cpp:(.text+0x25b4): undefined reference to `cuGraphicsEGLRegisterImage'
gstdsexample.cpp:(.text+0x25c8): undefined reference to `cuGraphicsResourceGetMappedEglFrame'
collect2: error: ld returned 1 exit status
Makefile:78: recipe for target 'libnvdsgst_dsexample.so' failed
make: *** [libnvdsgst_dsexample.so] Error 1

What can I do for this ?

Hi,
Please refer to this post:
How to create opencv gpumat from nvstream? - #18 by DaneLLL

Adding this should resolve the error:

#include <cudaEGL.h>

Thank you very much for your reply!

However, the above error message is generated after adding this header file. I think this error message is generated when linking. The reason should be that the corresponding library file cannot be found. I don’t know which library these two functions should be in. Is the deepstream package I installed incomplete?

Hi,
Please add -lcuda

        -L/usr/local/cuda-$(CUDA_VER)/lib64/ -lcudart -lcuda -ldl \
1 Like

Your answer is wonderful, the problem is solved perfectly, thank you very much!