glfw undeclared identifiers after linking with Visual Studio 2010 - visual-studio-2010

I am getting 'undeclared identifier' and 'identifier not declared' compiler errors while trying to test whether I've installed GLFW correctly for use with VS 2010.
I downloaded the latest 32 bit binaries from GLFW to be used with Visual Studio 2010.
The glfw3.h and glfw3native.h header file is in the include/gl folder of my Windows SDKs folder and the include folder of my VS 2010 install.
The glfw3.lib and glfw3dll.lib files are in the Windows SDKs lib folder and the VS 2010 install's lib folder.
The glfw3.dll file is in the same folder as the .exe of my VS 2010 project and in my System32 folder.
The duplicate locations exist to determine whether the issue is that my project is not pointing to the correct include, lib directories.
In Linker->Additional Dependencies, I have glfw3.lib, glew32d.lib, opengl32.lib and glu32.lib. I have tried including glfw3dll.lib separately and in combination with glfw3.lib, same result.
Here is the build log:
Build started 7/20/2013 01:00:28.
1>Project "j:\Users\Guy\documents\visual studio 2010\Projects\OpenGL4Test\OpenGL4Test\OpenGL4Test.vcxproj" on node 2 (build target(s)).
1>InitializeBuildStatus:
Touching "Debug\OpenGL4Test.unsuccessfulbuild".
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc100.pdb" /Gd /TP /analyze- /errorReport:prompt main.cpp
main.cpp
1>j:\users\Guy\documents\visual studio 2010\projects\opengl4test\opengl4test\main.cpp(13): error C2065: 'GLFW_OPENGL_VERSION_MAJOR' : undeclared identifier
1>j:\users\Guy\documents\visual studio 2010\projects\opengl4test\opengl4test\main.cpp(13): error C3861: 'glfwOpenWindowHint': identifier not found
1>j:\users\Guy\documents\visual studio 2010\projects\opengl4test\opengl4test\main.cpp(14): error C2065: 'GLFW_OPENGL_VERSION_MINOR' : undeclared identifier
1>j:\users\Guy\documents\visual studio 2010\projects\opengl4test\opengl4test\main.cpp(14): error C3861: 'glfwOpenWindowHint': identifier not found
1>j:\users\Guy\documents\visual studio 2010\projects\opengl4test\opengl4test\main.cpp(15): error C3861: 'glfwOpenWindowHint': identifier not found
1>j:\users\Guy\documents\visual studio 2010\projects\opengl4test\opengl4test\main.cpp(16): error C3861: 'glfwOpenWindowHint': identifier not found
1>j:\users\Guy\documents\visual studio 2010\projects\opengl4test\opengl4test\main.cpp(19): error C2065: 'GLFW_WINDOW' : undeclared identifier
1>j:\users\Guy\documents\visual studio 2010\projects\opengl4test\opengl4test\main.cpp(19): error C3861: 'glfwOpenWindow': identifier not found
1>Done Building Project "j:\Users\Guy\documents\visual studio 2010\Projects\OpenGL4Test\OpenGL4Test\OpenGL4Test.vcxproj" (build target(s)) -- FAILED.
Build FAILED.
Time Elapsed 00:00:00.33
And the code comes from the an OpenGL 4 tutorial, I changed the glfw header file to reflect the latest download, i.e. from glfw.h to glfw3.h:
#include <GL/glew.h> // include GLEW and new version of GL on Windows
#include <GL/glfw3.h> // GLFW helper library
#include <stdio.h>
#include <string>
int main () {
// start GL context and O/S window using the GLFW helper library
glfwInit ();
// "hint" that the version 4.2 should be run with no back-compat stuff
int major = 4;
int minor = 2;
glfwOpenWindowHint (GLFW_OPENGL_VERSION_MAJOR, major);
glfwOpenWindowHint (GLFW_OPENGL_VERSION_MINOR, minor);
glfwOpenWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwOpenWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// open a window of sixe 640x480 with 8bpp and 24 bits for depth sorting
glfwOpenWindow(640, 480, 8, 8, 8, 8, 24, 8, GLFW_WINDOW);
// start GLEW extension handler
glewInit ();
// get version info
const GLubyte* renderer = glGetString (GL_RENDERER); // get renderer string
const GLubyte* version = glGetString (GL_VERSION); // version as a string
printf("Renderer: %s\n", renderer);
printf("OpenGL version supported %s\n", version);
// tell GL to only draw onto a pixel if the shape is closer to the viewer
glEnable (GL_DEPTH_TEST); // enable depth-testing
glDepthFunc (GL_LESS); // depth-testing interprets a smaller value as "closer"
/* OTHER STUFF GOES HERE NEXT */
// close GL context and any other GLFW resources
glfwTerminate();
return 0;
}
It seems that most other people have problems linking these libraries, but these are compiler errors?

