Note that there are some explanatory texts on larger screens.

plurals
  1. POmakefile to compile opencv with cuda in ubuntu stopped working
    primarykey
    data
    text
    <p>I am trying to compile a project on my laptop in which I need both CUDA and opencv. So I have created 3 files</p> <p>main.cpp</p> <p>kernel.cu</p> <p>kernel.h</p> <p>In main.cpp I have opencv codes and in kernel.cu I have my kernels. I am using this makefile that I found in another project:</p> <pre><code>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 </code></pre> <p>I had tried the same project on another computer with opencv 2.4.2 ,CUDA 4.0 and gcc 4.4 and it worked fine but now that I try it on my laptop with opencv 2.4.2 ,CUDA 4.2 and gcc 4.6 it keeps returning errors for the last line but it does create main.o and kernel.o and if I comment out the last line it doesn't give error.</p> <p>I have built and ran both opencv and cuda sdk samples and they worked fine separately. Can you help me?</p> <p>Here is what it returns:</p> <blockquote> <p>g++ -L/usr/local/cuda/lib64 -lcudart <code>pkg-config --libs opencv</code> main.o kernel_gpu.o -o grayscale</p> <p>main.o: In function `main':</p> <p>main.cpp:(.text+0x44): undefined reference to `cv::imread(std::basic_string, std::allocator > const&amp;, int)'</p> <p>main.cpp:(.text+0x72): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&amp;)'</p> <p>main.cpp:(.text+0xa6): undefined reference to `cv::imshow(std::basic_string, std::allocator > const&amp;, cv::_InputArray const&amp;)'</p> <p>main.cpp:(.text+0xc8): undefined reference to `cv::waitKey(int)'</p> <p>main.o: In function `cv::Mat::~Mat()':</p> <p>main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)'</p> <p>main.o: In function `cv::Mat::release()':</p> <p>main.cpp:(.text._ZN2cv3Mat7releaseEv[cv::Mat::release()]+0x47): undefined reference to `cv::Mat::deallocate()'</p> <p>kernel_gpu.o: In function <code>cuda_BGsub': tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x41): undefined reference to</code>cudaConfigureCall'</p> <p>kernel_gpu.o: In function <code>cuda_grayscale': tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0xb3): undefined reference to</code>cudaConfigureCall'</p> <p>kernel_gpu.o: In function <code>cuda_Filter': tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x10d): undefined reference to</code>cudaConfigureCall'</p> <p>kernel_gpu.o: In function <code>cuda_Noise_reduc': tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x176): undefined reference to</code>cudaConfigureCall'</p> <p>kernel_gpu.o: In function <code>cuda_RGB': tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x1d9): undefined reference to</code>cudaConfigureCall'</p> <p>kernel_gpu.o:tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x234): more undefined references to `cudaConfigureCall' follow</p> <p>kernel_gpu.o: In function `__cudaUnregisterBinaryUtil()':</p> <p>tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x409): undefined reference to `__cudaUnregisterFatBinary'</p> <p>kernel_gpu.o: In function `__device_stub__Z5BGsubPhS_S_iib(unsigned char*, unsigned char*, unsigned char*, int, int, bool)':</p> <p>tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x442): undefined reference to `cudaSetupArgument'</p> <p>tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x465): undefined reference to `cudaSetupArgument'</p> <p>tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x488): undefined reference to `cudaSetupArgument'</p> <p>tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x4a7): undefined reference to `cudaSetupArgument'</p> <p>tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x4c6): undefined reference to `cudaSetupArgument'</p> <p>kernel_gpu.o:tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x4e5): more undefined references to `cudaSetupArgument' follow</p> <p>kernel_gpu.o: In function `<strong>sti_</strong>_cudaRegisterAll_45_tmpxft_000016bc_00000000_4_kernel_gpu_cpp1_ii_cdcbb70e()':</p> <p>tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0xe7e): undefined reference to `__cudaRegisterFatBinary'</p> <p>tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0xedc): undefined reference to `__cudaRegisterFunction'</p> <p>tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0xf29): undefined reference to `__cudaRegisterFunction'</p> <p>tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0xf76): undefined reference to `__cudaRegisterFunction'</p> <p>tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0xfc3): undefined reference to `__cudaRegisterFunction'</p> <p>tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x1010): undefined reference to `__cudaRegisterFunction'</p> <p>kernel_gpu.o:tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text+0x105d): more undefined references to `__cudaRegisterFunction' follow</p> <p>kernel_gpu.o: In function `cudaError cudaLaunch(char*)':</p> <p>tmpxft_000016bc_00000000-1_kernel_gpu.cudafe1.cpp:(.text.<em>Z10cudaLaunchIcE9cudaErrorPT</em>[cudaError cudaLaunch(char*)]+0x14): undefined reference to `cudaLaunch'</p> <p>collect2: ld returned 1 exit status</p> <p>make: <em>*</em> [all] Error 1</p> </blockquote> <p><strong>EDIT:</strong> This version works:</p> <pre><code>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 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload