___tmainCRTStartup problem

nobody wrote on Monday, August 28, 2006:

Hi,
I made the dll and lib using VC2005’s nmake and already put them in VC2005’s folder.

As for setting :
Additional Dependencies : glu32.lib opengl32.lib glfw.lib

Here’s my source code
<i>
#include <GL/glfw.h>

void DrawGLScene()
{
}

int main()
{
bool running=true;
glfwInit();

if\(\!glfwOpenWindow\(800, 600, 8, 8, 8, 8, 8, 0, GLFW\_WINDOW\)\)
\{
	glfwTerminate\(\);
	return 0;
\}

while\(running\)
\{
	DrawGLScene\(\);
	glfwSwapBuffers\(\);
	running = \!glfwGetKey\( GLFW\_KEY\_ESC \) &amp;&amp;
				glfwGetWindowParam\( GLFW\_OPENED \);
\}

glfwTerminate\(\);

}
</i>

But, I got these error :
<i>
LINK : warning LNK4098: defaultlib ‘LIBCMT’ conflicts with use of other libs; use /NODEFAULTLIB:library
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>D:\Program Samples\GLFW\2\Debug\2.exe : fatal error LNK1120: 1 unresolved externals
</i>

What should I do ? Thanks :slight_smile:

melekor wrote on Monday, August 28, 2006:

You’re getting this error because you created the project as a “win32 application”, but you haven’t provided the WinMain function, which is the entrypoint for “win32 applications”.

Solution:

change int main()

to

int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)

elmindreda wrote on Friday, September 01, 2006:

As CL wants to use WinMain as the entry point for Windows subsystem executables, you’ll need to tell it explicitly to use main instead. Add /entry:mainCRTStartup to your link flags and all will be well.