Linking error in VS2010 with GLew/ GLee/ Unofficial OpenGL SDK - visual-studio-2010

I am running Visual Studio 2010 Professional on a Windows 7 64bit laptop (HP Pavilion g6)
Unofficial OpenGL SDK: http://glsdk.sourceforge.net/docs/html/index.html
Unofficial OpenGL SDK, GLew, & GLee are all up to date, with matching drivers, libs and headers where appropriate
Settings:
Preprocessor either over the entire project OR over the main.c file: GLEW_STATIC
Additional Include Directories:
C:/glsdk_0.4.2/glload/include;C:/glsdk_0.4.2/glimg/include;C:/glsdk_0.4.2/glutil/include;C:/glsdk_0.4.2/glmesh/include;C:/glsdk_0.4.2/glm;C:/glsdk_0.4.2/glfw/include;C:/glsdk_0.4.2/freeglut/include;
Additional Library Directories:
C:/glsdk_0.4.2/glload/lib;C:/glsdk_0.4.2/glimg/lib;C:/glsdk_0.4.2/glutil/lib;C:/glsdk_0.4.2/glmesh/lib;C:/glsdk_0.4.2/glfw/library;C:/glsdk_0.4.2/freeglut/lib;
Also tried adding C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib/glew32s.lib (or glew32, glew32mx & glew32mxs);C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib/OpenGL32.lib; in Linker -> Input -> Additional Dependancies
Path Inputs (Changed through Environment Variables. Excluding irrelevant entries):
C:\glsdk_0.4.2\glutil\lib;C:\glsdk_0.4.2\freeglut\lib;C:\glsdk_0.4.2\glfw\library;C:\glsdk_0.4.2\glload\lib;C:\glsdk_0.4.2\glimg\lib;
GLew & GLee lib files are located in:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib
Also tried with them located at:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib
GLew & GLee header files are located in:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\GL
Also tried with them located at:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\GL
Code (other than headers) copied from "OpenGL Distilled", ISBN10 - 0-321-33679-8:
#include <stdio.h>
#include <math.h>
// Uncomment for GLee ( Also comment out glutInit(&argc, argv); )
//#include <GL\GLee.h>
// Uncomment for GLew
/*#include <GL\glew.h>
#include <GL\wglew.h>
#include <GL\glut.h>
#include <GL\glext.h> */
// Uncomment for all headers in the "Unofficial OpenGL SDK"
/*#include <glload\gl_all.h>
#include <GL\glut.h>
#include <glload\gll.h>
#include <glimg\glimg.h>
#include <glutil\glutil.h>
#include <glmesh\glmesh.h>
#include <GL\glfw.h>
#define FREEGLUT_STATIC
#define _LIB
#define FREEGLUT_LIB_PRAGMAS 0
#include <GL\freeglut.h> */
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
// Obtain a buffer identifier from OpenGL
GLuint bufferID = 0;
glGenBuffers( 1, &bufferID );
// Bind the buffer object, OpenGL initially creates it empty.
glBindBuffer( GL_ARRAY_BUFFER, bufferID );
// Define three vertices to draw a right angle triangle.
const GLfloat vertices[] = [
0.f, 0.f, 0.f,
1.f, 0.f, 0.f,
0.f, 1.f, 0.f };
// Tell OpenGL to copy data from the 'vertices' pointer into
// the buffer object
glBufferData(GL_ARRAY_BUFFER, 3*3*sizeof(GLfloat), vertices, GL_STATIC_DRAW );
return 0;
}
Errors:
With GLee:
1>gl_crap3.obj : error LNK2001: unresolved external symbol _GLeeFuncPtr_glBufferData
1>gl_crap3.obj : error LNK2001: unresolved external symbol _GLeeFuncPtr_glBindBuffer
1>gl_crap3.obj : error LNK2001: unresolved external symbol _GLeeFuncPtr_glGenBuffers
With the Unofficial OpenGL SDK:
1>gl_crap3.obj : error LNK2001: unresolved external symbol ___gleBufferData
1>gl_crap3.obj : error LNK2001: unresolved external symbol ___gleBindBuffer
1>gl_crap3.obj : error LNK2001: unresolved external symbol ___gleGenBuffers
With GLew:
1>gl_crap3.obj : error LNK2001: unresolved external symbol ___glewBufferData
1>gl_crap3.obj : error LNK2001: unresolved external symbol ___glewBindBuffer
1>gl_crap3.obj : error LNK2001: unresolved external symbol ___glewGenBuffers

