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).
Related
Right now I'm just trying to get 'www.google.com' to load in a webview when a button is pressed. After I added the webview in the designer the linker starts going crazy. I'm using QT Creater 2.6.1 with QT5 on Windows 7. I added the QT += 'webkit stuff' to the .pro file. I've tried cleaning and rebuilding, still get linker errors.
for some odd reason adding "#include <QWebView>" in any file produces a file not found error: "C:\Users\Scott\Desktop\eCookBook\eCookBook2\cookbook.cpp:3: error: C1083: Cannot open include file: 'QWebView': No such file or directory"
cookbook.h:
#ifndef COOKBOOK_H
#define COOKBOOK_H
#include <QMainWindow>
#include <QtWebKit/QWebElement>
#include <QtWebKit/QtWebKit>
#include <QtWebKitWidgets/QWebPage>
namespace Ui {
class cookBook;
}
class cookBook : public QMainWindow
{
Q_OBJECT
public:
explicit cookBook(QWidget *parent = 0);
~cookBook();
private slots:
void on_pushButton_clicked();
void on_textBrowser_anchorClicked(const QUrl &arg1);
private:
Ui::cookBook *ui;
//QWebPage page;
};
#endif // COOKBOOK_H
cookbook.cpp
#include "cookbook.h"
#include "ui_cookbook.h"
//#include <QWebView>
//#include <QtWebKit/QtWebKit>
cookBook::cookBook(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::cookBook)
{
ui->setupUi(this);
}
cookBook::~cookBook()
{
delete ui;
}
void cookBook::on_pushButton_clicked()
{
ui->listWidgetTest->insertItem(ui->listWidgetTest->count(), "TEST");
const QUrl testsite = "www.google.com";
ui->widget->load(testsite);
ui->widget->show();
}
.pro file
#-------------------------------------------------
#
# Project created by QtCreator 2013-01-23T14:46:45
#
#-------------------------------------------------
QT += core gui
QT += webkit
QT += webkit webkitwidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = eCookBook2
TEMPLATE = app
SOURCES += main.cpp\
cookbook.cpp
HEADERS += cookbook.h
FORMS += cookbook.ui
compiler output:
15:04:58: Running steps for project eCookBook2...
15:04:58: Configuration unchanged, skipping qmake step.
15:04:58: Starting: "C:\QtCommercial\QtCommercial5.0.0\Tools\QtCreator\bin\jom.exe"
C:\QtCommercial\QtCommercial5.0.0\Tools\QtCreator\bin\jom.exe -f Makefile.Debug
cl -c -nologo -Zm200 -Zc:wchar_t -Zi -MDd -GR -W3 -w34100 -w34189 -EHsc -DUNICODE -DWIN32 -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -I"..\..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include" -I"..\..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtWidgets" -I"..\..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtGui" -I"..\..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtCore" -I"debug" -I"." -I"." -I"..\..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\mkspecs\win32-msvc2010" -Fodebug\ #C:\Users\Scott\AppData\Local\Temp\cookbook.obj.5244.0.jom
cookbook.cpp
..\eCookBook2\cookbook.cpp(34) : warning C4100: 'arg1' : unreferenced formal parameter
echo 1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ "debug\\eCookBook2.exe.embed.manifest">debug\eCookBook2.exe_manifest.rc
if not exist debug\eCookBook2.exe del debug\eCookBook2.exe.embed.manifest>NUL 2>&1
if exist debug\eCookBook2.exe.embed.manifest copy /Y debug\eCookBook2.exe.embed.manifest debug\eCookBook2.exe_manifest.bak
link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST /MANIFESTFILE:debug\eCookBook2.exe.embed.manifest /OUT:debug\eCookBook2.exe #C:\Users\Scott\AppData\Local\Temp\eCookBook2.exe.5244.2012.jom
cookbook.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QWebView::QWebView(class QWidget *)" (__imp_??0QWebView##QAE#PAVQWidget###Z) referenced in function "public: void __thiscall Ui_cookBook::setupUi(class QMainWindow *)" (?setupUi#Ui_cookBook##QAEXPAVQMainWindow###Z)
cookbook.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall QWebView::metaObject(void)const " (?metaObject#QWebView##UBEPBUQMetaObject##XZ)
cookbook.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall QWebView::qt_metacast(char const *)" (?qt_metacast#QWebView##UAEPAXPBD#Z)
cookbook.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall QWebView::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#QWebView##UAEHW4Call#QMetaObject##HPAPAX#Z)
cookbook.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QWebView::event(class QEvent *)" (?event#QWebView##UAE_NPAVQEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "public: virtual class QSize __thiscall QWebView::sizeHint(void)const " (?sizeHint#QWebView##UBE?AVQSize##XZ)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::mousePressEvent(class QMouseEvent *)" (?mousePressEvent#QWebView##MAEXPAVQMouseEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::mouseReleaseEvent(class QMouseEvent *)" (?mouseReleaseEvent#QWebView##MAEXPAVQMouseEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::mouseDoubleClickEvent(class QMouseEvent *)" (?mouseDoubleClickEvent#QWebView##MAEXPAVQMouseEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::mouseMoveEvent(class QMouseEvent *)" (?mouseMoveEvent#QWebView##MAEXPAVQMouseEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::wheelEvent(class QWheelEvent *)" (?wheelEvent#QWebView##MAEXPAVQWheelEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::keyPressEvent(class QKeyEvent *)" (?keyPressEvent#QWebView##MAEXPAVQKeyEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::keyReleaseEvent(class QKeyEvent *)" (?keyReleaseEvent#QWebView##MAEXPAVQKeyEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::focusInEvent(class QFocusEvent *)" (?focusInEvent#QWebView##MAEXPAVQFocusEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::focusOutEvent(class QFocusEvent *)" (?focusOutEvent#QWebView##MAEXPAVQFocusEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::paintEvent(class QPaintEvent *)" (?paintEvent#QWebView##MAEXPAVQPaintEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::resizeEvent(class QResizeEvent *)" (?resizeEvent#QWebView##MAEXPAVQResizeEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::contextMenuEvent(class QContextMenuEvent *)" (?contextMenuEvent#QWebView##MAEXPAVQContextMenuEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::dragEnterEvent(class QDragEnterEvent *)" (?dragEnterEvent#QWebView##MAEXPAVQDragEnterEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::dragMoveEvent(class QDragMoveEvent *)" (?dragMoveEvent#QWebView##MAEXPAVQDragMoveEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::dragLeaveEvent(class QDragLeaveEvent *)" (?dragLeaveEvent#QWebView##MAEXPAVQDragLeaveEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::dropEvent(class QDropEvent *)" (?dropEvent#QWebView##MAEXPAVQDropEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::changeEvent(class QEvent *)" (?changeEvent#QWebView##MAEXPAVQEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::inputMethodEvent(class QInputMethodEvent *)" (?inputMethodEvent#QWebView##MAEXPAVQInputMethodEvent###Z)
cookbook.obj : error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QWebView::inputMethodQuery(enum Qt::InputMethodQuery)const " (?inputMethodQuery#QWebView##UBE?AVQVariant##W4InputMethodQuery#Qt###Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall QWebView::focusNextPrevChild(bool)" (?focusNextPrevChild#QWebView##MAE_N_N#Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual class QWebView * __thiscall QWebView::createWindow(enum QWebPage::WebWindowType)" (?createWindow#QWebView##MAEPAV1#W4WebWindowType#QWebPage###Z)
cookbook.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QWebView::~QWebView(void)" (__imp_??1QWebView##UAE#XZ) referenced in function "public: virtual void * __thiscall QWebView::`scalar deleting destructor'(unsigned int)" (??_GQWebView##UAEPAXI#Z)
cookbook.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QWebView::load(class QUrl const &)" (__imp_?load#QWebView##QAEXABVQUrl###Z) referenced in function "private: void __thiscall cookBook::on_pushButton_clicked(void)" (?on_pushButton_clicked#cookBook##AAEXXZ)
debug\eCookBook2.exe : fatal error LNK1120: 29 unresolved externals
jom: C:\Users\Scott\Desktop\eCookBook\eCookBook2-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Debug\Makefile.Debug [debug\eCookBook2.exe] Error 1120
jom: C:\Users\Scott\Desktop\eCookBook\eCookBook2-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Debug\Makefile [debug] Error 2
15:05:01: The process "C:\QtCommercial\QtCommercial5.0.0\Tools\QtCreator\bin\jom.exe" exited with code 2.
Error while building/deploying project eCookBook2 (kit: Desktop Qt 5.0.0 MSVC2010 32bit (SDK))
When executing step 'Make'
First try "Run qmake" (from the "Build" menu in Creator) to regenerate the make files and then re-build. Basically you need "Run qmake" after every modification in the .pro file.
Press Ctrl+5 in Creator.
Uncheck "Shadow build".
Change your .pro file line to:
QT += core gui network webkit webkitwidgets
Rebuild the project
The same bug fixed. Try to add path to qwebview.h in the include like:
(change "QtWebKitWidgets" to yours)
#include <QtWebKitWidgets/QWebView.h>
instead of just #include <QWebView.h>
Try to add it to all files that use QWebView.
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.
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 :)
I have a C++ project that uses IBPP to access a firebird database. I simply do it by including the file "all_in_one.cpp" in my project, and all went well with both VS6 (yes, I still have some of those) and VS2008.
Now I am considering using VS2010. It is compiling ok but does not link. I know VS2010 comes with a new implementation of the STL, and the linking problem obviously is around the STL.
I have tried creating a new project with VS2010, just adding the all_in_one.cpp file. It is a simple project that does not contain anything else, and it still fails to link with the same missing symbols. I can't figure out what's missing, incorrect. I have tried linking to the same libraries as in VS2008 (including the path). Nothing is working so far.
Here are the errors:
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) struct std::_Smanip<__int64> __cdecl std::setw(__int64)" (__imp_?setw#std##YA?AU?$_Smanip#_J#1#_J#Z) referenced in function "public: char const * __thiscall IBPP::DBKey::AsString(void)const " (?AsString#DBKey#IBPP##QBEPBDXZ)
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::_Container_base12::_Orphan_all(void)" (__imp_?_Orphan_all#_Container_base12#std##QAEXXZ) referenced in function "public: class std::vector<double,class std::allocator<double> > & __thiscall std::vector<double,class std::allocator<double> >::operator=(class std::vector<double,class std::allocator<double> > const &)" (??4?$vector#NV?$allocator#N#std###std##QAEAAV01#ABV01##Z)
all_in_one.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Lock(void)" (?_Lock#?$basic_streambuf#DU?$char_traits#D#std###std##UAEXXZ)
all_in_one.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Unlock(void)" (?_Unlock#?$basic_streambuf#DU?$char_traits#D#std###std##UAEXXZ)
all_in_one.obj : error LNK2001: unresolved external symbol "protected: virtual __int64 __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::showmanyc(void)" (?showmanyc#?$basic_streambuf#DU?$char_traits#D#std###std##MAE_JXZ)
all_in_one.obj : error LNK2001: unresolved external symbol "protected: virtual __int64 __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::xsgetn(char *,__int64)" (?xsgetn#?$basic_streambuf#DU?$char_traits#D#std###std##MAE_JPAD_J#Z)
all_in_one.obj : error LNK2001: unresolved external symbol "protected: virtual __int64 __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::xsputn(char const *,__int64)" (?xsputn#?$basic_streambuf#DU?$char_traits#D#std###std##MAE_JPBD_J#Z)
all_in_one.obj : error LNK2001: unresolved external symbol "protected: virtual class std::basic_streambuf<char,struct std::char_traits<char> > * __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::setbuf(char *,__int64)" (?setbuf#?$basic_streambuf#DU?$char_traits#D#std###std##MAEPAV12#PAD_J#Z)
all_in_one.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) __int64 const std::_BADOFF" (__imp_?_BADOFF#std##3_JB)
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl std::_Xlength_error(char const *)" (__imp_?_Xlength_error#std##YAXPBD#Z) referenced in function "public: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Xlen(void)const " (?_Xlen#?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##QBEXXZ)
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl std::_Xout_of_range(char const *)" (__imp_?_Xout_of_range#std##YAXPBD#Z) referenced in function "public: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Xran(void)const " (?_Xran#?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##QBEXXZ)
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base12::~_Container_base12(void)" (__imp_??1_Container_base12#std##QAE#XZ) referenced in function __unwindfunclet$??0?$_String_val#DV?$allocator#D#std###std##QAE#V?$allocator#D#1##Z$0
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base12::_Container_base12(void)" (__imp_??0_Container_base12#std##QAE#XZ) referenced in function "public: __thiscall std::_String_val<char,class std::allocator<char> >::_String_val<char,class std::allocator<char> >(class std::allocator<char>)" (??0?$_String_val#DV?$allocator#D#std###std##QAE#V?$allocator#D#1##Z)
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: struct std::_Iterator_base12 * * __thiscall std::_Container_base12::_Getpfirst(void)const " (__imp_?_Getpfirst#_Container_base12#std##QBEPAPAU_Iterator_base12#2#XZ) referenced in function "protected: void __thiscall std::vector<class ibpp_internals::TransactionImpl *,class std::allocator<class ibpp_internals::TransactionImpl *> >::_Orphan_range(class ibpp_internals::TransactionImpl * *,class ibpp_internals::TransactionImpl * *)const " (?_Orphan_range#?$vector#PAVTransactionImpl#ibpp_internals##V?$allocator#PAVTransactionImpl#ibpp_internals###std###std##IBEXPAPAVTransactionImpl#ibpp_internals##0#Z)
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __int64 __thiscall std::ios_base::width(__int64)" (__imp_?width#ios_base#std##QAE_J_J#Z) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits#D#std###std##YAAAV?$basic_ostream#DU?$char_traits#D#std###0#AAV10#PBD#Z)
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __int64 __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,__int64)" (__imp_?sputn#?$basic_streambuf#DU?$char_traits#D#std###std##QAE_JPBD_J#Z) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits#D#std###std##YAAAV?$basic_ostream#DU?$char_traits#D#std###0#AAV10#PBD#Z)
all_in_one.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __int64 __thiscall std::ios_base::width(void)const " (__imp_?width#ios_base#std##QBE_JXZ) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits#D#std###std##YAAAV?$basic_ostream#DU?$char_traits#D#std###0#AAV10#PBD#Z)
It seems your library/DLL is exporting some templated/STL stuff.
STL is not binary compatible among different compiler versions.
You need to use same compiler/linker/bitness to compile and link the DLL/EXE if STL/template is involved.
Remove the all_in_one.cpp from build and use the other files from core to build the library.
Concerning linker errors 10 and 11 from the error list above, I have the following solution
(probably it fixes all errors).
Open the property pages of your project by right clicking your project inside the Solution Explorer and selecting "Properties".
Inside the "Property Pages"-window:
--> open "Configuration Properties" from left menu
--> select "VC++ Directories" on the left
--> go to "Library Directories" on the right
--> the corresponding string should contain a sub-string like
"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib"
--> replace "9.0" by "10.0"
to make the changes working "re"build your solution (perhaps clean your solution first).
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 ?