Visual Studios 2013 - C++ Linker Error with openCV 3.0 Libs - c++

Their is a problem with the Linker for C++ in my Visual Studios 2013 on Windows 8. I want to use openCV 3.0 with my Visual Studios. All links inside the code will be used normal and IntelliSense recognize the datamembers. But if I want to compile the programm Visual Studios give me following errors:
Fehler 1 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""private: char * __thiscall cv::String::allocate(unsigned int)" (?allocate#String#cv##AAEPADI#Z)" in Funktion ""public: __thiscall cv::String::String(char const *)" (??0String#cv##QAE#PBD#Z)". C:\Users\Marc\Documents\Workspaces\C++_VS\OpenCV_Test\OpenCV_Test\main.obj OpenCV_Test
Fehler 2 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""private: void __thiscall cv::String::deallocate(void)" (?deallocate#String#cv##AAEXXZ)" in Funktion ""public: __thiscall cv::String::~String(void)" (??1String#cv##QAE#XZ)". C:\Users\Marc\Documents\Workspaces\C++_VS\OpenCV_Test\OpenCV_Test\main.obj OpenCV_Test
Fehler 3 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __thiscall cv::CommandLineParser::CommandLineParser(int,char const * const * const,class cv::String const &)" (??0CommandLineParser#cv##QAE#HQBQBDABVString#1##Z)" in Funktion "_main". C:\Users\Marc\Documents\Workspaces\C++_VS\OpenCV_Test\OpenCV_Test\main.obj OpenCV_Test
Fehler 4 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __thiscall cv::CommandLineParser::~CommandLineParser(void)" (??1CommandLineParser#cv##QAE#XZ)" in Funktion "_main". C:\Users\Marc\Documents\Workspaces\C++_VS\OpenCV_Test\OpenCV_Test\main.obj OpenCV_Test
Fehler 5 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""protected: void __thiscall cv::CommandLineParser::getByName(class cv::String const &,bool,int,void *)const " (?getByName#CommandLineParser#cv##IBEXABVString#2#_NHPAX#Z)" in Funktion ""public: class cv::String __thiscall cv::CommandLineParser::get(class cv::String const &,bool)const " (??$get#VString#cv###CommandLineParser#cv##QBE?AVString#1#ABV21#_N#Z)". C:\Users\Marc\Documents\Workspaces\C++_VS\OpenCV_Test\OpenCV_Test\main.obj OpenCV_Test
Fehler 6 error LNK1120: 5 nicht aufgelöste Externe C:\Users\Marc\Documents\Workspaces\C++_VS\OpenCV_Test\Debug\OpenCV_Test.exe 1 1 OpenCV_Test
I installed openCV with the following guide: http://www.minlabz.com/how-to-install-opencv-3-0-0-on-windows-7-and-configure-with-visual-studio-2014/
Here is the little code that I used to test if the openCV dependencies work:
#include "opencv2\highgui\highgui.hpp"
#include "opencv2\core\core.hpp"
#include <stdio.h>
using namespace cv;
int main(int argc, const char** argv)
{
const char* keyMap;
//Standard image that will be used if dont exist arguments
keyMap = "{path | | }";
//Reading the Callingarguments
CommandLineParser parser(argc, argv, keyMap);
String filename = parser.get<String>("path");
}
I hope I don't forgot something simple.

When you installed the OpenCV 3 with visual studio 2013 and cmake , you will find the dlls in
\opencv\msvc\bin\Release for the release mode and the include in \opencv\build\include, therefore invoke the command prompt and type
cl /EHsc main.cpp /Fetest.exe /I D:\CPP_Libraries\opencv_3.0.0\build\include /link /LIBPATH:D:\CPP_Libraries\opencv_3.0.0\msvc\lib\Release opencv_core300.lib
with this sample
#include <iostream>
#include <opencv2/core/core.hpp>
int main( int argc, char** argv )
{
std::cout << "\n%%( Random Generator )%%\n";
cv::Mat G = cv::Mat::ones(4,4, CV_64FC1);
cv::Mat m = cv::Mat::zeros(1,1, CV_64FC1);
cv::Mat s = cv::Mat::ones(1,1, CV_64FC1);
std::cout << G << std::endl;
cv::randn(G, m, s);
std::cout << G << std::endl;
return 0;
}
The result is

