Linking external library in QT Creator - qt-creator

I need your help.
I'm trying to link an external library with QT Creator
I get three LNK2019 errors
mainwindow.obj:-1: error: LNK2019: unresolved external symbol ""void __cdecl cv::projectPoints(class cv::_InputArray const &,class cv::_InputArray const &,class cv::_InputArray const &,class cv::_InputArray const &,class cv::_InputArray const &,class cv::_OutputArray const &,class cv::_OutputArray const &,double)" (?projectPoints#cv##YAXABV_InputArray#1#0000ABV_OutputArray#1#1N#Z)" in Funktion ""private: int __thiscall MainWindow::on_ButtonVideo_clicked(void)" (?on_ButtonVideo_clicked#MainWindow##AAEHXZ)".
mainwindow.obj:-1: error: LNK2019: unresolved external symbol ""bool __cdecl cv::solvePnP(class cv::_InputArray const &,class cv::_InputArray const &,class cv::_InputArray const &,class cv::_InputArray const &,class cv::_OutputArray const &,class cv::_OutputArray const &,bool,int)" (?solvePnP#cv##YA_NABV_InputArray#1#000ABV_OutputArray#1#1_NH#Z)" in Funktion ""private: int __thiscall MainWindow::on_ButtonVideo_clicked(void)" (?on_ButtonVideo_clicked#MainWindow##AAEHXZ)".
mainwindow.obj:-1: error: LNK2019: unresolved external symbol ""bool __cdecl cv::findChessboardCorners(class cv::_InputArray const &,class cv::Size_<int>,class cv::_OutputArray const &,int)" (?findChessboardCorners#cv##YA_NABV_InputArray#1#V?$Size_#H#1#ABV_OutputArray#1#H#Z)" in Funktion ""private: int __thiscall MainWindow::on_ButtonVideo_clicked(void)" (?on_ButtonVideo_clicked#MainWindow##AAEHXZ)".
my .pro-file
QT += core gui widgets
TARGET = beispiel
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
INCLUDEPATH += C:/opencv/build/include/
LIBS += -LC:/opencv/build/x64/vc12/lib \
-lopencv_calib3d249 \
-lopencv_core249 \
-lopencv_highgui249 \
-lopencv_imgproc249
I installed opencv3.0 hoping that will fix it but it didn't.
Any help will be appreciated.
now I lost everything.
I cleaned and re-build the project.
now I get 16 Linking errors.
mainwindow.obj:-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::Mat::Mat(int,int,int,void *,unsigned int)" (??0Mat#cv##QAE#HHHPAXI#Z)".
mainwindow.obj:-1: 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::Mat::Mat(int,int,int,void *,unsigned int)" (??0Mat#cv##QAE#HHHPAXI#Z)".
mainwindow.obj:-1: error: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""void __cdecl cv::error(int,class cv::String const &,char const *,char const *,int)" (?error#cv##YAXHABVString#1#PBD1H#Z)" in Funktion ""public: __thiscall cv::Mat::Mat(int,int,int,void *,unsigned int)" (??0Mat#cv##QAE#HHHPAXI#Z)".
mainwindow.obj:-1: error: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""class cv::_InputOutputArray const & __cdecl cv::noArray(void)" (?noArray#cv##YAABV_InputOutputArray#1#XZ)" in Funktion ""private: int __thiscall MainWindow::on_ButtonVideo_clicked(void)" (?on_ButtonVideo_clicked#MainWindow##AAEHXZ)".
mainwindow.obj:-1: error: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: virtual bool __thiscall cv::FileStorage::open(class cv::String const &,int,class cv::String const &)" (?open#FileStorage#cv##UAE_NABVString#2#H0#Z)" in Funktion ""private: int __thiscall MainWindow::on_ButtonVideo_clicked(void)" (?on_ButtonVideo_clicked#MainWindow##AAEHXZ)".
mainwindow.obj:-1: error: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""void __cdecl cv::findContours(class cv::_InputOutputArray const &,class cv::_OutputArray const &,int,int,class cv::Point_<int>)" (?findContours#cv##YAXABV_InputOutputArray#1#ABV_OutputArray#1#HHV?$Point_#H#1##Z)" in Funktion ""private: int __thiscall MainWindow::on_ButtonVideo_clicked(void)" (?on_ButtonVideo_clicked#MainWindow##AAEHXZ)".
mainwindow.obj:-1: error: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""void __cdecl cv::line(class cv::_InputOutputArray const &,class cv::Point_<int>,class cv::Point_<int>,class cv::Scalar_<double> const &,int,int,int)" (?line#cv##YAXABV_InputOutputArray#1#V?$Point_#H#1#1ABV?$Scalar_#N#1#HHH#Z)" in Funktion ""private: int __thiscall MainWindow::on_ButtonVideo_clicked(void)" (?on_ButtonVideo_clicked#MainWindow##AAEHXZ)".
mainwindow.obj:-1: error: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""void __cdecl cv::circle(class cv::_InputOutputArray const &,class cv::Point_<int>,int,class cv::Scalar_<double> const &,int,int,int)" (?circle#cv##YAXABV_InputOutputArray#1#V?$Point_#H#1#HABV?$Scalar_#N#1#HHH#Z)" in Funktion ""private: int __thiscall MainWindow::on_ButtonVideo_clicked(void)" (?on_ButtonVideo_clicked#MainWindow##AAEHXZ)".
mainwindow.obj:-1: error: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""void __cdecl cv::ellipse(class cv::_InputOutputArray const &,class cv::Point_<int>,class cv::Size_<int>,double,double,double,class cv::Scalar_<double> const &,int,int,int)" (?ellipse#cv##YAXABV_InputOutputArray#1#V?$Point_#H#1#V?$Size_#H#1#NNNABV?$Scalar_#N#1#HHH#Z)" in Funktion ""private: int __thiscall MainWindow::on_ButtonVideo_clicked(void)" (?on_ButtonVideo_clicked#MainWindow##AAEHXZ)".
mainwindow.obj:-1: error: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""void __cdecl cv::ellipse(class cv::_InputOutputArray const &,class cv::RotatedRect const &,class cv::Scalar_<double> const &,int,int)" (?ellipse#cv##YAXABV_InputOutputArray#1#ABVRotatedRect#1#ABV?$Scalar_#N#1#HH#Z)" in Funktion ""private: int __thiscall MainWindow::on_ButtonVideo_clicked(void)" (?on_ButtonVideo_clicked#MainWindow##AAEHXZ)".
mainwindow.obj:-1: error: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""void __cdecl cv::projectPoints(class cv::_InputArray const &,class cv::_InputArray const &,class cv::_InputArray const &,class cv::_InputArray const &,class cv::_InputArray const &,class cv::_OutputArray const &,class cv::_OutputArray const &,double)" (?projectPoints#cv##YAXABV_InputArray#1#0000ABV_OutputArray#1#1N#Z)" in Funktion ""private: int __thiscall MainWindow::on_ButtonVideo_clicked(void)" (?on_ButtonVideo_clicked#MainWindow##AAEHXZ)".
mainwindow.obj:-1: error: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""bool __cdecl cv::solvePnP(class cv::_InputArray const &,class cv::_InputArray const &,class cv::_InputArray const &,class cv::_InputArray const &,class cv::_OutputArray const &,class cv::_OutputArray const &,bool,int)" (?solvePnP#cv##YA_NABV_InputArray#1#000ABV_OutputArray#1#1_NH#Z)" in Funktion ""private: int __thiscall MainWindow::on_ButtonVideo_clicked(void)" (?on_ButtonVideo_clicked#MainWindow##AAEHXZ)".
mainwindow.obj:-1: error: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""bool __cdecl cv::findChessboardCorners(class cv::_InputArray const &,class cv::Size_<int>,class cv::_OutputArray const &,int)" (?findChessboardCorners#cv##YA_NABV_InputArray#1#V?$Size_#H#1#ABV_OutputArray#1#H#Z)" in Funktion ""private: int __thiscall MainWindow::on_ButtonVideo_clicked(void)" (?on_ButtonVideo_clicked#MainWindow##AAEHXZ)".
mainwindow.obj:-1: error: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: virtual bool __thiscall cv::VideoCapture::read(class cv::_OutputArray const &)" (?read#VideoCapture#cv##UAE_NABV_OutputArray#2##Z)" in Funktion ""private: int __thiscall MainWindow::on_ButtonVideo_clicked(void)" (?on_ButtonVideo_clicked#MainWindow##AAEHXZ)".
mainwindow.obj:-1: error: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""void __cdecl cv::namedWindow(class cv::String const &,int)" (?namedWindow#cv##YAXABVString#1#H#Z)" in Funktion ""private: int __thiscall MainWindow::on_ButtonVideo_clicked(void)" (?on_ButtonVideo_clicked#MainWindow##AAEHXZ)".
mainwindow.obj:-1: error: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""void __cdecl cv::imshow(class cv::String const &,class cv::_InputArray const &)" (?imshow#cv##YAXABVString#1#ABV_InputArray#1##Z)" in Funktion ""private: int __thiscall MainWindow::on_ButtonVideo_clicked(void)" (?on_ButtonVideo_clicked#MainWindow##AAEHXZ)".
this my entire code:
#include "mainwindow.h"
using namespace cv;
using namespace std;
Point prevCenter_bl;
Point prevCenter_gr;
Point prevCenter_rd;
int boardHeight = 6;
int boardWidth = 9;
Size cbSize = Size(boardHeight,boardWidth);
string filename = "out_camera_data.yml";
//default image size
const int FRAME_WIDTH = 640;
const int FRAME_HEIGHT = 480;
//function prototypes
//void generate_boardPoints();
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->ButtonVideo, SIGNAL(clicked()), this, SLOT(on_ButtonVideo_clicked()) );
connect(ui->ButtonVideoRelease, SIGNAL(clicked()), this, SLOT(on_ButtonVideoRelease_clicked()) );
// connect(ui->videoFrame, SIGNAL(clicked()), this, SLOT(on_ButtonVideoRelease_clicked()) );
}
MainWindow::~MainWindow()
{
delete ui;
}
int MainWindow::on_ButtonVideo_clicked()
{
///init_chess_board
//set up a FileStorage object to read camera params from file
FileStorage fs;
fs.open(filename, FileStorage::READ);
// read camera matrix and distortion coefficients from file
Mat intrinsics, distortion;
fs["Camera_Matrix"] >> intrinsics;
fs["Distortion_Coefficients"] >> distortion;
// close the input file
fs.release();
//set up matrices for storage
Mat webcamImage, gray, one;
Mat rvec = Mat(Size(3,1), CV_64F);
Mat tvec = Mat(Size(3,1), CV_64F);
//setup vectors to hold the chessboard corners in the chessboard coordinate system and in the image
vector<Point2d> imagePoints, imageFramePoints, imageOrigin;
vector<Point3d> boardPoints, framePoints;
//generate vectors for the points on the chessboard
for (int i=0; i<boardWidth; i++)
{
for (int j=0; j<boardHeight; j++)
{
boardPoints.push_back( Point3d( double(i), double(j), 0.0) );
}
}
//generate points in the reference frame
framePoints.push_back( Point3d( 0.0, 0.0, 0.0 ) );
framePoints.push_back( Point3d( 5.0, 0.0, 0.0 ) );
framePoints.push_back( Point3d( 0.0, 5.0, 0.0 ) );
framePoints.push_back( Point3d( 0.0, 0.0, 5.0 ) );
///init_ellipse_tracking
// namedWindow("Control"); //create a window called "Control"
int iLowH_bl = 104; //0
int iHighH_bl = 179; //179
int iLowS_bl = 86; //0
int iHighS_bl = 255; //255
int iLowV_bl = 0; //0
int iHighV_bl = 255; //255
int sliderPos_bl = 70; //70
int iLowH_gr = 87; //0
int iHighH_gr = 102; //179
int iLowS_gr = 108; //0
int iHighS_gr = 238; //255
int iLowV_gr = 78; //0
int iHighV_gr = 175; //255
int sliderPos_gr = 70; //70
int iLowH_rd = 0; //0
int iHighH_rd = 34; //179
int iLowS_rd = 68; //0
int iHighS_rd = 255; //255
int iLowV_rd = 58; //0
int iHighV_rd = 117; //255
int sliderPos_rd = 70; //70
//Create trackbars in "Control" window
// cvCreateTrackbar("LowH", "Control", &iLowH, 179); //Hue (0 - 179)
// cvCreateTrackbar("HighH", "Control", &iHighH, 179);
// cvCreateTrackbar("LowS", "Control", &iLowS, 255); //Saturation (0 - 255)
// cvCreateTrackbar("HighS", "Control", &iHighS, 255);
// cvCreateTrackbar("LowV", "Control", &iLowV, 255); //Value (0 - 255)
// cvCreateTrackbar("HighV", "Control", &iHighV, 255);
//cvCreateTrackbar("Ellipse", "Control", &sliderPos, 255);
// cvResizeWindow("Control", 220, 50);
Mat imgOriginal;
VideoCapture cap(0); //capture the video from web cam
capture.set(CV_CAP_PROP_FRAME_WIDTH,FRAME_WIDTH);
capture.set(CV_CAP_PROP_FRAME_HEIGHT,FRAME_HEIGHT);
if ( !cap.isOpened() ) // if not success, exit program
{
cout << "Cannot open the web cam" << endl;
return -1;
}
while (true)
{
/// chess_board
//store image to matrix
capture.read(webcamImage);
//make a gray copy of the webcam image
cvtColor(webcamImage,gray,COLOR_BGR2GRAY);
//detect chessboard corners
bool found = findChessboardCorners(gray, cbSize, imagePoints, CALIB_CB_FAST_CHECK);
//drawChessboardCorners(webcamImage, cbSize, Mat(imagePoints), found);
//find camera orientation if the chessboard corners have been found
if ( found )
{
//find the camera extrinsic parameters
solvePnP( Mat(boardPoints), Mat(imagePoints), intrinsics, distortion, rvec, tvec, false );
//project the reference frame onto the image
projectPoints(framePoints, rvec, tvec, intrinsics, distortion, imageFramePoints );
//DRAWING
//draw the reference frame on the image
circle(webcamImage, (Point) imagePoints[0], 4 ,CV_RGB(255,0,0) );
Point one, two, three;
one.x=10; one.y=10;
two.x = 60; two.y = 10;
three.x = 10; three.y = 60;
line(webcamImage, one, two, CV_RGB(255,0,0) );
line(webcamImage, one, three, CV_RGB(0,255,0) );
line(webcamImage, imageFramePoints[0], imageFramePoints[1], CV_RGB(255,0,0), 2 );
line(webcamImage, imageFramePoints[0], imageFramePoints[2], CV_RGB(0,255,0), 2 );
line(webcamImage, imageFramePoints[0], imageFramePoints[3], CV_RGB(0,0,255), 2 );
//show the pose estimation data
cout << fixed << setprecision(2) << "rvec = ["
<< rvec.at<double>(0,0) << ", "
<< rvec.at<double>(1,0) << ", "
<< rvec.at<double>(2,0) << "] \t" << "tvec = ["
<< tvec.at<double>(0,0) << ", "
<< tvec.at<double>(1,0) << ", "
<< tvec.at<double>(2,0) << "]" << endl;
}
//show the image on screen
namedWindow("OpenCV Webcam", 0);
imshow("OpenCV Webcam", webcamImage);
//show the gray image
//namedWindow("Gray Image", CV_WINDOW_AUTOSIZE);
//imshow("Gray Image", gray);
/// ellipse_tracking
bool bSuccess = cap.read(imgOriginal); // read a new frame from video
if (!bSuccess) //if not success, break loop
{
cout << "Cannot read a frame from video stream" << endl;
break;
}
Mat imgHSV_bl;
Mat imgHSV_gr;
Mat imgHSV_rd;
cvtColor(imgOriginal, imgHSV_bl, COLOR_BGR2HSV); //Convert the captured frame from BGR to HSV
cvtColor(imgOriginal, imgHSV_gr, COLOR_BGR2HSV); //Convert the captured frame from BGR to HSV
cvtColor(imgOriginal, imgHSV_rd, COLOR_BGR2HSV); //Convert the captured frame from BGR to HSV
Mat imgThresholded_bl;
Mat imgThresholded_gr;
Mat imgThresholded_rd;
inRange(imgHSV_bl, Scalar(iLowH_bl, iLowS_bl, iLowV_bl), Scalar(iHighH_bl, iHighS_bl, iHighV_bl), imgThresholded_bl); //Threshold the image
inRange(imgHSV_gr, Scalar(iLowH_gr, iLowS_gr, iLowV_gr), Scalar(iHighH_gr, iHighS_gr, iHighV_gr), imgThresholded_gr); //Threshold the image
inRange(imgHSV_rd, Scalar(iLowH_rd, iLowS_rd, iLowV_rd), Scalar(iHighH_rd, iHighS_rd, iHighV_rd), imgThresholded_rd); //Threshold the image
//morphological opening (remove small objects from the foreground)
erode(imgThresholded_bl, imgThresholded_bl, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
erode(imgThresholded_gr, imgThresholded_gr, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
erode(imgThresholded_rd, imgThresholded_rd, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
dilate( imgThresholded_bl, imgThresholded_bl, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
dilate( imgThresholded_gr, imgThresholded_gr, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
dilate( imgThresholded_rd, imgThresholded_rd, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
//morphological closing (fill small holes in the foreground)
dilate( imgThresholded_bl, imgThresholded_bl, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
dilate( imgThresholded_gr, imgThresholded_gr, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
dilate( imgThresholded_rd, imgThresholded_rd, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
erode(imgThresholded_bl, imgThresholded_bl, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
erode(imgThresholded_gr, imgThresholded_gr, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
erode(imgThresholded_rd, imgThresholded_rd, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
// imshow("Thresholded Image Blue", imgThresholded_bl); //show the thresholded image
// imshow("Thresholded Image Green", imgThresholded_gr); //show the thresholded image
// imshow("Thresholded Image Red", imgThresholded_rd); //show the thresholded image
//imshow("Original", imgOriginal); //show the original image
///#### End sticker color selection ####
vector<vector<Point> > contours_bl;
vector<vector<Point> > contours_gr;
vector<vector<Point> > contours_rd;
Mat bimage_bl = imgThresholded_bl >= sliderPos_bl;
Mat bimage_gr = imgThresholded_gr >= sliderPos_gr;
Mat bimage_rd = imgThresholded_rd >= sliderPos_rd;
findContours(bimage_bl, contours_bl, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);
findContours(bimage_gr, contours_gr, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);
findContours(bimage_rd, contours_rd, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);
for(size_t i = 0; i < contours_bl.size(); i++){
size_t count = contours_bl[i].size();
if( count < 6 )
continue;
Mat pointsf;
Mat(contours_bl[i]).convertTo(pointsf, CV_32F);
RotatedRect box = fitEllipse(pointsf);
prevCenter_bl.x = box.center.x;
prevCenter_bl.y = box.center.y;
ellipse(imgOriginal, box, Scalar(0,0,255), 1, CV_AA);
ellipse(imgOriginal, box.center, box.size*0.0001f, box.angle, 0, 360, Scalar(0,255,255), 1, CV_AA);
line(imgOriginal, box.center, prevCenter_gr, cv::Scalar(0,255,0), 1, CV_AA);
}
for(size_t i = 0; i < contours_gr.size(); i++){
size_t count = contours_gr[i].size();
if( count < 6 )
continue;
Mat pointsf;
Mat(contours_gr[i]).convertTo(pointsf, CV_32F);
RotatedRect box = fitEllipse(pointsf);
prevCenter_gr.x = box.center.x;
prevCenter_gr.y = box.center.y;
ellipse(imgOriginal, box, Scalar(0,0,255), 1, CV_AA);
ellipse(imgOriginal, box.center, box.size*0.0001f, box.angle, 0, 360, Scalar(0,255,255), 1, CV_AA);
line(imgOriginal, box.center, prevCenter_rd, cv::Scalar(0,255,0), 1, CV_AA);
}
for(size_t i = 0; i < contours_rd.size(); i++){
size_t count = contours_rd[i].size();
if( count < 6 )
continue;
Mat pointsf;
Mat(contours_rd[i]).convertTo(pointsf, CV_32F);
RotatedRect box = fitEllipse(pointsf);
prevCenter_rd.x = box.center.x;
prevCenter_rd.y = box.center.y;
ellipse(imgOriginal, box, Scalar(0,0,255), 1, CV_AA);
ellipse(imgOriginal, box.center, box.size*0.0001f, box.angle, 0, 360, Scalar(0,255,255), 1, CV_AA);
line(imgOriginal, box.center, prevCenter_bl, cv::Scalar(0,255,0), 1, CV_AA);
}
imshow("result", imgOriginal);
waitKey(10);
}
return 0;
}
void MainWindow::on_ButtonVideoRelease_clicked()
{
if(capture.isOpened())
capture.release();
}
the header:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <opencv2/opencv.hpp>
#include <opencv/cv.hpp>
#include "ui_mainwindow.h"
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <iostream>
#include <stdio.h>
#include <string>
#include <iomanip>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
cv::VideoCapture capture;
private slots:
int on_ButtonVideo_clicked();
void on_ButtonVideoRelease_clicked();
};
#endif // MAINWINDOW_H
and the .pro
QT += core gui widgets
TARGET = beispiel
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
INCLUDEPATH += C:/opencv/build/include/
LIBS += -LC:/opencv/build/x64/vc12/lib \
-lopencv_calib3d249 \
-lopencv_core249 \
-lopencv_highgui249 \
-lopencv_imgproc249 \
it's still the same.
I have both opencv 2.4.9. and 3.0 installed, so there are those libs in the folder C:/opencv/build/x64/vc12/lib and C:/opencv/build/x64/vc12/staticlib.
what's the difference between lib and staticlib?
can anyone help pls?

You are trying to link one or more libraries that don't exist:
opencv_calib3d249
When I check the contents of the OpenCV 3.0 sfx I can only see these libraries:
opencv\build\x64\vc11\staticlib\opencv_calib3d300.lib
opencv\build\x64\vc12\staticlib\opencv_calib3d300.lib
opencv\build\x86\vc11\staticlib\opencv_calib3d300.lib
opencv\build\x86\vc12\staticlib\opencv_calib3d300.lib
So it seems to me that both the path to the libs (C:/opencv/build/x64/vc12/lib) and the version number in the files (249) are not correct.
If you want to look inside the .lib files you reference in order to find out which methods they export, use a command similar to this:
dumpbin opencv_calib3d300.lib /symbols
Dumpbin is part of Visual Studio, there is plenty of information available on SO, for example here.

Related

error LNK2019 and LNK2001 with VS2010 and Qt Library

I'm trying to reproduce the Qt example "webbrowser" (from qt-everywhere-opensource-src-4.8.3/examples/activeqt/webbrwowser) with VS2010 ((I work on windows7 x64).
So, I copied all files (.h and .cpp) from webbrowser folder to my project.
Also, in Project properties-->Linker-->input-->additional directives I added the following libraries:
phonon4.lib
QAxServer.lib
Qt3Support4.lib
QtCLucene4.lib
QtCore4.lib
QtDeclarative4.lib
QtDesigner4.lib
QtDesignerComponents4.lib
QtGui4.lib
QtHelp4.lib
Qtmain.lib
QtMultimedia4.lib
QtNetwork4.lib
QtOpenGL4.lib
QtScript4.lib
QtScriptTools4.lib
QtSql4.lib
QtSvg4.lib
QtTest4.lib
QtUiTools.lib
QtWebKit4.lib
QtXml4.lib
QtXmlPatterns4.lib
Now, when I press Debug button, I get these errors:
1>------ Inizio compilazione: Progetto: web_browser, Configurazione: Debug Win32 ------
1> main.cpp
1>main.obj : error LNK2019: riferimento al simbolo esterno "public: class QVariant __thiscall QAxBase::dynamicCall(char const *,class QVariant const &,class QVariant const &,class QVariant const &,class QVariant const &,class QVariant const &,class QVariant const &,class QVariant const &,class QVariant const &)" (?dynamicCall#QAxBase##QAE?AVQVariant##PBDABV2#1111111#Z) non risolto nella funzione "public: __thiscall MainWindow::MainWindow(void)" (??0MainWindow##QAE#XZ)
1>main.obj : error LNK2019: riferimento al simbolo esterno "public: bool __thiscall QAxBase::setControl(class QString const &)" (?setControl#QAxBase##QAE_NABVQString###Z) non risolto nella funzione "public: void __thiscall Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi#Ui_MainWindow##QAEXPAVQMainWindow###Z)
1>main.obj : error LNK2019: riferimento al simbolo esterno "public: __thiscall QAxWidget::QAxWidget(class QWidget *,class QFlags<enum Qt::WindowType>)" (??0QAxWidget##QAE#PAVQWidget##V?$QFlags#W4WindowType#Qt#####Z) non risolto nella funzione "public: __thiscall WebAxWidget::WebAxWidget(class QWidget *,class QFlags<enum Qt::WindowType>)" (??0WebAxWidget##QAE#PAVQWidget##V?$QFlags#W4WindowType#Qt#####Z)
1>main.obj : error LNK2001: simbolo esterno "public: virtual struct QMetaObject const * __thiscall QAxWidget::metaObject(void)const " (?metaObject#QAxWidget##UBEPBUQMetaObject##XZ) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual void * __thiscall QAxWidget::qt_metacast(char const *)" (?qt_metacast#QAxWidget##UAEPAXPBD#Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual int __thiscall QAxWidget::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#QAxWidget##UAEHW4Call#QMetaObject##HPAPAX#Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "protected: virtual void __thiscall QAxWidget::connectNotify(char const *)" (?connectNotify#QAxWidget##MAEXPBD#Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual class QSize __thiscall QAxWidget::sizeHint(void)const " (?sizeHint#QAxWidget##UBE?AVQSize##XZ) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual class QSize __thiscall QAxWidget::minimumSizeHint(void)const " (?minimumSizeHint#QAxWidget##UBE?AVQSize##XZ) non risolto
1>main.obj : error LNK2001: simbolo esterno "protected: virtual void __thiscall QAxWidget::resizeEvent(class QResizeEvent *)" (?resizeEvent#QAxWidget##MAEXPAVQResizeEvent###Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "protected: virtual void __thiscall QAxWidget::changeEvent(class QEvent *)" (?changeEvent#QAxWidget##MAEXPAVQEvent###Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual class QAxAggregated * __thiscall QAxWidget::createAggregate(void)" (?createAggregate#QAxWidget##UAEPAVQAxAggregated##XZ) non risolto
1>main.obj : error LNK2001: simbolo esterno "protected: virtual bool __thiscall QAxWidget::createHostWindow(bool)" (?createHostWindow#QAxWidget##MAE_N_N#Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual char const * __thiscall QAxWidget::className(void)const " (?className#QAxWidget##UBEPBDXZ) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual bool __thiscall QAxBase::propertyWritable(char const *)const " (?propertyWritable#QAxBase##UBE_NPBD#Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual void __thiscall QAxBase::setPropertyWritable(char const *,bool)" (?setPropertyWritable#QAxBase##UAEXPBD_N#Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual void __thiscall QAxWidget::clear(void)" (?clear#QAxWidget##UAEXXZ) non risolto
1>main.obj : error LNK2001: simbolo esterno "protected: virtual bool __thiscall QAxWidget::initialize(struct IUnknown * *)" (?initialize#QAxWidget##MAE_NPAPAUIUnknown###Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "private: virtual struct QMetaObject const * __thiscall QAxWidget::parentMetaObject(void)const " (?parentMetaObject#QAxWidget##EBEPBUQMetaObject##XZ) non risolto
1>main.obj : error LNK2019: riferimento al simbolo esterno "protected: virtual bool __thiscall QAxWidget::translateKeyEvent(int,int)const " (?translateKeyEvent#QAxWidget##MBE_NHH#Z) non risolto nella funzione "protected: virtual bool __thiscall WebAxWidget::translateKeyEvent(int,int)const " (?translateKeyEvent#WebAxWidget##MBE_NHH#Z)
1>main.obj : error LNK2019: riferimento al simbolo esterno "public: virtual __thiscall QAxWidget::~QAxWidget(void)" (??1QAxWidget##UAE#XZ) non risolto nella funzione "public: virtual __thiscall WebAxWidget::~WebAxWidget(void)" (??1WebAxWidget##UAE#XZ)
1>C:\Users\Cristina\Desktop\OpenCV\Progetti\ARUCO\web_browser\Debug\web_browser.exe : fatal error LNK1120: 21 esterni non risolti
========== Compilazione: 0 completate, 1 non riuscite, 0 aggiornate, 0 ignorate ==========
Here is main.cpp file:
#include <C:/Users/Cristina/Desktop/OpenCV/dep/qt/qt-everywhere-opensource-src-4.8.3/include/QtGui/qapplication.h>
#include <C:/Users/Cristina/Desktop/OpenCV/dep/qt/qt-everywhere-opensource-src-4.8.3/include/QtGui/QMessageBox>
#include <C:/Users/Cristina/Desktop/OpenCV/dep/qt/qt-everywhere-opensource-src-4.8.3/include/QtGui/QProgressBar>
#include <C:/Users/Cristina/Desktop/OpenCV/dep/qt/qt-everywhere-opensource-src-4.8.3/include/QtGui/QStatusBar>
#include <C:/Users/Cristina/Desktop/OpenCV/dep/qt/qt-everywhere-opensource-src-4.8.3/include/QtGui/QMainWindow>
#include <C:/Users/Cristina/Desktop/OpenCV/dep/qt/qt-everywhere-opensource-src-4.8.3/include/QtCore/QAbstractEventDispatcher>
#if defined(Q_WS_WINCE_WM)
#include "ui_mainwindow_windowsmobile.h"
#include <windows.h>
#else
#include "ui_mainwindow.h"
#endif
//! [0]
class MainWindow : public QMainWindow, public Ui::MainWindow
{
Q_OBJECT
public:
MainWindow();
public slots:
void on_WebBrowser_TitleChange(const QString &title);
void on_WebBrowser_ProgressChange(int a, int b);
void on_WebBrowser_CommandStateChange(int cmd, bool on);
void on_WebBrowser_BeforeNavigate();
void on_WebBrowser_NavigateComplete(QString);
void on_actionGo_triggered();
void on_actionNewWindow_triggered();
void on_actionAbout_triggered();
void on_actionAboutQt_triggered();
void on_actionFileClose_triggered();
private:
QProgressBar *pb;
};
//! [0] //! [1]
MainWindow::MainWindow()
{
setupUi(this);
connect(addressEdit, SIGNAL(returnPressed()), actionGo, SLOT(trigger()));
connect(actionBack, SIGNAL(triggered()), WebBrowser, SLOT(GoBack()));
connect(actionForward, SIGNAL(triggered()), WebBrowser, SLOT(GoForward()));
connect(actionStop, SIGNAL(triggered()), WebBrowser, SLOT(Stop()));
connect(actionRefresh, SIGNAL(triggered()), WebBrowser, SLOT(Refresh()));
connect(actionHome, SIGNAL(triggered()), WebBrowser, SLOT(GoHome()));
connect(actionSearch, SIGNAL(triggered()), WebBrowser, SLOT(GoSearch()));
pb = new QProgressBar(statusBar());
pb->setTextVisible(false);
pb->hide();
statusBar()->addPermanentWidget(pb);
WebBrowser->dynamicCall("GoHome()");
}
//! [1] //! [2]
void MainWindow::on_WebBrowser_TitleChange(const QString &title)
{
setWindowTitle("Qt WebBrowser - " + title);
}
void MainWindow::on_WebBrowser_ProgressChange(int a, int b)
{
if (a <= 0 || b <= 0) {
pb->hide();
return;
}
pb->show();
pb->setRange(0, b);
pb->setValue(a);
}
void MainWindow::on_WebBrowser_CommandStateChange(int cmd, bool on)
{
switch (cmd) {
case 1:
actionForward->setEnabled(on);
break;
case 2:
actionBack->setEnabled(on);
break;
}
}
void MainWindow::on_WebBrowser_BeforeNavigate()
{
actionStop->setEnabled(true);
}
void MainWindow::on_WebBrowser_NavigateComplete(QString)
{
actionStop->setEnabled(false);
}
//! [2] //! [3]
void MainWindow::on_actionGo_triggered()
{
WebBrowser->dynamicCall("Navigate(const QString&)", addressEdit->text());
}
void MainWindow::on_actionNewWindow_triggered()
{
MainWindow *window = new MainWindow;
window->show();
if (addressEdit->text().isEmpty())
return;
window->addressEdit->setText(addressEdit->text());
window->actionStop->setEnabled(true);
window->on_actionGo_triggered();
}
void MainWindow::on_actionAbout_triggered()
{
QMessageBox::about(this, tr("About WebBrowser"),
tr("This Example has been created using the ActiveQt integration into Qt Designer./n"
"It demonstrates the use of QAxWidget to embed the Internet Explorer ActiveX/n"
"control into a Qt application."));
}
void MainWindow::on_actionAboutQt_triggered()
{
QMessageBox::aboutQt(this, tr("About Qt"));
}
void MainWindow::on_actionFileClose_triggered()
{
close();
}
#include "C:/Users/Cristina/Desktop/OpenCV/dep/qt/qt-everywhere-opensource-src-4.8.3/examples/activeqt/webbrowser/tmp/moc/debug_shared/main.moc"
//! [3] //! [4]
int main(int argc, char ** argv)
{
QApplication a(argc, argv);
MainWindow w;
#if defined(Q_OS_WINCE)
w.showMaximized();
#else
w.show();
#endif
return a.exec();
}
//! [4]
Where I am wrong??
Thanks for your help!
I solved my problem. I linked libraries for release mode, but I compiled in debug mode. So the right libraries to link are:
phonond4.lib
QAxServerd.lib
Qt3Supportd4.lib
QtCLucened4.lib
QtCored4.lib
QAxContainerd.lib
and so on.
Hope it is of help to someone!

superbible lnk2019 glew

I'm working with Superbible 5th edition and I've already come across a problem with the first program. I've been able to fix a good amount of problems by adding in Windows.h and taking out the line #define FREEGLUT_STATIC, but I can't get past the linker errors I have right now.
#include <Windows.h>
#include <GLTools.h>
#include <GLShaderManager.h>
#include <gl\glew.h>
#include <gl\glut.h>
GLBatch triangleBatch;
GLShaderManager shaderManager;
void ChangeSize(int w, int h)
{
glViewport(0, 0, w, h);
}
void SetupRC()
{
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
shaderManager.InitializeStockShaders();
GLfloat vVerts[] =
{
-0.5f, 0.0f, 0.0f,
0.5f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f
};
triangleBatch.Begin(GL_TRIANGLES, 3);
triangleBatch.CopyVertexData3f(vVerts);
triangleBatch.End();
}
void RenderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
GLfloat vRed[] = { 1.0f, 0.0f, 0.0f, 1.0f };
shaderManager.UseStockShader(GLT_SHADER_IDENTITY, vRed);
triangleBatch.Draw();
glutSwapBuffers();
}
int main(int argc, char* argv[])
{
gltSetWorkingDirectory(argv[0]);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
glutInitWindowSize(800, 600);
glutCreateWindow("Triangle");
glutReshapeFunc(ChangeSize);
glutDisplayFunc(RenderScene);
GLenum err = glewInit();
if(GLEW_OK != err)
{
fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err));
return 1;
}
SetupRC();
glutMainLoop();
return 0;
}
and these are the errors I am getting:
1>triangle test.obj : error LNK2019: unresolved external symbol "public: void __thiscall GLBatch::End(void)" (?End#GLBatch##QAEXXZ) referenced in function "void __cdecl SetupRC(void)" (?SetupRC##YAXXZ)
1>triangle test.obj : error LNK2019: unresolved external symbol "public: void __thiscall GLBatch::Begin(unsigned int,unsigned int,unsigned int)" (?Begin#GLBatch##QAEXIII#Z) referenced in function "void __cdecl SetupRC(void)" (?SetupRC##YAXXZ)
1>triangle test.obj : error LNK2019: unresolved external symbol "public: bool __thiscall GLShaderManager::InitializeStockShaders(void)" (?InitializeStockShaders#GLShaderManager##QAE_NXZ) referenced in function "void __cdecl SetupRC(void)" (?SetupRC##YAXXZ)
1>triangle test.obj : error LNK2019: unresolved external symbol "public: void __thiscall GLBatch::CopyVertexData3f(float (*)[3])" (?CopyVertexData3f#GLBatch##QAEXPAY02M#Z) referenced in function "public: void __thiscall GLBatch::CopyVertexData3f(float *)" (?CopyVertexData3f#GLBatch##QAEXPAM#Z)
1>triangle test.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall GLBatch::Draw(void)" (?Draw#GLBatch##UAEXXZ) referenced in function "void __cdecl RenderScene(void)" (?RenderScene##YAXXZ)
1>triangle test.obj : error LNK2019: unresolved external symbol "public: int __cdecl GLShaderManager::UseStockShader(enum GLT_STOCK_SHADER,...)" (?UseStockShader#GLShaderManager##QAAHW4GLT_STOCK_SHADER##ZZ) referenced in function "void __cdecl RenderScene(void)" (?RenderScene##YAXXZ)
1>triangle test.obj : error LNK2019: unresolved external symbol _glewGetErrorString referenced in function _main
1>triangle test.obj : error LNK2019: unresolved external symbol _glewInit referenced in function _main
1>triangle test.obj : error LNK2019: unresolved external symbol "void __cdecl gltSetWorkingDirectory(char const *)" (?gltSetWorkingDirectory##YAXPBD#Z) referenced in function _main
1>triangle test.obj : error LNK2019: unresolved external symbol "public: __thiscall GLBatch::GLBatch(void)" (??0GLBatch##QAE#XZ) referenced in function "void __cdecl `dynamic initializer for 'triangleBatch''(void)" (??__EtriangleBatch##YAXXZ)
1>triangle test.obj : error LNK2019: unresolved external symbol "public: __thiscall GLShaderManager::GLShaderManager(void)" (??0GLShaderManager##QAE#XZ) referenced in function "void __cdecl `dynamic initializer for 'shaderManager''(void)" (??__EshaderManager##YAXXZ)
1>triangle test.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall GLBatch::~GLBatch(void)" (??1GLBatch##UAE#XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'triangleBatch''(void)" (??__FtriangleBatch##YAXXZ)
1>triangle test.obj : error LNK2019: unresolved external symbol "public: __thiscall GLShaderManager::~GLShaderManager(void)" (??1GLShaderManager##QAE#XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'shaderManager''(void)" (??__FshaderManager##YAXXZ)
It should be able to compile with just the included files from the website, but it's not.
You'll have to add some libraries to the project that provide the mentioned function bodies. You can do this using the project properties ("Linker", "Input", "Additional Dependencies") or a #pragma line anywhere in your source code:
#pragma comment(lib, "libraryname.lib")
I don't know about the library name; it's most likely explained somewhere in the book, but it might be GLTools.lib or GLShaderManager.lib (or something different; you should have these files somewhere alongside the include files (but in a lib directory).
Edit: You're missing the lib file for glew as well (glew32.lib).

Relinking to a modified DLL in another solution in Visual Studio 2010

I coded a BitPacker object that takes in various types of data and packs them to a buffer using the fewest number of bits required to store their values. I created a separate solution to make this into a DLL for reuse-ability. I was successfully able to link to it from another solution and use it. However I ran into the problem of these two function prototypes in the DLL being ambiguous when trying to pass in a long long for "data" instead of an int:
static __declspec(dllexport) unsigned long long UnpackBits(char *srcBuffer, long long data, unsigned int &offsetBits, const unsigned int numBits);
static __declspec(dllexport) unsigned int UnpackBits(char *srcBuffer, int data, unsigned int &offsetBits, const unsigned int numBits);
static __declspec(dllexport) float UnpackBits(char *srcBuffer, float data, unsigned int &offsetBits);
There is no problem when I'm simply passing an int. Since I can't think of a way to remove the ambiguity to support both data types I decided to modify the DLL source by commenting out the "long long" versions from the header and source files and recompiling them (both for Debug and Release). However after doing that I'm receiving linker errors for pretty much every call to that DLL now. I don't know why since I also changed the instances of where I was using a long long data member to int to make sure there was no reference to the old long long version that I commented out.
1>ChessGame.obj : error LNK2019: unresolved external symbol "public: static unsigned int __cdecl BitPacker::UnpackBits(char *,int,unsigned int &,unsigned int)" (?UnpackBits#BitPacker##SAIPADHAAII#Z) referenced in function "public: class ChessGame * __thiscall ChessGame::LoadGame(char const *)" (?LoadGame#ChessGame##QAEPAV1#PBD#Z)
1>Date.obj : error LNK2001: unresolved external symbol "public: static unsigned int __cdecl BitPacker::UnpackBits(char *,int,unsigned int &,unsigned int)" (?UnpackBits#BitPacker##SAIPADHAAII#Z)
1>Turn.obj : error LNK2001: unresolved external symbol "public: static unsigned int __cdecl BitPacker::UnpackBits(char *,int,unsigned int &,unsigned int)" (?UnpackBits#BitPacker##SAIPADHAAII#Z)
1>ChessGame.obj : error LNK2019: unresolved external symbol "public: static int __cdecl BitPacker::ReadFile(char const *,char *,int)" (?ReadFile#BitPacker##SAHPBDPADH#Z) referenced in function "public: class ChessGame * __thiscall ChessGame::LoadGame(char const *)" (?LoadGame#ChessGame##QAEPAV1#PBD#Z)
1>ChessGame.obj : error LNK2019: unresolved external symbol "public: static int __cdecl BitPacker::FileSize(char const *)" (?FileSize#BitPacker##SAHPBD#Z) referenced in function "public: class ChessGame * __thiscall ChessGame::LoadGame(char const *)" (?LoadGame#ChessGame##QAEPAV1#PBD#Z)
1>ChessGame.obj : error LNK2019: unresolved external symbol "public: static void __cdecl BitPacker::PackBits(char *,int,unsigned int &,unsigned int)" (?PackBits#BitPacker##SAXPADHAAII#Z) referenced in function "public: int __thiscall ChessGame::SaveGame(char const *)" (?SaveGame#ChessGame##QAEHPBD#Z)
1>Date.obj : error LNK2001: unresolved external symbol "public: static void __cdecl BitPacker::PackBits(char *,int,unsigned int &,unsigned int)" (?PackBits#BitPacker##SAXPADHAAII#Z)
1>Turn.obj : error LNK2001: unresolved external symbol "public: static void __cdecl BitPacker::PackBits(char *,int,unsigned int &,unsigned int)" (?PackBits#BitPacker##SAXPADHAAII#Z)
1>ChessGame.obj : error LNK2019: unresolved external symbol "public: static int __cdecl BitPacker::CopyBits(char *,char *,unsigned int &,unsigned int &,unsigned int)" (?CopyBits#BitPacker##SAHPAD0AAI1I#Z) referenced in function "public: int __thiscall ChessGame::SaveGame(char const *)" (?SaveGame#ChessGame##QAEHPBD#Z)
1>Turn.obj : error LNK2001: unresolved external symbol "public: static int __cdecl BitPacker::CopyBits(char *,char *,unsigned int &,unsigned int &,unsigned int)" (?CopyBits#BitPacker##SAHPAD0AAI1I#Z)
1>ChessGameManager.obj : error LNK2019: unresolved external symbol "public: static bool __cdecl BitPacker::FileExists(char const *)" (?FileExists#BitPacker##SA_NPBD#Z) referenced in function "public: void __thiscall ChessGameManager::RenderGameMenuIcons(void)" (?RenderGameMenuIcons#ChessGameManager##QAEXXZ)
1>C:\Users\rvandyke\Documents\Visual Studio 2010\Projects\SuperChessW32_v003\Debug\SuperChessW32_v003.exe : fatal error LNK1120: 6 unresolved externals
I tried cleaning the calling project, manually deleting all the object files and doing a Rebuild All but the errors remain. I'm thinking it is somehow still using an old version of the DLL header file and/or lib but don't know how or why. Is there something I need to do in my calling Solution for it to "re recognize" the new DLL?
PS - And while I'm asking anyone have any advice on the ambiguity problem? I'd like to be able to support both 32 and 64 bit data types but not sure how. I thought about simply getting rid of the int version and only having the long long version but then I worry about the possibility of data becoming truncated when catching the return type back into an int.

OpenCV Build on Visual Studio LINK error

I have followed this tutorial here as mentioned exactly
I now try to run simple OpenCV code on Visual Studio but it I keep getting linker errors.
I am trying this OpenCV tutorial in particular
Here is the error I keep getting :
1>Linking...
1>LINK : warning LNK4067: ambiguous entry point; selected 'mainCRTStartup'
1>OpenCV_Proj.obj : error LNK2019: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey#cv##YAHH#Z) referenced in function _main
1>OpenCV_Proj.obj : error LNK2019: unresolved 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) referenced in function _main
1>OpenCV_Proj.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::_InputArray::_InputArray(class cv::Mat const &)" (??0_InputArray#cv##QAE#ABVMat#1##Z) referenced in function _main
1>OpenCV_Proj.obj : error LNK2019: unresolved 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) referenced in function _main
1>OpenCV_Proj.obj : 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 _main
1>OpenCV_Proj.obj : 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)
1>OpenCV_Proj.obj : error LNK2019: unresolved external symbol "public: void __thiscall cv::Mat::copySize(class cv::Mat const &)" (?copySize#Mat#cv##QAEXABV12##Z) referenced in function "public: class cv::Mat & __thiscall cv::Mat::operator=(class cv::Mat const &)" (??4Mat#cv##QAEAAV01#ABV01##Z)
1>OpenCV_Proj.obj : 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)
1>C:\Users\Saher\Documents\Visual Studio 2008\Projects\OpenCV_Proj\Debug\OpenCV_Proj.exe : fatal error LNK1120: 8 unresolved externals``
For the following code :
// OpenCV_Proj.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file
if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image ); // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
I have been trying to get OpenCV to work for VS2008 for a while and any help regarding this issue will be apprectiated.
NOTE: In the readme file of the tutorial the following is what I followed:
1) Add build\bin and one of build\{x86|x64}\{vc9\vc10\mingw}\bin to your system path (to use DLLs)
Add build\{x86|x64}\{vc9\vc10\mingw}\lib or
build\{x86|x64}\{vc9\vc10\mingw}\staticlib as library directories to your linker settings,
Add build\include and build\include\opencv as include directories to your compiler settings.
Any help with getting this to work is really appreciated.
Those symbols are defined inside the OpenCV libraries, so you need to configure the project and let the linker know which OpenCV libraries you are using.
At the very least you should add: opencv_core230.lib and opencv_highgui230.lib (for OpenCV 2.3.0)
For more info on how to do this on VS2010, check this tutorial.
Go to properties->Linker->input and
add cv210.lib; cxcore210.lib; highgui210.lib;cvaux210.lib;
Your problem will be solved.
Have a happy coding....
I faced the same issue. After using dumpbin to see the exported symbols of highgui, I found that the linker is trying to link against a symbol that has debug_build_guard at the end.
If you built OPENCV in release mode, You cannot compile your application in DEBUG mode. Try flipping it to RELEASE and it magically works :)

wxWidgets defaultlib 'MSVCRT' conflicts problem

So, I have a small project with a very simple code. All it really does is create a wxFrame the following way:
wxFrame(NULL, -1, title, wxPoint(-1, -1), wxSize(380, 220))
There is no compiling problem to any of my code whatsoever. The problem occures when I do this line:
IMPLEMENT_APP(App);
App is:
class App: public wxApp
So, when I do that and I hit compile, I have the following errors:
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>CApp.obj : warning LNK4248: unresolved typeref token (01000019) for 'wxVideoMode'; image may not run
1>CLoadingFrame.obj : warning LNK4248: unresolved typeref token (01000019) for 'wxToolTip'; image may not run
1>CLoadingFrame.obj : warning LNK4248: unresolved typeref token (0100001A) for 'wxDropTarget'; image may not run
1>CLoadingFrame.obj : error LNK2020: unresolved token (0A000DB2) "int g_isPainting" (?g_isPainting##3HA)
1>CApp.obj : error LNK2020: unresolved token (0A000DBE) "int g_isPainting" (?g_isPainting##3HA)
1>CLoadingFrame.obj : error LNK2028: unresolved token (0A000DB4) "void __cdecl wxOnAssert(char const *,int,char const *,char const *,char const *)" (?wxOnAssert##$$FYAXPBDH000#Z) referenced in function "protected: void __thiscall wxShadowObjectFields_wxImplementation_HashTable::ResizeTable(unsigned int)" (?ResizeTable#wxShadowObjectFields_wxImplementation_HashTable##$$FIAEXI#Z)
1>CApp.obj : error LNK2028: unresolved token (0A000DC0) "void __cdecl wxOnAssert(char const *,int,char const *,char const *,char const *)" (?wxOnAssert##$$FYAXPBDH000#Z) referenced in function "protected: void const * __thiscall wxVectorBase::GetItem(unsigned int)const " (?GetItem#wxVectorBase##$$FIBEPBXI#Z)
1>CApp.obj : error LNK2019: unresolved external symbol "void __cdecl wxOnAssert(char const *,int,char const *,char const *,char const *)" (?wxOnAssert##$$FYAXPBDH000#Z) referenced in function "protected: void const * __thiscall wxVectorBase::GetItem(unsigned int)const " (?GetItem#wxVectorBase##$$FIBEPBXI#Z)
1>CLoadingFrame.obj : error LNK2001: unresolved external symbol "void __cdecl wxOnAssert(char const *,int,char const *,char const *,char const *)" (?wxOnAssert##$$FYAXPBDH000#Z)
1>CApp.obj : error LNK2001: unresolved external symbol "int g_isPainting" (?g_isPainting##3HA)
1>CLoadingFrame.obj : error LNK2001: unresolved external symbol "int g_isPainting" (?g_isPainting##3HA)
1>CApp.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall wxAppConsole::OnAssertFailure(char const *,int,char const *,char const *,char const *)" (?OnAssertFailure#wxAppConsole##UAEXPBDH000#Z)
1>CApp.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall wxAppConsole::OnAssert(char const *,int,char const *,char const *)" (?OnAssert#wxAppConsole##UAEXPBDH00#Z)
1>D:\WickedLauncher\WickedLauncherv2\Debug\WickedLauncherv2.exe : fatal error LNK1120: 8 unresolved externals
I would appreciate any help!
Regards.
where is defined g_isPainting ?
Did you add the right library to the linker for wxAppConsole ?

Resources