Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在ubuntu中使用cuda编译opencv的makefile停止工作_Ubuntu_Opencv_Makefile_Cuda - Fatal编程技术网

在ubuntu中使用cuda编译opencv的makefile停止工作

在ubuntu中使用cuda编译opencv的makefile停止工作,ubuntu,opencv,makefile,cuda,Ubuntu,Opencv,Makefile,Cuda,我试图在我的笔记本电脑上编译一个项目,其中我需要CUDA和opencv。 所以我创建了3个文件 main.cpp kernel.cu kernel.h 在main.cpp中我有opencv代码,在kernel.cu中我有我的内核。 我正在使用在另一个项目中找到的此makefile: CXX=g++ CUDA_INSTALL_PATH=/usr/local/cuda CFLAGS= -I. -I$(CUDA_INSTALL_PATH)/include `pkg-config --cflags op

我试图在我的笔记本电脑上编译一个项目,其中我需要CUDA和opencv。 所以我创建了3个文件

main.cpp

kernel.cu

kernel.h

在main.cpp中我有opencv代码,在kernel.cu中我有我的内核。 我正在使用在另一个项目中找到的此makefile:

CXX=g++
CUDA_INSTALL_PATH=/usr/local/cuda
CFLAGS= -I. -I$(CUDA_INSTALL_PATH)/include `pkg-config --cflags opencv`
LDFLAGS= -L$(CUDA_INSTALL_PATH)/lib64 -lcudart `pkg-config --libs opencv`

all:
    $(CXX) $(CFLAGS) -c main.cpp -o main.o
    nvcc $(CUDAFLAGS) -arch="sm_21" -c kernel.cu -o kernel.o
    $(CXX) $(LDFLAGS) main.o kernel.o -o main
我曾在另一台使用opencv 2.4.2、CUDA 4.0和gcc 4.4的计算机上尝试过相同的项目,效果很好,但现在我在笔记本电脑上使用opencv 2.4.2、CUDA 4.2和gcc 4.6进行了尝试,它不断返回最后一行的错误,但它确实创建了main.o和kernel.o,如果我注释掉最后一行,它不会给出错误

我已经构建并运行了opencv和cuda sdk示例,它们分别工作得很好。 你能帮我吗

以下是它的回报:

g++-L/usr/local/cuda/lib64-lcudart
pkg-config--libs opencv
main.o kernel\u gpu.o-o灰度

main.o:在函数“main”中:

main.cpp:(.text+0x44):对“cv::imread(std::basic_string,std::allocator>const&,int)”的未定义引用

main.cpp:(.text+0x72):对“cv::\u InputArray::\u InputArray(cv::Mat const&)”的未定义引用

main.cpp:(.text+0xa6):未定义对“cv::imshow(std::basic_string,std::allocator>const&,cv:_inputarrayconst&)”的引用

main.cpp:(.text+0xc8):对“cv::waitKey(int)”的未定义引用

main.o:在函数“cv::Mat::~Mat()”中:

main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39):未定义对“cv::fastFree(void*)”的引用

main.o:在函数'cv::Mat::release()'中:

main.cpp:(.text._ZN2cv3Mat7releaseEv[cv::Mat::release()]+0x47):未定义对“cv::Mat::deallocate()”的引用

kernel_gpu.o:在函数
cuda_BGsub'中:
tmpxft_000016bc_00000000-1_内核_gpu.cudafe1.cpp:(.text+0x41):对
cudaConfigureCall'的未定义引用

kernel_gpu.o:在函数
cuda_grayscale'中:
tmpxft_000016bc_00000000-1_内核_gpu.cudafe1.cpp:(.text+0xb3):未定义对
cudaConfigureCall'

kernel_gpu.o:在函数
cuda_Filter'中:
tmpxft_000016bc_00000000-1_内核_gpu.cudafe1.cpp:(.text+0x10d):对
cudaconfig调用的未定义引用

内核\u gpu.o:在函数
cuda\u Noise\u reduce'中:
tmpxft_000016bc_00000000-1_内核_gpu.cudafe1.cpp:(.text+0x176):未定义对
cudaConfigureCall'

kernel_gpu.o:在函数
cuda_RGB'中:
tmpxft_000016bc_00000000-1_内核_gpu.cudafe1.cpp:(.text+0x1d9):未定义对
cudaConfigureCall'

kernel_gpu.o:tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x234):下面是对“cudaConfigureCall”的更多未定义引用

kernel_gpu.o:在函数`\uu cudaUnregisterBinaryUtil()中:

tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x409):对`u cudaUnregisterFatBinary'的未定义引用

kernel_gpu.o:在函数`u设备`存根`u Z5BGsubPhS_siib(无符号字符*,无符号字符*,无符号字符*,int,int,bool)`:

tmpxft_000016bc_00000000-1_内核_gpu.cudafe1.cpp:(.text+0x442):对“cudaSetupArgument”的未定义引用

tmpxft_000016bc_00000000-1_内核_gpu.cudafe1.cpp:(.text+0x465):对“cudaSetupArgument”的未定义引用

tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x488):对“cudaSetupArgument”的未定义引用

tmpxft_000016bc_00000000-1_内核_gpu.cudafe1.cpp:(.text+0x4a7):对“cudaSetupArgument”的未定义引用

tmpxft_000016bc_00000000-1_内核_gpu.cudafe1.cpp:(.text+0x4c6):对“cudaSetupArgument”的未定义引用

kernel_gpu.o:tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x4e5):下面是对“cudaSetupArgument”的更多未定义引用

kernel\u gpu.o:在函数`sti\u\u cudaRegisterAll\u 45\u tmpxft\u 000016bc\u 00000000\u 4\u kernel\u gpu\u cpp1\u ii\u cdcb70e()中:

tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0xe7e):对`u cudaRegisterFatBinary'的未定义引用

tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0xedc):对`u cudaRegisterFunction'的未定义引用

tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0xf29):对`u cudaRegisterFunction'的未定义引用

tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0xf76):对`u cudaRegisterFunction'的未定义引用

tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0xfc3):对`u cudaRegisterFunction'的未定义引用

tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x1010):对`u cudaRegisterFunction'的未定义引用

kernel_gpu.o:tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x105d):下面是对`u cudaRegisterFunction'的更多未定义引用

kernelgpu.o:在函数“cudaError cudaLaunch(char*)”中:

tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text.z10cudalunchece9cudaerrorpt[cudaError cudaLaunch(char*)]+0x14):对“cudaLaunch”的未定义引用

collect2:ld返回了1个退出状态

make:[全部]错误1

编辑: 此版本适用于:

CXX=g++
CUDA_INSTALL_PATH=/usr/local/cuda
CFLAGS= -I. -I$(CUDA_INSTALL_PATH)/include `pkg-config --cflags opencv`
LDFLAGS= -L$(CUDA_INSTALL_PATH)/lib64 -lcudart `pkg-config --libs opencv`

all:
    $(CXX) $(CFLAGS) -c main.cpp -o main.o
    nvcc $(CUDAFLAGS) -arch="sm_21" -c kernel.cu -o kernel.o
    $(CXX)  main.o `pkg-config --libs opencv` -L$(CUDA_INSTALL_PATH)/lib64 -lcudart kernel.o -o main

你能试着把所有的-l选项放在kernel.o后面吗


致以最良好的祝愿

塔克斯!成功了。我在问题的末尾加上了工作题。