You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu16.04下使用NPP库编译程序时出现nppiMalloc_8u_C1未定义引用错误

Fixing Undefined Reference Errors for NPP Functions in Ubuntu 16.04

Hey there, let's sort out that frustrating undefined reference error you're hitting with functions like nppiMalloc_8u_C1 when compiling with nvcc.

The Root Cause

Your current command uses -L to tell nvcc where to look for libraries, but you haven't actually specified which NPP libraries to link against. The compiler knows the path to the libraries, but it doesn't know which ones contain the functions your code uses—hence the "undefined reference" messages.

The Solution

You need to add -l flags for the specific NPP libraries that include the functions you're calling. For nppiMalloc_8u_C1, this function lives in the nppig library (NPP Image Geometry module). Here's the corrected compile command:

nvcc -L/home/usr/local/cuda-9.0/targets/x86_64-linux/lib -lnppig -lnppc main.cu

A quick breakdown of the flags:

  • -L: Specifies the directory where nvcc should search for library files (you already had this right)
  • -lnppig: Links against the libnppig.so library (nvcc automatically adds the lib prefix and .so suffix)
  • -lnppc: Links against the core NPP library, which is often a dependency for other NPP modules

Extra Tips

  • If your code uses other NPP functions (like image filtering, arithmetic operations, etc.), you'll need to add the corresponding library flags. For example:
    • Image arithmetic: -lnppial
    • Image filtering: -lnppif
    • Color conversion: -lnppicc
  • To confirm which library contains a specific function, use this command (replace the library path and function name as needed):
    nm -D /home/usr/local/cuda-9.0/targets/x86_64-linux/lib/libnppig.so | grep nppiMalloc
    
    This will show you if the function exists in that library.

内容的提问来源于stack exchange,提问作者Tuğrul Görgülü

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:25:42