The porblem is solved now.
I re-extract opencv and followed the steps of the following two links:
Install OpenCV 3.0 on Windows 8
Create an Visual Studio (2013) Project with openCV

Having experienced very similar compilation error messages than those shown in the original post, I followed the thorough links above (Install OpenCV 3.0 on Windows 8, Create an Visual Studio (2013) Project with openCV).
This did not solve the compilation errors though.
What worked for me was to change the OPENCV_DIR environment variable to point to the x86 build of openCV instead of the x64 build.

If you had compiled opencv in x64 environment, I strongly recommend you to change x64 platform in Configuration Manager(Visual studio). I fixed same problem like this.enter image description here

Related

LNK2019 error with Eclipse Paho MQTT C for a Visual Studio C++ project (win64)

I want to use the Eclipse Paho MQTT C library in a simple C++ program. For the library i used the the pre-build binaries for windows - see https://projects.eclipse.org/projects/technology.paho/downloads
C client for Windows 1.3.0 - 64 bit
I found the exact same issue in this talk LNK2019 error when compiling a Visual C++ Win32 project with Eclipse Paho MQTT.
For linkage in include I have the following setting:
C/C++ - Additional include: xxx\paho\eclipse-paho-mqtt-c-win64-1.3.0\include
Linker - additional Additional Library Directories
Linker - input - additional dependencies:
eclipse-paho-mqtt-c-win64-1.3.0\lib\paho-mqtt3cs.lib
eclipse-paho-mqtt-c-win64-1.3.0\lib\paho-mqtt3c.lib
eclipse-paho-mqtt-c-win64-1.3.0\lib\paho-mqtt3a.lib
eclipse-paho-mqtt-c-win64-1.3.0\lib\paho-mqtt3as.lib
My code is as follows:
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern "C" {
#include <MQTTClient.h>
#include <MQTTClientPersistence.h>
}
#define ADDRESS "xxx"
#define CLIENTID "ExampleClientSub"
#define TOPIC "xxx"
#define PAYLOAD "Hello World!"
#define QOS 1
#define TIMEOUT 10000L
int main()
{
MQTTClient client;
MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer;
int rc;
int ch;
MQTTClient_create(&client, ADDRESS, CLIENTID,
MQTTCLIENT_PERSISTENCE_NONE, NULL);
conn_opts.keepAliveInterval = 20;
conn_opts.cleansession = 1;
conn_opts.username = "roman.busse";
conn_opts.password = "VojUriLKhOsmzUJQ1lld";
MQTTClient_setCallbacks(client, NULL, connlost, msgarrvd, delivered);
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
{
printf("Failed to connect, return code %d\n", rc);
exit(EXIT_FAILURE);
}
printf("Subscribing to topic %s\nfor client %s using QoS%d\n\n"
"Press Q<Enter> to quit\n\n", TOPIC, CLIENTID, QOS);
MQTTClient_subscribe(client, TOPIC, QOS);
do
{
ch = getchar();
} while (ch != 'Q' && ch != 'q');
MQTTClient_unsubscribe(client, TOPIC);
MQTTClient_disconnect(client, 10000);
MQTTClient_destroy(&client);
return 0;
}
So like you can see i said to the compiler: "Yes this is a C lib". But all in all I get the same LNK2019 errors...
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol _MQTTClient_setCallbacks
referenced in function
_main paho_test C:\Users\rtreiber\documents\visual studio 2017\Projects\paho_test\paho_test\paho_test.obj 1
Error LNK2019 unresolved external symbol _MQTTClient_create referenced
in function _main paho_test C:\Users\rtreiber\documents\visual studio
2017\Projects\paho_test\paho_test\paho_test.obj 1
Error LNK2019 unresolved external symbol _MQTTClient_connect
referenced in function
_main paho_test C:\Users\rtreiber\documents\visual studio 2017\Projects\paho_test\paho_test\paho_test.obj 1
Error LNK2019 unresolved external symbol _MQTTClient_disconnect
referenced in function
_main paho_test C:\Users\rtreiber\documents\visual studio 2017\Projects\paho_test\paho_test\paho_test.obj 1
Error LNK2019 unresolved external symbol _MQTTClient_subscribe
referenced in function
_main paho_test C:\Users\rtreiber\documents\visual studio 2017\Projects\paho_test\paho_test\paho_test.obj 1
Error LNK2019 unresolved external symbol _MQTTClient_unsubscribe
referenced in function
_main paho_test C:\Users\rtreiber\documents\visual studio 2017\Projects\paho_test\paho_test\paho_test.obj 1
Error LNK2019 unresolved external symbol _MQTTClient_freeMessage
referenced in function "int __cdecl msgarrvd(void *,char *,int,struct
MQTTClient_message *)"
(?msgarrvd##YAHPAXPADHPAUMQTTClient_message###Z) paho_test C:\Users\rtreiber\documents\visual
studio 2017\Projects\paho_test\paho_test\paho_test.obj 1
Error LNK2019 unresolved external symbol _MQTTClient_free referenced
in function "int __cdecl msgarrvd(void *,char *,int,struct
MQTTClient_message *)"
(?msgarrvd##YAHPAXPADHPAUMQTTClient_message###Z) paho_test C:\Users\rtreiber\documents\visual
studio 2017\Projects\paho_test\paho_test\paho_test.obj 1
Error LNK2019 unresolved external symbol _MQTTClient_destroy
referenced in function
_main paho_test C:\Users\rtreiber\documents\visual studio 2017\Projects\paho_test\paho_test\paho_test.obj 1 Error LNK1120 9
unresolved externals paho_test C:\Users\rtreiber\documents\visual
studio 2017\Projects\paho_test\Debug\paho_test.exe 1
So any ideas?

QT Creator | Error LNK2019 | Opencv in QT

I integrated opencv in QT creator. I want to use my camera and display the frames in the mainwindow. After compiling a simple code, where I only want to output a simple message, I get an error (German language) Like:
videocap.obj:-1: Fehler: LNK2019: Verweis auf nicht aufgelöstes
externes Symbol ""public: __cdecl
cv::VideoCapture::VideoCapture(void)" (??0VideoCapture#cv##QEAA#XZ)"
in Funktion ""public: void __cdecl videoCap::playVideo(void)"
(?playVideo#videoCap##QEAAXXZ)".
Code:
void videoCap:: playVideo(){
VideoCapture *cap = new VideoCapture();
if(!cap->isOpened()){
cout<< "nope" << endl;
}else{
cout << "dope" << endl;
}
}
Can you explain me what I am doing wrong please ?

Linker Errors with glfw and MSVS 2012

I'm trying to setup glfw with MSVS 2012.
I downloaded the latest version of glfw from http://www.glfw.org/download.html (32 bit).
In the next step i created a new property sheet with the following content:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(glfw_DIR)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(glfw_DIR)\lib-msvc120;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>
Then I tried to run the following code:
#include <GLFW/glfw3.h>
#include <thread>
int main()
{
glfwInit();
std::this_thread::sleep_for(std::chrono::seconds(1));
glfwTerminate();
}
and received the following Output:
1>------ Erstellen gestartet: Projekt: openGL_Basic_flow, Konfiguration: Debug Win32 ------
1>LINK : warning LNK4098: Standardbibliothek "MSVCRT" steht in Konflikt mit anderen Bibliotheken; /NODEFAULTLIB:Bibliothek verwenden.
1>glfw3.lib(window.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__glClear#4" in Funktion "_glfwCreateWindow".
1>glfw3.lib(context.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__glGetIntegerv#8" in Funktion "__glfwRefreshContextAttribs".
1>glfw3.lib(context.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__glGetString#4" in Funktion "_glfwExtensionSupported".
1>glfw3.lib(wgl_context.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__wglCreateContext#4" in Funktion "__glfwCreateContext".
1>glfw3.lib(wgl_context.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__wglDeleteContext#4" in Funktion "__glfwDestroyContext".
1>glfw3.lib(wgl_context.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__wglGetProcAddress#4" in Funktion "__glfwPlatformGetProcAddress".
1>glfw3.lib(wgl_context.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__wglMakeCurrent#8" in Funktion "__glfwPlatformMakeContextCurrent".
1>glfw3.lib(wgl_context.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__wglShareLists#8" in Funktion "__glfwCreateContext".
1>glfw3.lib(win32_time.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__dtoul3" in Funktion "__glfwPlatformSetTime".
1>glfw3.lib(win32_time.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__ultod3" in Funktion "__glfwInitTimer".
1>C:\Projektmappe\Debug\openGL_Basic_flow.exe : fatal error LNK1120: 10 nicht aufgelöste Externe
========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ==========
I also tried to fix it with the workaround mentioned here: Compiling GLFW with Visual Studio 2012
But it didn't help. The output changed to the following:
1>------ Erstellen gestartet: Projekt: openGL_Basic_flow, Konfiguration: Debug Win32 ------
1> main.cpp
1>LINK : warning LNK4098: Standardbibliothek "MSVCRT" steht in Konflikt mit anderen Bibliotheken; /NODEFAULTLIB:Bibliothek verwenden.
1>glfw3.lib(win32_time.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__dtoul3" in Funktion "__glfwPlatformSetTime".
1>glfw3.lib(win32_time.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__ultod3" in Funktion "__glfwInitTimer".
1>C:\Projektmappe\Debug\openGL_Basic_flow.exe : fatal error LNK1120: 2 nicht aufgelöste Externe
========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ==========
Any other ideas?
You are using the wrong binaries for Visual Studio 2012. The correct binaries are in the lib-msvc110 folder. You need to always be cautious when you have 2 or 3 digit versions since these do not match the year (well they do for 2010 only).
VC90 = Visual Studio 2008
VC100 = Visual Studio 2010
VC110 = Visual Studio 2012.
VC120 = Visual Studio 2013.

opencv issue with vs 2013 C++

I am using opencv 2.4.8 with visual studio 2013. I have been trying to get my application to run. I know for sure the code works, but I am having linker issues I believe...
here is the error I get:
Error 1 error LNK2019: unresolved external symbol _cvCreateImage referenced in function "void __cdecl getBinaryImage(void)" (?getBinaryImage##YAXXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 2 error LNK2019: unresolved external symbol _cvInRangeS referenced in function "void __cdecl getBinaryImage(void)" (?getBinaryImage##YAXXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 3 error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl cv::format(char const *,...)" (?format#cv##YA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##PBDZZ) referenced in function __catch$?getFace##YAXXZ$0 C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 4 error LNK2019: unresolved external symbol "void __cdecl cv::fastFree(void *)" (?fastFree#cv##YAXPAX#Z) referenced in function "public: __thiscall cv::Mat::~Mat(void)" (??1Mat#cv##QAE#XZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 5 error LNK2019: unresolved external symbol "public: __thiscall cv::_InputArray::_InputArray(class cv::Mat const &)" (??0_InputArray#cv##QAE#ABVMat#1##Z) referenced in function __catch$?getFace##YAXXZ$0 C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 6 error LNK2019: unresolved external symbol "public: __thiscall cv::_InputArray::_InputArray(class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > const &)" (??0_InputArray#cv##QAE#ABV?$vector#VMat#cv##V?$allocator#VMat#cv###std###std###Z) referenced in function __catch$?getFace##YAXXZ$0 C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 7 error LNK2001: unresolved external symbol "public: virtual class cv::Mat __thiscall cv::_InputArray::getMat(int)const " (?getMat#_InputArray#cv##UBE?AVMat#2#H#Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 8 error LNK2001: unresolved external symbol "public: virtual void __thiscall cv::_InputArray::getMatVector(class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > &)const " (?getMatVector#_InputArray#cv##UBEXAAV?$vector#VMat#cv##V?$allocator#VMat#cv###std###std###Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 9 error LNK2001: unresolved external symbol "public: virtual class cv::GlBuffer __thiscall cv::_InputArray::getGlBuffer(void)const " (?getGlBuffer#_InputArray#cv##UBE?AVGlBuffer#2#XZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 10 error LNK2001: unresolved external symbol "public: virtual class cv::GlTexture __thiscall cv::_InputArray::getGlTexture(void)const " (?getGlTexture#_InputArray#cv##UBE?AVGlTexture#2#XZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 11 error LNK2001: unresolved external symbol "public: virtual class cv::gpu::GpuMat __thiscall cv::_InputArray::getGpuMat(void)const " (?getGpuMat#_InputArray#cv##UBE?AVGpuMat#gpu#2#XZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 12 error LNK2001: unresolved external symbol "public: virtual int __thiscall cv::_InputArray::kind(void)const " (?kind#_InputArray#cv##UBEHXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 13 error LNK2001: unresolved external symbol "public: virtual class cv::Size_<int> __thiscall cv::_InputArray::size(int)const " (?size#_InputArray#cv##UBE?AV?$Size_#H#2#H#Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 14 error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall cv::_InputArray::total(int)const " (?total#_InputArray#cv##UBEIH#Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 15 error LNK2001: unresolved external symbol "public: virtual int __thiscall cv::_InputArray::type(int)const " (?type#_InputArray#cv##UBEHH#Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 16 error LNK2001: unresolved external symbol "public: virtual int __thiscall cv::_InputArray::depth(int)const " (?depth#_InputArray#cv##UBEHH#Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 17 error LNK2001: unresolved external symbol "public: virtual int __thiscall cv::_InputArray::channels(int)const " (?channels#_InputArray#cv##UBEHH#Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 18 error LNK2001: unresolved external symbol "public: virtual bool __thiscall cv::_InputArray::empty(void)const " (?empty#_InputArray#cv##UBE_NXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 19 error LNK2019: unresolved external symbol "public: void __thiscall cv::Mat::deallocate(void)" (?deallocate#Mat#cv##QAEXXZ) referenced in function "public: void __thiscall cv::Mat::release(void)" (?release#Mat#cv##QAEXXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 20 error LNK2019: unresolved external symbol "public: void __thiscall cv::Mat::copySize(class cv::Mat const &)" (?copySize#Mat#cv##QAEXABV12##Z) referenced in function "public: __thiscall cv::Mat::Mat(class cv::Mat const &)" (??0Mat#cv##QAE#ABV01##Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 21 error LNK2019: unresolved external symbol "public: void __thiscall cv::Algorithm::set(char const *,double)" (?set#Algorithm#cv##QAEXPBDN#Z) referenced in function __catch$?getFace##YAXXZ$0 C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 22 error LNK2019: unresolved external symbol "int __cdecl cv::_interlockedExchangeAdd(int *,int)" (?_interlockedExchangeAdd#cv##YAHPAHH#Z) referenced in function "public: __thiscall cv::Mat::Mat(class cv::Mat const &)" (??0Mat#cv##QAE#ABV01##Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 23 error LNK2019: unresolved external symbol _cvCvtColor referenced in function "void __cdecl getBinaryImage(void)" (?getBinaryImage##YAXXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 24 error LNK2019: unresolved external symbol _cvShowImage referenced in function "void __cdecl getBinaryImage(void)" (?getBinaryImage##YAXXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 25 error LNK2019: unresolved external symbol _cvLoadImage referenced in function "void __cdecl getBinaryImage(void)" (?getBinaryImage##YAXXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 26 error LNK2019: unresolved external symbol _cvSaveImage referenced in function "void __cdecl getBinaryImage(void)" (?getBinaryImage##YAXXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 27 error LNK2019: unresolved external symbol _cvWaitKey referenced in function "void __cdecl getBinaryImage(void)" (?getBinaryImage##YAXXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 28 error LNK2019: unresolved external symbol _cvCreateCameraCapture referenced in function _main C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 29 error LNK2019: unresolved external symbol _cvQueryFrame referenced in function _main C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 30 error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?imread#cv##YA?AVMat#1#ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##H#Z) referenced in function "void __cdecl read_csv(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > &,class std::vector<int,class std::allocator<int> > &,char)" (?read_csv##YAXABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AAV?$vector#VMat#cv##V?$allocator#VMat#cv###std###2#AAV?$vector#HV?$allocator#H#std###2#D#Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 31 error LNK2019: unresolved external symbol "class cv::Ptr<class cv::FaceRecognizer> __cdecl cv::createLBPHFaceRecognizer(int,int,int,int,double)" (?createLBPHFaceRecognizer#cv##YA?AV?$Ptr#VFaceRecognizer#cv###1#HHHHN#Z) referenced in function __catch$?getFace##YAXXZ$0 C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 32 error LNK1120: 31 unresolved externals C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\Debug\PAD_visualEngine.exe PAD_visualEngine
I had a 2012 vs application of this project and it worked just fine, The steps I have done is setting the Additional library Directories as "C:\opencv\build\x86\vc12\lib" and the additional Include Directories as "C:\opencv\build\include". For safe measures I also set the path as C:\opencv. I don't really know what I am forgetting? I thank you in advance for the help!
here is the code:
#include "opencv2/opencv.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
using namespace cv;
#define CV_IMWRITE_JPEG_QUALITY 1
#define CV_IMWRITE_PNG_COMPRESSION 16
#define CV_IMWRITE_PXM_BINARY 32
vector<Mat> images;
vector<int> labels;
void getBinaryImage()
{
IplImage *gray, *binary, *dest, *a;
a = cvLoadImage("out2.jpg");
gray = cvCreateImage(cvSize(a->width, a->height), IPL_DEPTH_8U, 1);
//binary=cvCreateImage(cvSize(a->width,a->height), IPL_DEPTH_8U,1);
dest = cvCreateImage(cvSize(a->width, a->height), IPL_DEPTH_8U, 1);
cvCvtColor(a, gray, CV_BGR2GRAY);
//cvThreshold(gray,binary,30,255,THRESH_BINARY);
cvInRangeS(a, cvScalar(1, 1, 1), cvScalar(120, 100, 300), dest);
cvSaveImage("out2_gray.jpg", dest);
cvShowImage("inrangGray", dest);
cvWaitKey(0);
}
void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';')
{
std::ifstream file(filename.c_str(), ifstream::in);
if (!file){
string error = "no valid input csv file";
cout << error;
}
string line, path, classlabel;
while (getline(file, line)){
stringstream liness(line);
getline(liness, path, separator);
getline(liness, classlabel);
if (!path.empty() && !classlabel.empty()){
images.push_back(imread(path, 0));
labels.push_back(atoi(classlabel.c_str()));
}
}
}
void getFace()
{
try{
read_csv("file.csv", images, labels);
}
catch (cv::Exception& e){
cerr << "error opening file info.csv";
exit(1);
}
try{
if (images.size() <= 1){
string error = "this app needs at leaset 2 images";
cout << error;
}
int height = images[0].rows;
Mat testImage = images[images.size() - 1];
int testLab = labels[labels.size() - 1];
images.pop_back();
labels.pop_back();
Ptr<FaceRecognizer>model = createLBPHFaceRecognizer();
model->train(images, labels);
int predictedlabel = model->predict(testImage);
string result = format("predicted=%d/ actual=%d", predictedlabel, testLab);
cout << result << endl;
model->set("threshold", 0.0);
predictedlabel = model->predict(testImage);
cout << "predicted class = " << predictedlabel << endl;
}
catch (cv::Exception& e){
cerr << "overall error";
}
}
int main(int argc, char** argv)
{
/*VideoCapture cap;
// open the default camera, use something different from 0 otherwise;
// Check VideoCapture documentation.
if(!cap.open(0))
return 0;
for(;;)
{
Mat frame;
cap >> frame;
if( frame.empty() ) break; // end of video stream
imshow("capture", frame);
if( (waitKey() & 255) == 27 ) break; // stop capturing by pressing ESC
}
// the camera will be closed automatically upon exit
// cap.close();
return 0; */
int p[3];
CvCapture *pCapturedImage = cvCreateCameraCapture(-1);
IplImage *pSaveImg = cvQueryFrame(pCapturedImage);
pSaveImg = cvQueryFrame(pCapturedImage);
p[0] = CV_IMWRITE_JPEG_QUALITY;
p[1] = 100;
p[2] = 0;
//cvSaveImage("out2.jpg", pSaveImg, p);
//getBinaryImage();
getFace();
return 0;
}
You are getting those errors because the linker doesn't know in which library to look for the used methods. You can try adding the names of those libraries (depending on the methods you are using, try adding opencv_core248.lib, etc.) in Project properties->Linker->Input->Additional dependencies.
The second method is by adding the additional dependencies before the main function via pragma comments, as follows:
#pragma comment (lib, "opencv_core248d.lib")
#pragma comment (lib, "opencv_highgui248d.lib")
#pragma comment (lib, "opencv_imgproc248d.lib")
#pragma comment (lib, "opencv_video248d.lib")
#pragma comment (lib, "opencv_features2d248d.lib")
If you are building a release version, remove the "d" letter before the extension (opencv_core248.lib, etc.)
Let me know if that works for you!
Best regards
Check if your platform is win32 or x64(Solution Properties-->Configuration -->Platform column). I faced similar issue when my platform was win32 and the linker was trying to link using x64.

OpenSSL fatal error LNK1120: 3 unresolved externals

I've installed OpenSSL to Windows 8, and did the necessary modifications to the OpenSSL library, without installing it as a native library. But I've a specific error message that I couldn't find it on internet.
1>------ Build started: Project: CryptoProject, Configuration: Debug Win32 ------
1> main.cpp
1>main.obj : error LNK2019: unresolved external symbol _BN_new referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _BN_bn2dec referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _BN_generate_prime referenced in function _main
1>C:\Users\...\...\...\Debug\EXAMPLE.exe : fatal error LNK1120: 3 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Hope you guys find something. So here it goes:
#include <iostream>
#include <string>
#include "openssl/bn.h"
using namespace std;
int main()
{
BIGNUM * q = BN_new();
BIGNUM * two = BN_new();
long int num_bits_q = 160;
long int num_bits_p = 1024;
BN_generate_prime(q, num_bits_q, 0, two, NULL,NULL,NULL);
cout << "q is: " << BN_bn2dec(q) << endl;
return 0;
}
I ran that code and it compiled successfully in visual studio 2012, I used OpenSSL-Win32. If OpenSSL-Win64 does not work use OpenSSL-Win32, I also had the same problem. Don't forget to include ssleay32.lib, I hope you know how to configure OpenSSl in visual studio.