error LNK2019: unsolvable external symbol (OpenCV + VS2012) - opencv

I've searched a lot but none of the answers help.
I added these things below:
include directory: D:\Program Files (x86)\opencv\build\include
library directory: D:\Program Files (x86)\opencv\build\x86\vc11\lib
additional library directory: D:\Program Files (x86)\opencv\build\x86\vc11\lib
additional dependency: %(AdditionalDependencies);opencv_core248d.lib;opencv_imgproc248d.lib;opencv_ml248d.lib;opencv_video248d.lib;opencv_features2d248d.lib;opencv_calib3d248d.lib;opencv_objdetect248d.lib;opencv_contrib248d.lib;opencv_legacy248d.lib;opencv_flann248d.lib;
I'm using 64-bit machine but adding x64 directory cause a lot of trouble, so I add x86 directory instead.
I used the test code below:
#include "opencv2/opencv.hpp"
using namespace cv;
int main()
{
Mat img = imread("../opencv.jpg");
if (img.empty())
{
fprintf(stderr, "Error: load image failed.");
return -1;
}
namedWindow("image", CV_WINDOW_AUTOSIZE);
imshow("image", img);
waitKey();
return 0;
}
And the problem is: (ignore the Chinese part)
1>test.obj : error LNK2019: unsolvable external symbol "void __cdecl cv::namedWindow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?namedWindow#cv##YAXABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##H#Z),该符号在函数 _main 中被引用
1>test.obj : error LNK2019: unsolvable external symbol "int __cdecl cv::waitKey(int)" (?waitKey#cv##YAHH#Z),该符号在函数 _main 中被引用
1>test.obj : error LNK2019: unsolvable external symbol "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow#cv##YAXABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##ABV_InputArray#1##Z),该符号在函数 _main 中被引用
1>test.obj : error LNK2019: unsolvable 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),该符号在函数 _main 中被引用
Thank you in advance!!

Please refer to the answer to this question. It's probably caused by the mixing up 64/32 bit libraries and application.
This instruction shows how to build opencv applications using VS in detail. Hope it would help.

Related

Why I have get this kind of error in Visual Studio 2022

Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: __cdecl Window::Window(void)" (??0Window##QEAA#XZ) referenced in function "public: __cdecl AppWindow::AppWindow(void)" (??0AppWindow##QEAA#XZ) Game1 E:\Game\Game1\Game1\main.obj 1
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: __cdecl Window::~Window(void)" (??1Window##QEAA#XZ) referenced in function "public: __cdecl AppWindow::~AppWindow(void)" (??1AppWindow##QEAA#XZ) Game1 E:\Game\Game1\Game1\main.obj 1
Severity Code Description Project File Line Suppression State
Error LNK1120 2 unresolved externals Game1 E:\Game\Game1\x64\Debug\Game1.exe 1

Fade2D library & C++ Builder

I wish to use Fade2D library in my C++Builder projects.
Libraries are in MS Visual Studio's and using them raised an exception:
[ilink32 Error] Error contains invalid OMF record, type 0x21 (possibly COFF)
I tried the two tools from Embarcadero to build the .lib file for C++ Builder:
COFF2OMF to convert the .lib from VS format and
IMPLIB to produces the .lib file starting form DLL
In both cases I have the error:
[ilink32 Error] Error: Unresolved external 'GEOM_FADE2D::setLic(const char *, const char *, const char *, const char *, const char *)' referenced from MAIN.OBJ
Any suggestions? Thanks in advance.

OpenCV Errors - Accurate eye center tracking