For the SDK, your Visual Studio project should have the following settings (where sdkbase is the path to the directory you unzipped and compiled the SDK in).
C/C++->General->Additional Include Directories:
sdkbase\glload\include;sdkbase\glimg\include;sdkbase\glutil\include;sdkbase\glmesh\include;sdkbase\glm;sdkbase\freeglut\include;sdkbase\glfw\include
Linker->General->Additional Library Directories:
sdkbase\glload\lib;sdkbase\glimg\lib;sdkbase\glutil\lib;sdkbase\glmesh\lib;sdkbase\freeglut\lib;sdkbase\glfw\library
Linker->Input/Additional Dependencies, for debug builds:
glloadD.lib glimgD.lib glutilD.lib glmeshD.lib freeglutD.lib glfwD.lib glu32.lib opengl32.lib gdi32.lib winmm.lib user32.lib
For release builds:
glload.lib glimg.lib glutil.lib glmesh.lib freeglut.lib glfw.lib glu32.lib opengl32.lib gdi32.lib winmm.lib user32.lib

For people not using the Unofficial OpenGL SDK, I had just run into this problem and, thanks to Nicol Bolas' answer, realized I needed debug libraries for GLEW.
For Visual Studio, I fixed this by replacing glew32.lib in my project's debug configuration - at linker->input/Additional Dependencies - with glew32s.lib (note the s at the end).
After I did that, everything worked fine.
Note
While you may be able to initialize GLEW and use GLEW specific functions without this fix, as soon as you start making calls to OpenGL you will probably get the error, when building with debug symbols.

Related

QuantLib Date class in Visual C++ 2010