Some function names were changed in Version 3 of GLFW, such as glfwOpenWindowHint to glfwWindowHint.
This page gives the version changes, so use CTRL F to find the new function names:
http://www.glfw.org/changelog.html
Also, I found I needed to change #include <GL/glfw3.h> to #include <GLFW/glfw3.h> as the folder name was changed (check in the GLFW directory to see what yours is).
Hope that helps...

There is nothing like #include "GL/glfw3.h" now.
If you extract the source file of glfw package you will get folder GLFW so you need to include it like
> #include "GLFW\glfw3.h"

Related

fatal error C1189: #error: <future> is not supported when compiling with /clr or /clr:pure

When porting Qt to 5.10.1, I am getting following error
Reason for Error: Visual studio Build with clr(Common language runtime ) support settings, so that above error is generated.
C/C++ Advanced > showIncludes sets "Yes", so It has been identified that from Qt's QThread above error is generated.
How to resolve above error in Qt 5.10.1 with VS2015 ?
Note: I am using C# dll in my Qt VS project
Make sure QThread doesn't include when clr is enabled.
I have done conditional compilation for my project include
#ifndef CLR_ENABLED
#include <QtCore/QThread> //Error C1189: #error: <future> is not supported when compiling with /clr or /clr:pure. Qt5 porting.
#endif

How to compile (and link) a python module using PyQt (and sip) under windows

