Search code examples
gcccudastatic-librariesdynamic-library

The static library are included, but still link to dynamic library in same name at runtime


I am using nvcodec sdk (https://developer.nvidia.com/nvidia-video-codec-sdk) and use its linux static library in my project.

I added the compile option in gcc with

gcc myprogram.c  NvCodec/Lib/linux/stubs/x86_64/libnvcuvid.so

However, when running the program,

./bin/a.out: symbol lookup error: ./bin/a.out: undefined symbol: cuvidGetDecodeStatus

I found that the symbol cuvidGetDecodeStatus is actually in NvCodec/Lib/linux/stubs/x86_64/libnvcuvid.so.

And by

nm a.out

the symbol is included in the program.

so I tried

ldd a.out

I found it's linked to nvidia driver with same name.

libnvcuvid.so.1 => /usr/lib/nvidia-384/libnvcuvid.so.1 

I can't modify the LD_LIBRARY_PATH to modify the search order since NvCodec is a static library.

I have no idea why it's linked to the nvidia driver library even I don't add link option (like -lnvcuvid)

And idea?

thank you


Solution

  • as @Robert Crovella said,

    this is an issue for an outdated driver. the library in the cuda codec sdk is actually a stub, which points to the cuda driver shared library.

    And there is no symbol like cuvidGetDecodeStatus in the nvidia-384 driver library.

    after update nvidia-384 to nvidia-396, the problem solved.