I just started this simple Quantlib date class in VC++ Express 2010:
#include <iostream>
#include <sstream>
#include "ql/time/date.hpp"
int main(int, char* [])
{
QuantLib::Date d(1, QuantLib::January, 2010);
std::cout<<da<<std::endl;
}
When I compiled it, this is one of the errors:
1>ql_inout.obj : error LNK2019: unresolved external symbol "public: __thiscall QuantLib::Date::Date(int,enum QuantLib::Month,int)" (??0Date#QuantLib##QAE#HW4Month#1#H#Z) referenced in function _main
It must be something I didn't setup correctly in 2010 project. I have compiled the library in Debug mode successfully.
Not all headers include the pragma that tells the linker to add QuantLib. If you don't want to include the full headers—which is advisable, as they would increase a lot your compilation time—you can add
#include <ql/auto_link.hpp>
to the included headers.
(You could also add the library explicitly to the linker options, but that is a lot more work since you have to specify different library names depending on the configuration. auto_link.hpp does this for you.)

LNK2019: unresolved external symbol error in Visual Studio C++

This is my code in Visual Studio C++
#include "stdafx.h"
#include<opencv\cv.h>
#include<opencv\highgui.h>
using namespace cv;
int main(int argc, char** argv[]) {
IplImage* img = cvLoadImage("logo.jpg");
cvNamedWindow("Test", CV_WINDOW_AUTOSIZE);
cvShowImage("Test", img);
cvWaitKey(0);
cvReleaseImage(&img);
cvDestroyWindow("Test");
return 0;
}
I am using OpenCV 2.4.6 and Visual Studio 2010. This is the error:
openCV_testing.obj : error LNK2019: unresolved external symbol _cvDestroyWindow
referenced in function _main
openCV_testing.obj : error LNK2019: unresolved external symbol _cvReleaseImage
referenced in function _main
openCV_testing.obj : error LNK2019: unresolved external symbol _cvWaitKey referenced in
function _main
openCV_testing.obj : error LNK2019: unresolved external symbol _cvShowImage referenced
in function _main
openCV_testing.obj : error LNK2019: unresolved external symbol _cvNamedWindow
referenced in function _main
openCV_testing.obj : error LNK2019: unresolved external symbol _cvLoadImage referenced
in function _main
Please help.
'unresolved external symbol' means that you're not linking with required library.
Go to Properties -> Linker -> Additional Library dependencies and add path to OpenCV libs.
First check
How to build applications with OpenCV inside the Microsoft Visual Studio
If you still suffer from the same problem, you could be under one of the below cases.
Your active solution platform is x86 but you are trying to link x64 OpenCV libraries.
Your active solution platform is X64 but you are trying to link x86 OpenCV libraries.
If you are under one of these cases, check
Compiling a 64-bit Application in Microsoft Visual Studio Express 2010
Add these into your code:
#pragma comment (lib, "opencv_core248d.lib")
#pragma comment (lib, "opencv_highgui248d.lib")
#pragma comment (lib, "opencv_imgproc248d.lib")
#pragma comment (lib, "opencv_video248d.lib")
#pragma comment (lib, "opencv_features2d248d.lib")
It worked for me.
i searched a lot for the same problem this was the best solution i had found and it worked for me.
Open Configuration Properties > C/C++ > General, and edit the field Additional Include Directories to add these 3 paths (for the headers):
C:\OpenCV2.3\build\include\opencv
C:\OpenCV2.3\build\include\opencv2
C:\OpenCV2.3\build\include
I know this is not about the OpenCV library, but I already had a problem importing Tiny-Process library. My .lib file was linked correctly in Configuration Properties -> Linker -> Additional Library dependencies and the Additionnal Include Directories were correctly added but the the functions definition (s) were still not found and I was getting the LNK2019 error.
To fix the issue, I had to go in the library project properties, change the Character Set property in Configuration Properties -> Advanced Character Set and change the value Use Multi-Byte Character Set to Use Unicode Character Set.
After recompiling the library and using the new .lib file, it was working.

Linker errors (LNK2001) with Boost library (filesystem.hpp) in CLI/CLR code

I have been trying to figure this out for a few days and can't seem to find a solution. I am creating a Windows Forms application inside of MSVS 2012 (but the application itself is using MSVS 2010 binaries and .NET 4.0). The application requires the use of CLI/CLR managed code.
I have followed the Getting Started guide and built the libraries using:
bootstrap.bat
.\b2.exe --toolset=msvc-10.0 --build-type=complete
I setup/linked the directories to my project inside of Visual Studio:
C/C++ > General > Additional Include Directories > "C:\Program Files %28x86%29\Microsoft Visual Studio 11.0\Boost"
Linker > General > Additional Library Directories > "C:\Program Files %28x86%29\Microsoft Visual Studio 11.0\Boost\stage\lib"
Here is all that I added to my previously compiling and executing code:
#define BOOST_LIB_DIAGNOSTIC //show diagnostics
#define BOOST_USE_WINDOWS_H
#define BOOST_FILESYSTEM_NO_DEPRECATED //don't use deprecated code
#include <boost/filesystem.hpp>
using namespace boost::filesystem;
Here is the output of the build (Release/Win32):
1>------ Build started: Project: PROJECT_NAME (Visual Studio 2010), Configuration: Release Win32 ------
1> PROJECT_NAME.cpp
1> Linking to lib file: libboost_filesystem-vc100-mt-1_53.lib
1> Linking to lib file: libboost_system-vc100-mt-1_53.lib
1>PROEJCT_NAME.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __clrcall boost::system::system_category(void)" (?system_category#system#boost##$$FYMABVerror_category#12#XZ)
1>PROJECT_NAME.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __clrcall boost::system::generic_category(void)" (?generic_category#system#boost##$$FYMABVerror_category#12#XZ)
1>PROJECT_NAME.obj : error LNK2001: unresolved external symbol "void __clrcall boost::filesystem::path_traits::convert(wchar_t const *,wchar_t const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class std::codecvt<wchar_t,char,int> const &)" (?convert#path_traits#filesystem#boost##$$FYMXPB_W0AAV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##ABV?$codecvt#_WDH#5##Z)
1>PROJECT_NAME.obj : error LNK2001: unresolved external symbol "public: static class std::codecvt<wchar_t,char,int> const & __clrcall boost::filesystem::path::codecvt(void)" (?codecvt#path#filesystem#boost##$$FSMABV?$codecvt#_WDH#std##XZ)
1>PROJECT_NAME.obj : error LNK2001: unresolved external symbol "class boost::system::error_code __clrcall boost::filesystem::detail::dir_itr_close(void * &)" (?dir_itr_close#detail#filesystem#boost##$$FYM?AVerror_code#system#3#AAPAX#Z)
1>C:\Users\USERNAME\Documents\Visual Studio 2012\Projects\PROJECT_NAME\Release\PROJECT_NAME.exe : fatal error LNK1120: 5 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Do I still not have something built/linked correctly? Let me know if there's more information needed and I will supply what I can.
Reviving an old post, I know, but I spent a long time trying to figure out a similar issue, so I'm posting for the next person who comes across similar issues.
For this to work, you'll need to build Boost with VS2012 or download it from Teeks99 or Sourceforge. I was unable to make it work with VS2010.
Change the Platform Toolset to Visual Studio 2012 (v110) in the Project configuration properties. That worked for me when I was trying to figure out a similar problem (#include <boost/filesystem.hpp> in a VS2010 minimal example code). Make sure that the Common Language Runtime Support is set to /clr (NOT /clr:pure).

error LNK2019: unresolved external symbol - only .h files

Argh... I've been struggling lately to make Visual Studio 2010 (VC++) include a bunch of 3rd party libraries I wanna use in my project. That's the issue: The linker seems not to be able to determine every symbol that is generated in my code which come from the 3rd party libraries definitions. I've included the header files path on my include directories and also the sources path on my source directory, but it is still not working. I've googled it for a while and in most of cases, the issues is cause by a missing reference of the .lib file on linker's additional dependencies, however the library don't come with them.
Here's a piece of sample code:
#include "stdafx.h"
#include <fuzzylite\FuzzyEngine.h>
int _tmain(int argc, _TCHAR* argv[])
{
fl::FuzzyEngine eng;
return 0;
}
So that's the output VS shows
Fuzzycolors.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall fl::FuzzyEngine::~FuzzyEngine(void)" (??1FuzzyEngine#fl##UAE#XZ) referenced in function _wmain
Fuzzycolors.obj : error LNK2019: unresolved external symbol "public: __thiscall fl::FuzzyEngine::FuzzyEngine(void)" (??0FuzzyEngine#fl##QAE#XZ) referenced in function _wmain
So i wonder if is there a way to build my sources with the .h and .cpp files of my 3rd party library.
Thank you.
Caio
Check the new version of fuzzylite-2.0 at http://www.fuzzylite.com. That problem has been solved.
Windows requires to add __declspec(dllexport) to classes, which was not present in previous versions. Today, every class starts with class FL_EXPORT Engine, where FL_EXPORT is the missing definition.

Having problems linking with v8 on windows

I'm using Visual Studio 2010 on a 64-bit Windows 7 machine. I've pulled v8 source from SVN, built it with no problems (wich arch=x64), but I still can't compile my project that tries to use v8.
Here is a sample code that produces that same error :
#include <v8.h>
int main(int argc, char *argv[])
{
v8::Handle<v8::Context> context = v8::Context::New();
return 0;
}
The linker error I get is :
v8test.obj : error LNK2019: unresolved external symbol "public: static class v8::Persistent<class v8::Context> __cdecl v8::Context::New(class v8::ExtensionConfiguration *,class v8::Handle<class v8::ObjectTemplate>,class v8::Handle<class v8::Value>)" (?New#Context#v8##SA?AV?$Persistent#VContext#v8###2#PAVExtensionConfiguration#2#V?$Handle#VObjectTemplate#v8###2#V?$Handle#VValue#v8###2##Z) referenced in function _main
I built v8 as a static lib, tried both debug and release build, I get the same error.
In addition to v8_base.lib you need to also include v8_snapshot.lib, ws2_32.lib, and winmm.lib.
The sample on the V8 Getting Started Page can be compiled in a Console Application with following dependencies listed under Project Properties->Configuration Properties->Linker->Input->Additional Dependencies:
v8_base.lib;v8_snapshot.lib;ws2_32.lib;winmm.lib;(AdditionalDependencies)

Resources