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 ?
Related
I've spent about two days now trying to get this to work but I still keep getting the same error with every method I do. I'm new to connecting MySQL to C++ so I'm a bit lost and every time I try to compile it, the thing spits out LNK2019 error. I'm using Visual Studio 2022.
#include <iostream>
#include <mysql.h>
using namespace std;
// DATABASE STUFF
struct connection_details {
const char* server, * user, * password, * database;
};
MYSQL* mysql_connection_setup(struct connection_details mysql_details) {
MYSQL* connection = mysql_init(NULL);
if (!(mysql_real_connect(connection, mysql_details.server, mysql_details.user, mysql_details.password, mysql_details.database, 0, NULL, 0))) {
cout << "Connection Error: " << mysql_error(connection) << endl;
exit(1);
}
return connection;
}
MYSQL_RES* mysql_execute_query(MYSQL* connection, const char* sql_query) {
if (mysql_query(connection, sql_query)) {
cout << "MYSQL Query Error: " << mysql_error(connection) << endl;
exit(1);
}
return mysql_use_result(connection);
}
// MAIN FUNCTION
int main(int argc, char const* argv[]) {
MYSQL* con;
MYSQL_RES* res;
MYSQL_ROW row;
struct connection_details mysql_db;
mysql_db.server = "localhost";
mysql_db.user = "root";
mysql_db.password = "tAblE4wTe3";
mysql_db.database = "test";
con = mysql_connection_setup(mysql_db);
res = mysql_execute_query(con, "select * from table1");
cout << "Displaying Database:\n" << endl;
while ((row = mysql_fetch_row(res)) != NULL) {
cout << row[0] << " | " << row[1] << " | " << row[2] << endl;
}
mysql_free_result(res);
mysql_close(con);
return 0;
}
Errors it shows:
1>------ Build started: Project: Test, Configuration: Debug x64 ------
1>main.obj : error LNK2019: unresolved external symbol mysql_error referenced in function "struct MYSQL * __cdecl mysql_connection_setup(struct connection_details)" (?mysql_connection_setup##YAPEAUMYSQL##Uconnection_details###Z)
1>main.obj : error LNK2019: unresolved external symbol mysql_init referenced in function "struct MYSQL * __cdecl mysql_connection_setup(struct connection_details)" (?mysql_connection_setup##YAPEAUMYSQL##Uconnection_details###Z)
1>main.obj : error LNK2019: unresolved external symbol mysql_real_connect referenced in function "struct MYSQL * __cdecl mysql_connection_setup(struct connection_details)" (?mysql_connection_setup##YAPEAUMYSQL##Uconnection_details###Z)
1>main.obj : error LNK2019: unresolved external symbol mysql_query referenced in function "struct MYSQL_RES * __cdecl mysql_execute_query(struct MYSQL *,char const *)" (?mysql_execute_query##YAPEAUMYSQL_RES##PEAUMYSQL##PEBD#Z)
1>main.obj : error LNK2019: unresolved external symbol mysql_use_result referenced in function "struct MYSQL_RES * __cdecl mysql_execute_query(struct MYSQL *,char const *)" (?mysql_execute_query##YAPEAUMYSQL_RES##PEAUMYSQL##PEBD#Z)
1>main.obj : error LNK2019: unresolved external symbol mysql_free_result referenced in function main
1>main.obj : error LNK2019: unresolved external symbol mysql_fetch_row referenced in function main
1>main.obj : error LNK2019: unresolved external symbol mysql_close referenced in function main
1>C:\Users\Administrator\Documents\Visual Studio 2022\C++ Projects\Test\x64\Debug\Test.exe : fatal error LNK1120: 8 unresolved externals
1>Done building project "Test.vcxproj" -- FAILED.
These are the include/library folder locations:
C:\Users\Administrator\Documents\Visual Studio 2022\mysql stuff\libbinlogevents
C:\Users\Administrator\Documents\Visual Studio 2022\mysql stuff\libbinlogstandalone
C:\Users\Administrator\Documents\Visual Studio 2022\mysql stuff\libchangestreams
C:\Users\Administrator\Documents\Visual Studio 2022\mysql stuff\libmysql
C:\Users\Administrator\Documents\Visual Studio 2022\mysql stuff\libservices
C:\Program Files\MySQL\Connector C++ 8.0\lib64\vs14
C:\Users\Administrator\Documents\Visual Studio 2022\mysql stuff\include
C:\Program Files\MySQL\Connector C++ 8.0\include
I've tried looking it up, and every forum, video, etc. that I try using to resolve doesn't work. I'm not sure if it's a 32-bit or 64-bit issue, though I don't think it is since all files point to 64-bit folders. I'm thinking it's something in my code but I'm very new to this so I can't really pinpoint it. Any help would be appreciated.
EDIT: I managed to solve it, just started the project from scratch and followed the visual studio docs and this video.
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
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.
I'm trying to use cpp-netlib with Visual Studio 2010.
I've built cpp-netlib and add .lib files to my project, but I can't compile them.
--Environment
Windows 7 x64
cpp-netlib 0.11.0
boost 1.55.0
Win32 OpenSSL v1.0.1f
My code is here.
#include <boost/network/protocol/http/client.hpp>
#include <iostream>
int main(int argc, char *argv[]) {
using namespace boost::network;
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " [url]" << std::endl;
return 1;
}
http::client client;
http::client::request request(argv[1]);
request << header("Connection", "close");
http::client::response response = client.get(request);
std::cout << body(response) << std::endl;
return 0;
}
I added the cpp-netlib library path and the cpp-netlib include path to the project.
Boost and openssl paths were also added.
I added the libs to the project.
libboost_system-vc100-mt-gd-1_55.lib
libboost_date_time-vc100-mt-gd-1_55.lib
libboost_regex-vc100-mt-gd-1_55.lib
cppnetlib-client-connections.lib
cppnetlib-uri.lib
I think the errors come from something related OpenSSL.
Error 55 error LNK2019: unresolved external symbol - function _BIO_ctrl ...
Actually, I have Japanese one so it's like below.
エラー 55 error LNK2019: 未解決の外部シンボル _BIO_ctrl が関数 "public: class boost::system::error_code const & __thiscall boost::asio::ssl::detail::engine::map_error_code(class boost::system::error_code &)const " (?map_error_code#engine#detail#ssl#asio#boost##QBEABVerror_code#system#5#AAV675##Z) で参照されました。 cppnetlib-client-connections.lib(client.obj)
エラー 57 error LNK2019: 未解決の外部シンボル _BIO_ctrl_pending が関数 "private: enum boost::asio::ssl::detail::engine::want __thiscall boost::asio::ssl::detail::engine::perform(int (__thiscall boost::asio::ssl::detail::engine::*)(void *,unsigned int),void *,unsigned int,class boost::system::error_code &,unsigned int *)" (?perform#engine#detail#ssl#asio#boost##AAE?AW4want#12345#P812345#AEHPAXI#Z0IAAVerror_code#system#5#PAI#Z) で参照されました。 cppnetlib-client-connections.lib(client.obj)
エラー 43 error LNK2019: 未解決の外部シンボル _BIO_free が関数 "public: __thiscall boost::asio::ssl::detail::engine::~engine(void)" (??1engine#detail#ssl#asio#boost##QAE#XZ) で参照されました。 cppnetlib-client-connections.lib(client.obj)
Could you tell me what I'm missing?
I tried to add more libs to the project, but it still didn't work.
I should've got to add these two library.
libeay32.lib
ssleay32.lib
I ran into the same problem, except i fixed it by using the WIN32 version of SSL instead of the X64 version.
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.