I have a C++ project using Qt5 (also compiles with Qt4) which I want to make available in python (preferable 3.4). In order to do this I use PyQt4 (because of the QtXml module which is, as far as I know, not available in PyQt5 anymore) and sip. This all works perfectly on my linux machine. But unfortunately I need it for windows and can't get it run. What I have done so far:
A very small example without Qt or other dependencies (one function which returns an integer) works. Even with gcc. But after an "bad reloc" error in my project I switched to the MSVC
My python 3.4 was build with "MSC v.1600 32 bit (Intel)" "on win32" so according to What version of Visual Studio is Python on my computer compiled with? I downloaded Qt 5.2.1 MSVC2010 and Microsoft Visual Studio Express 2010 SP1
I assume that the precompiled PyQt4-4.11.2-gpl-Py3.4-Qt5.3.1-x32 should fit
In order to get the sip.h and sipconfig.py file I compiled sip (4.16.3).
From now on I am unsure what to do. I have to admit that I have no knowledge about libraries.
The C++/Qt project is compiled with QtCreator with CONFIG += staticlib and TEMPLATE = lib. The resulting *.lib (here: xml2db.lib) is been copied to the folder where my sip files are (e.g. sipxml2dbcmodule.cpp)
So via the "VS Command Prompt" nmake throws fatal (link) errors. I'm unsure what the needed compiler flags should be or if the staticlib is wrong. My flags are:
LFLAGS = /NOLOGO /DYNAMICBASE /NXCOMPAT /DLL /MANIFEST /MANIFESTFILE:$(TARGET).manifest /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /NODEFAULTLIB:library /LIBPATH:/LIBPATH:C:\Qt\5.2.1\msvc2010\lib
LIBS = /LIBPATH:C:\Python34\libs python34.lib xml2db.lib /LIBPATH:C:\Qt\5.2.1\msvc2010\lib\Qt5Xmld.lib C:\Qt\5.2.1\msvc2010\lib\Qt5Sqld.lib C:\Qt\5.2.1\msvc2010\lib\Qt5Cored.lib
$(TARGET): $(OFILES)
$(LINK) $(LFLAGS) /OUT:$(TARGET) $(OFILES) $(LIBS)
Where target is "myTools.pyd". It results in
sipmyToolscmodule.cpp
sipmyToolsxml2db.cpp
Generating Code...
link /NOLOGO /DYNAMICBASE /NXCOMPAT /DLL /MANIFEST /MANIFESTFILE:myTools
.pyd.manifest /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /NODEFAULTLIB:library /LIBPATH:
C:\Qt\5.2.1\msvc2010\lib /OUT:myTools.pyd sipmyToolscmodule.obj sipmyToolsxml2db
.obj /LIBPATH:C:\Python34\libs python34.lib xml2db.lib /LIBPATH:C:\Qt\5.2.1\msvc
2010\lib\Qt5Xmld.lib C:\Qt\5.2.1\msvc2010\lib\Qt5Sqld.lib C:\Qt\5.2.1\msvc2010\l
ib\Qt5Cored.lib
xml2db.lib(xml2db.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_L
EVEL': value '2' doesn't match value '0' in sipmyToolscmodule.obj
MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_i
nfo(class type_info const &)" (??0type_info##AAE#ABV0##Z) already defined in LIB
CMT.lib(typinfo.obj)
MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall
type_info::operator=(class type_info const &)" (??4type_info##AAEAAV0#ABV0##Z)
already defined in LIBCMT.lib(typinfo.obj)
Creating library myTools.lib and object myTools.exp
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; u
se /NODEFAULTLIB:library
myTools.pyd : fatal error LNK1169: one or more multiply defined symbols found
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\BIN\link.EXE"' : return code '0x491'
Stop.
I would be pleased for an answer or fresh idea. Thanks in advance.
EDIT
I don't know exactly how I solved it but here are a few more hints that helped me to solve it.
Since sip 5 won't have the build system I tried to create a qmake project. To do so I downloaded the pyqt source package and looked at the project files and adjusted it to my needs.
Especially when you are changing the qmake project file it might be usefull to delete the make, object and/or moc files.
The qt version should perfectly match to the pyqt version (actually I don't mean the version itself but the qt version it was compiled for)
Good luck for those who have similiar problems

Set up x64 in Visual C++ 2010

I am trying to learn x64 assembly using Visual Studion 2010.
I was following this video tutorial : x64 Assembly and C++ Tutorial 1: Getting into x64 ASM from C++
As it says, I installed Visual Studio 2010, windows 7 SDK 3.5 (ISO install) and edited the configuration.
But when I compile the code, I get following error :
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\masm.targets(49,5): error MSB3721: The command "ml64.exe /c /nologo /Zi /Fo"x64\Debug\asm.obj" /W3 /errorReport:prompt /Taasm.asm" exited with code 1.
What is this problem, and how can I solve it?
Look at the assembler output above that line, or build the .asm file by itself.
You should see warnings generated by the assembler
eg. "somefile.asm(564): warning A6004: procedure argument or local not referenced :"
Deal with those warnings. The "exited with code 1" is not very explanatory.

Linking error in VS2010 with GLew/ GLee/ Unofficial OpenGL SDK

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.

Visual Studio 2010 includes MFC even though empty console application is specified (C++)

I've spent most of my day trying to figure out why this error is occurring but it continues to mystify me.
I created a console application in Visual C++ and specified it to be empty. After putting all of my source in the virtual folder and compiling it an error occurred:
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afx.h(24): fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afx.h(24): fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afx.h(24): fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
Strange error indeed, because I never included any MFC files. So I remedied the situation by specifying "/MT" in the code generation settings.
This worked well...until I decided to include "Windows.h", which spawned this error:
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxv_w32.h(16): fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include windows.h
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxv_w32.h(16): fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include windows.h
I've tried everything I could think of, including recreating the project with and without precompiled headers, a Win32 app rather than console, and a WxWidget app. All of these apps seemingly try to include MFC even though I never specified. Can anyone shed some light on this problem? Thank you!
Find out what's including the MFC headers - the /showIncludes option may help with that.
Which in the IDE project property page is under:
C/C++ | Advanced | Show Includes
Once you know who is including them you can make a decision on how to address the problem - you might simply be able to remove an errant #include, but it might require jettisoning a library you're using that's dependent on MFC.
Make sure 'USE of MFC' is in 'Use MFC in a Shared DLL' setting. That fixed it for me.
If MFC is required, set the following values ( Debug/Win32 ):
Configuration Properties > General :
Use of MFC : Use MFC in a Shared DLL
Configuration Properties > C/C++ > Code Generation :
Runtime Library : /MDd
If MFC is not required, and only standard window libraries are required, keep the setting as below.
Configuration Properties > General :
Use of MFC : Use Standard Windows Libraries
Configuration Properties > C/C++ > Code Generation :
Runtime Library : /MTd

Resources