1>C:\opencv243\build\include\constants.h(15): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>C:\opencv243\build\include\constants.h(26): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>prog.cpp(16): warning C4068: unknown pragma
1>prog.cpp(44): warning C4068: unknown pragma
1>prog.cpp(48): error C3861: 'round': identifier not found
1>prog.cpp(49): error C3861: 'round': identifier not found
1>prog.cpp(54): warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
1>prog.cpp(74): warning C4068: unknown pragma
1>prog.cpp(189): warning C4068: unknown pragma
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I want to run accurate eye center tracking programme but these are my errors... Please help me to fix this.. I havent got enough time for this project..
(if All of my code is necessary , i can send it)
*EDİT*
The last status of my project; it have build errors.. :
1>------ Build started: Project: MNOpenCV, Configuration: Debug Win32 ------
1>hkjn.obj : error LNK2019: unresolved external symbol "double __cdecl computeDynamicThreshold(class cv::Mat const &,double)" (?computeDynamicThreshold##YANABVMat#cv##N#Z) referenced in function "class cv::Point_<int> __cdecl findEyeCenter(class cv::Mat,class cv::Rect_<int>,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?findEyeCenter##YA?AV?$Point_#H#cv##VMat#2#V?$Rect_#H#2#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z)
1>hkjn.obj : error LNK2019: unresolved external symbol "class cv::Mat __cdecl matrixMagnitude(class cv::Mat const &,class cv::Mat const &)" (?matrixMagnitude##YA?AVMat#cv##ABV12#0#Z) referenced in function "class cv::Point_<int> __cdecl findEyeCenter(class cv::Mat,class cv::Rect_<int>,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?findEyeCenter##YA?AV?$Point_#H#cv##VMat#2#V?$Rect_#H#2#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z)
1>hkjn.obj : error LNK2019: unresolved external symbol "bool __cdecl inMat(class cv::Point_<int>,int,int)" (?inMat##YA_NV?$Point_#H#cv##HH#Z) referenced in function "bool __cdecl floodShouldPushPoint(class cv::Point_<int> const &,class cv::Mat const &)" (?floodShouldPushPoint##YA_NABV?$Point_#H#cv##ABVMat#2##Z)
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Users\AA\Documents\Visual Studio 2010\Projects\MNOpenCV\Debug\MNOpenCV.exe : fatal error LNK1120: 4 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Maybe you forgot to add the include for the "double round (double x)" function?
#include <math.h>
If not, it might be an issue with your pragma instructions...
C++ Round Function Reference
Best regards!

How to fix error LNK2019 when using videoInput.lib with OpenCv2.1?

I am new in OpenCV and have some problems when using videoInput.lib,please help me.I am using winXP SP3+Cmake2.8.2+OpenCV 2.1+Visual Studio 2008.I have made every configuration and now OpenCv can be used when I am coding.I heard videoInput.lib has been included since OpenCV2.0 and I want to use it,so I tried codes below to quick test.
// Test2.cpp : Defines the entry point for the console application.
//
#include "videoInput.h"
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
#include "cxcore.h"
int main(int ,char * *)
{
int width=320;
int height=240;
IplImage *pRgb=cvCreateImage(cvSize(width,height), IPL_DEPTH_8U, 3);
videoInput video;
video.setupDevice(0, width, height);
video.showSettingsWindow(0);
while(1)
{
if(video.isFrameNew(0))
{
video.getPixels(0, (unsigned char *)pRgb->imageData, false, true);
//cvFlip(pRgb,NULL,1);
char c=cvWaitKey(1);
if(c==27) break;
cvShowImage("Video", pRgb);
}
}
}
However when I build the codes,I got following error
1>------ Build started: Project: Test2, Configuration: Debug Win32 ------
1>Compiling...
1>Test2.cpp
1>c:\opencv2.1\vc2008\include\opencv\cvcompat.h(803) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
1>Linking...
1>Test2.obj : error LNK2019: unresolved external symbol "public: __thiscall videoInput::~videoInput(void)" (??1videoInput##QAE#XZ) referenced in function _main
1>Test2.obj : error LNK2019: unresolved external symbol "public: bool __thiscall videoInput::getPixels(int,unsigned char *,bool,bool)" (?getPixels#videoInput##QAE_NHPAE_N1#Z) referenced in function _main
1>Test2.obj : error LNK2019: unresolved external symbol "public: bool __thiscall videoInput::isFrameNew(int)" (?isFrameNew#videoInput##QAE_NH#Z) referenced in function _main
1>Test2.obj : error LNK2019: unresolved external symbol "public: void __thiscall videoInput::showSettingsWindow(int)" (?showSettingsWindow#videoInput##QAEXH#Z) referenced in function _main
1>Test2.obj : error LNK2019: unresolved external symbol "public: bool __thiscall videoInput::setupDevice(int,int,int)" (?setupDevice#videoInput##QAE_NHHH#Z) referenced in function _main
1>Test2.obj : error LNK2019: unresolved external symbol "public: __thiscall videoInput::videoInput(void)" (??0videoInput##QAE#XZ) referenced in function _main
1>C:\Documents and Settings\SKSC\My Documents\Visual Studio 2008\Projects\Test2\Debug\Test2.exe : fatal error LNK1120: 6 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\SKSC\My Documents\Visual Studio 2008\Projects\Test2\Test2\Debug\BuildLog.htm"
1>Test2 - 7 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I have been googling for a long time but still can not find the solution,I am gonna mad.Does anyone know how to fix these problems?
Thanks in advance.
I think you still need to link with videoInput.lib, OpenCV uses videoInput.lib but it doesn't mean you can use all functions of videoInput.lib from OpenCV
Yes, you have to explicitly link to videoInput.lib from the Linker.
Here you will find what you need.
Here is how you can solve it:
"Go to Project Properties -> Confuguration Properties -> Linker -> Input and add videoinput.lib along with the usual OpenCV library files." This is the solution from the site mentioned above. I tried it and it works.

Errors while building ACE program

i just started ACE with a "HELLO WORLD" program. It compiled successfully but while building it produces some of the errors.Can anyone help me.
CODE:
#include <stdio.h>
#include "ace/Log_Msg.h"
#include "ace/OS_main.h"
int ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
ACE_DEBUG((LM_DEBUG, "Hello World\n"));
return 0;
}
ERROR:
/tmp/cccwdbA0.o: In function `main':
hello.cpp:(.text+0xa): undefined reference to `ACE_Log_Msg::last_error_adapter()'
hello.cpp:(.text+0x13): undefined reference to `ACE_Log_Msg::instance()'
hello.cpp:(.text+0x43): undefined reference to `ACE_Log_Msg::conditional_set(char const*, int, int, int)'
hello.cpp:(.text+0x5f): undefined reference to `ACE_Log_Msg::log(ACE_Log_Priority, char const*, ...)'
collect2: ld returned 1 exit status
Compilation failed.
Without seeing the build commands it's hard to tell but it looks like you didn't add a link-time reference to the ACE library.
It's hard to tell what you've done to make this not work. If I were to guess, it looks as if you've updated your include path in your makefile but forgotten to link libACE.so to your project. This would result in the undefined compilation behaviour you're seeing.

Resources