# GLFW only works in MS Visual Studio 2003?

**URL:** <https://discourse.glfw.org/t/glfw-only-works-in-ms-visual-studio-2003/430>\
**Category:** support\
**Created:** [June 14, 2007, 12:55pm UTC](https://discourse.glfw.org/t/glfw-only-works-in-ms-visual-studio-2003/430 "2007-06-14T12:55:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 14, 2007, 12:55pm UTC](https://discourse.glfw.org/t/glfw-only-works-in-ms-visual-studio-2003/430/1 "2007-06-14T12:55:39Z")

</div>

**nobody** wrote on [Thursday, June 14, 2007](https://sourceforge.net/p/glfw/discussion/247562/thread/30b23dce/#395d):

Hello, I have used GLUT/OpenGL for a while but now I found the very nice and small toolkit GLFW.  
Cause I needed the binaries for MS Visual Studio 2003, I got the glfw-2.6.beta1-source and compiled them by myself.  
All works fine after including the Header gl/glfw.h and the static lib glfw.lib. So I ported my 2D-OpenGL-gameengine from my GLUT Project to GLFW and it works great too. But my engine only works in the Development Environment of visual Studio 2003 !!! If I run my app outside from Visual Studio, my engine makes graphic errors ! ☹

Look here plz:

Engine renders all stuff correct: (In the MSVS Environment!)  
[http://img261.imageshack.us/img261/3324/correcthw6.png](http://img261.imageshack.us/img261/3324/correcthw6.png)

Engine renders strange stuff: (Out of the MSVS Environment!)  
[http://img409.imageshack.us/img409/7424/incorrectke2.png](http://img409.imageshack.us/img409/7424/incorrectke2.png)

What could I have done wrong ? I have nothing changed on Code of my engine. I have only replaced the GLUT code with  
GLFW and then it only works in the Environment of MSVS2003 ☹ Does anybody know how I could solve the prob ?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 14, 2007, 5:17pm UTC](https://discourse.glfw.org/t/glfw-only-works-in-ms-visual-studio-2003/430/2 "2007-06-14T17:17:06Z")

</div>

**nobody** wrote on [Thursday, June 14, 2007](https://sourceforge.net/p/glfw/discussion/247562/thread/30b23dce/#f5a1):

Maybe the Code of my Main.cpp could help ?

//--------------------------------------------------------------------  
// Include-Dateien  
//--------------------------------------------------------------------  
#include "FinalMain.h"  
#include "FinalTextureAtlas.h"  
#include "FinalMap.h"  
#include "FinalLogger.h"

//--------------------------------------------------------------------  
// Globals  
//--------------------------------------------------------------------  
FinalTextureAtlas finalAtlas;  
FinalMap finalMap;  
int camX = 0;  
int camY = 0;

int ProjectInitialize()  
{  
glEnable(GL\_CULL\_FACE);  
glEnable(GL\_TEXTURE\_2D);  
glShadeModel(GL\_SMOOTH);  
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);  
glClearDepth(1.0f);  
glEnable(GL\_DEPTH\_TEST);  
glDepthFunc(GL\_LEQUAL);  
glHint(GL\_PERSPECTIVE\_CORRECTION\_HINT, GL\_NICEST);  
glEnable(GL\_BLEND);  
glBlendFunc(GL\_SRC\_ALPHA, GL\_ONE\_MINUS\_SRC\_ALPHA);

```
finalAtlas.SetNumberOfAtlases\(1\);
finalAtlas.LoadAtlas\(&quot;gfx/atlas1.tga&quot;, 0\);
finalMap.SetFinalTextureAtlasAdress\(&amp;finalAtlas\);
finalMap.LoadTileMap\(&quot;maps/mapbig.bin&quot;\);

return 1;		

```

}

void GLFWCALL ProjectResize(int width, int height)  
{  
if(height == 0) height = 200;  
if(width == 0) width = 320;  
glViewport(0, 0, width, height);  
glMatrixMode (GL\_PROJECTION);  
glLoadIdentity();  
glOrtho(0.0f,(float)1024.0f, (float)768.0f, 0.0f, 0.0f, 3.0f);  
glMatrixMode(GL\_MODELVIEW);  
glLoadIdentity();  
}

void ProjectMainLoop()  
{  
finalMap.DrawTileMap(&camX, &camY);  
}

int ProjectTerminate()  
{  
return 1;  
}

int main()  
{  
int running = GL\_TRUE;

```
glfwInit\(\);
	
glfwOpenWindowHint\(GLFW\_REFRESH\_RATE, 75\);

if\( \!glfwOpenWindow\(1024,768, 8,8,8,8,24,0, GLFW\_FULLSCREEN\)\)
\{
	glfwTerminate\(\);
	return 0;
\}

ProjectInitialize\(\);

glfwSetWindowTitle\(&quot;FinalEngineXP Version 1.0 \(c\) Finalbrain&quot;\);
glfwSetWindowSizeCallback\(ProjectResize\);

do 
\{
	glClear\(GL\_COLOR\_BUFFER\_BIT | GL\_DEPTH\_BUFFER\_BIT\);
	glLoadIdentity\(\);
	
	ProjectMainLoop\(\);
	
	glfwSwapBuffers\(\);
	
	running = \!glfwGetKey\(GLFW\_KEY\_ESC\) &amp;&amp; glfwGetWindowParam\(GLFW\_OPENED\);

	if \(glfwGetKey\(GLFW\_KEY\_LEFT\)\)	camX-=4;
	if \(glfwGetKey\(GLFW\_KEY\_RIGHT\)\)	camX+=4;
	if \(glfwGetKey\(GLFW\_KEY\_UP\)\)	camY-=4;
	if \(glfwGetKey\(GLFW\_KEY\_DOWN\)\)	camY+=4;
\}
while\(running\);

glfwTerminate\(\);
ProjectTerminate\(\);
return 0;

```

}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 15, 2007, 3:40pm UTC](https://discourse.glfw.org/t/glfw-only-works-in-ms-visual-studio-2003/430/3 "2007-06-15T15:40:24Z")

</div>

**nobody** wrote on [Friday, June 15, 2007](https://sourceforge.net/p/glfw/discussion/247562/thread/30b23dce/#395d/27a2):

Hmmm…Does anybody know a solution ☹ ?

I have tried much things out … and now I know much more about my prob:

Only if I switch my Project to "Multithreaded Debug" (/MTd), then it works correctly!

Maybe my glfw.lib is only a debug version ?

And I get some Linker-Warning if i start the Debug Version of my Project:

LINK : warning LNK4098: defaultlib ‘LIBC’ conflicts with use of other libs; use /NODEFAULTLIB:library

Can somebody plz send me a correct Multithreading static glfw.lib for visual studio 2003 ?  
Maybe it will help me ? I do not want have a debug version of the lib ☹

Mailto: [Finalbrain@t-online.de](mailto:Finalbrain@t-online.de)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 16, 2007, 11:11am UTC](https://discourse.glfw.org/t/glfw-only-works-in-ms-visual-studio-2003/430/4 "2007-06-16T11:11:00Z")

</div>

**[kohaistyle](https://sourceforge.net/u/kohaistyle/)** wrote on [Saturday, June 16, 2007](https://sourceforge.net/p/glfw/discussion/247562/thread/30b23dce/#395d/27a2/cdfc):

Hello !

Elmindreda should clarify this, but i think you’re right.  
The lib you’re using has been compiled with another version of the default libs, and that’s why MSVC bugs you.

Instead of using premade libs, trying recompiling GLFW yourself, it should simply fix that.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 17, 2007, 8:29am UTC](https://discourse.glfw.org/t/glfw-only-works-in-ms-visual-studio-2003/430/5 "2007-06-17T08:29:31Z")

</div>

**nobody** wrote on [Sunday, June 17, 2007](https://sourceforge.net/p/glfw/discussion/247562/thread/30b23dce/#395d/d00c):

Thanx for the help 🙂

I had compiled it by myself…but I used therefore the predefined Makefile. It seems that my Project only runs than  
in Multithreaded debug mode ☹

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 17, 2007, 11:52am UTC](https://discourse.glfw.org/t/glfw-only-works-in-ms-visual-studio-2003/430/6 "2007-06-17T11:52:50Z")

</div>

**nobody** wrote on [Sunday, June 17, 2007](https://sourceforge.net/p/glfw/discussion/247562/thread/30b23dce/#6f4e):

Now I have tried out all the things out with Visual Studio 2005, cause in the beta1-glfw-package there was  
a predefined Projectfile for MSVS2005!

I tried to compile the GLFW once with the runtime Option (/MT) (Multi-threaded) and once with (/MD) /Multi-threaded DLL.

But ONLY If I switch my own Project to Multi-threaded Debug (/MTd) or Multi-threaded Debug DLL (/MDd) my engine works fine ?!

Whats the difference in compileing the static lib GLFW with (/MT) or (/MD) ? I saw that /MT is the default for a win32 project so I want to use that and not /MTd or /MDd.

Maybe someone can help me out of this jungle ? I have als tried GLUT with MSVS2005 (/MT) and my engine works so fine. There must be an error or somethting else in GLFW ☹

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 17, 2007, 4:25pm UTC](https://discourse.glfw.org/t/glfw-only-works-in-ms-visual-studio-2003/430/7 "2007-06-17T16:25:36Z")

</div>

**nobody** wrote on [Sunday, June 17, 2007](https://sourceforge.net/p/glfw/discussion/247562/thread/30b23dce/#08ca):

Ok…Thread can be closed! I have found the error! GLFW works now good with VisualStudio with /Md.  
There was a memory error in one of my classes with the atoi-funktion…it was a program-mistake done by myself, but the mistake-consequences only appeard, when I used GLFW! Strange Error … Thanx for Help 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 17, 2007, 5:27pm UTC](https://discourse.glfw.org/t/glfw-only-works-in-ms-visual-studio-2003/430/8 "2007-06-17T17:27:33Z")

</div>

**[kohaistyle](https://sourceforge.net/u/kohaistyle/)** wrote on [Sunday, June 17, 2007](https://sourceforge.net/p/glfw/discussion/247562/thread/30b23dce/#08ca/9e68):

Cool thing !

Show us the result, when you’re done 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 17, 2007, 7:55pm UTC](https://discourse.glfw.org/t/glfw-only-works-in-ms-visual-studio-2003/430/9 "2007-06-17T19:55:54Z")

</div>

**nobody** wrote on [Sunday, June 17, 2007](https://sourceforge.net/p/glfw/discussion/247562/thread/30b23dce/#395d/34a5):

Yes…I am working on a gargoyles Quest Clone…the inofficial continue of firebrand ^^ But it will take still much time…
