Compile Error after Install on Ubuntu with CUDA
I installed OpenCV on Ubuntu with CUDA with this guide:
https://gist.github.com/raulqf/f42c71...
However when I try to compile the program:
#include <iostream>
#include <ctime>
#include <cmath>
#include "bits/time.h"
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/core/cuda.hpp>
#include <opencv2/cudaarithm.hpp>
#include <opencv2/cudaimgproc.hpp>
#define TestCUDA true
int main() {
std::clock_t begin = std::clock();
try {
cv::String filename = "/home/raul/Pictures/Screenshot_20170317_105454.png";
cv::Mat srcHost = cv::imread(filename, cv::IMREAD_GRAYSCALE);
for(int i=0; i<1000; i++) {
if(TestCUDA) {
cv::cuda::GpuMat dst, src;
src.upload(srcHost);
//cv::cuda::threshold(src,dst,128.0,255.0, CV_THRESH_BINARY);
cv::cuda::bilateralFilter(src,dst,3,1,1);
cv::Mat resultHost;
dst.download(resultHost);
} else {
cv::Mat dst;
cv::bilateralFilter(srcHost,dst,3,1,1);
}
}
//cv::imshow("Result",resultHost);
//cv::waitKey();
} catch(const cv::Exception& ex) {
std::cout << "Error: " << ex.what() << std::endl;
}
std::clock_t end = std::clock();
std::cout << double(end-begin) / CLOCKS_PER_SEC << std::endl;
}
Like this:
$ g++ `pkg-config opencv --cflags --libs` -o test test.cpp
$ ./test
I get Errors:
/tmp/ccq7bU2Y.o: In function `main':
test.cpp:(.text+0x7e): undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
test.cpp:(.text+0x9d): undefined reference to `cv::cuda::GpuMat::defaultAllocator()'
test.cpp:(.text+0xb7): undefined reference to `cv::cuda::GpuMat::defaultAllocator()'
test.cpp:(.text+0xfe): undefined reference to `cv::cuda::GpuMat::upload(cv::_InputArray const&)'
test.cpp:(.text+0x112): undefined reference to `cv::cuda::Stream::Null()'
test.cpp:(.text+0x17a): undefined reference to `cv::cuda::bilateralFilter(cv::_InputArray const&, cv::_OutputArray const&, int, float, float, int, cv::cuda::Stream&)'
test.cpp:(.text+0x1d3): undefined reference to `cv::cuda::GpuMat::download(cv::_OutputArray const&) const'
/tmp/ccq7bU2Y.o: In function `cv::Mat::~Mat()':
test.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)'
/tmp/ccq7bU2Y.o: In function `cv::Mat::release()':
test.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference to `cv::Mat::deallocate()'
/tmp/ccq7bU2Y.o: In function `cv::cuda::GpuMat::~GpuMat()':
test.cpp:(.text._ZN2cv4cuda6GpuMatD2Ev[_ZN2cv4cuda6GpuMatD5Ev]+0x14): undefined reference to `cv::cuda::GpuMat::release()'
/tmp/ccq7bU2Y.o:(.data.DW.ref._ZTIN2cv9ExceptionE[DW.ref._ZTIN2cv9ExceptionE]+0x0): undefined reference to `typeinfo for cv::Exception'
collect2: error: ld returned 1 exit status
Hi did you manage to solve this? I followed that same guide and I am facing right now the same exact problem.