Member Avatar

Im trying to install the opencv libraries and i tried following the instructions at:
but Im having problems getting the sample code to compile. When I try:

#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>

using namespace std;

int main()
	catch(const cv::Exception& ex)
		std::cout << "Error: " << ex.what() << endl;
	return 0;

I get these errors
1>test.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl cv::gpu::getDeviceName(int)" (?getDeviceName@gpu@cv@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function _main

1>C:\Users\Chris\Documents\Visual Studio 2008\Projects\open cv image capture\Debug\open cv image capture.exe : fatal error LNK1120: 1 unresolved externals

How can I fix them?

Recommended Answers

All 2 Replies

Those are linker errors. You have not shown your compiler commands, but you'll need a -l something in there somewhere.

I have put several OpenCV examples here:

They all use CMakeLists.txt files to be used with the CMake build system, so unless you switch to CMake (which I highly recommend) the building part of the examples won't help you, but maybe the actual content will :)


What dviddoria said, but also the GPU stuff requires 1) an nvidia card w/ CUDA capabilities, and 2) the nvidia CUDA development tools and libraries. This second issue is what may be causing your link failure. Anyway, here is the OpenCV GPU FAQ page which talks about what you need to do to use it:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.