-2

I am quite new to C++ and I am using a book to get into computergrafics. I am using Visaul Studio 2013 and Windows 8. When I try to rebuild the solution, I get the following Errors:

1 error LNK2001:unresolved external symbol "_wWinMain@16". C:\application\gl_application\gl_application\MSVCRT.lib(wcrtexew.obj) gl_application 2 error LNK1120: unresolved external symbol C:\application\gl_application\Release\gl_application.exe 1 1 gl_application 

I took the following code right from the book and all advises a found online didnt help.

application.cpp

 #include <glut.h> #include "screen_interface.h" #include "global_definitions.h" #include "palette.h" void main_loop( void ) { for( long x=0 ; x<256 ; x++ ) for( long y=0 ; y<480 ; y++ ) screen[ y * 640 + x ] = palette[ x ]; glDrawPixels( x_res, y_res, GL_BGRA_EXT, GL_UNSIGNED_BYTE, screen ); glFlush(); } void initialise_world( void ) { initialise_platform(); display_func = 1; } void display( void ) { switch( display_func ) { case 0 : initialise_world(); break; case 1 : main_loop(); break; default : display_message(); } } int main( int argc, char **argv ) { glutInit( &argc, argv ); glutInitDisplayMode( GLUT_SINGLE | GLUT_RGBA ); glutInitWindowSize( x_res, y_res ); glutCreateWindow( "3D-Grafik Programmierung" ); glutKeyboardFunc( key_down ); glutSpecialFunc( special_down ); glutDisplayFunc( display ); glutIdleFunc( display ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluOrtho2D( 0, x_res, y_res, 0 ); glRasterPos2d( 0, 0 ); glPixelZoom( 1, -1 ); glClear( GL_COLOR_BUFFER_BIT ); glutMainLoop(); return 0; } 

And this Header files: Screen_interface.h

#ifndef SCREEN_INTERFACE_H #define SCREEN_INTERFACE_H #define _CRT_SECURE_NO_WARNINGS #include <time.h> #include <stdio.h> #include <string.h> #include <glut.h> #include "simple_types.h" const long x_res = 640, y_res = 480; long display_func = 0; long message_sx = 0, message_sy = 0; char message_text[ 10000 ]; long write( long sx, long sy, char *message ) { long begin_x = sx; for( unsigned long x=0 ; x<strlen( message ) ; x++ ) { if( message[ x ] == '\n' ) { sx = begin_x; sy += 12; continue; } if( message[ x ] == '\t' ) { sx = ((sx / 64) + 1) * 64; continue; } glRasterPos2d( sx, sy ); glutBitmapCharacter( GLUT_BITMAP_HELVETICA_12, message[ x ] ); sx += glutBitmapWidth( GLUT_BITMAP_HELVETICA_12, message[ x ] ); } return sy; } void display_message( void ) { GLfloat c[ 4 ]; glGetFloatv( GL_COLOR_CLEAR_VALUE, c ); glColor3ub( 0, 0, 0 ); long sy = write( message_sx, message_sy, message_text ); glColor3ub( 0, 0, 200 ); if( display_func == 2 ) write( message_sx, sy, "\n\nDruecken Sie eine beliebige Taste, um das Programm fortzusetzen.\n" ); if( display_func == 3 ) write( message_sx, sy, "\n\nDruecken Sie eine beliebige Taste, um das Programm zu beenden.\n" ); glClearColor( c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ] ); glFlush(); } void set_message( char *message ) { unsigned long x; long tmp_width = 0, text_width = 0, text_height = 0; for( x=0 ; x<strlen( message ) ; x++ ) { if( message[ x ] == '\n' ) { text_height += 12; if( tmp_width > text_width ) text_width = tmp_width; tmp_width = 0; continue; } if( message[ x ] == '\t' ) { tmp_width = ((tmp_width / 64) + 1) * 64; continue; } tmp_width += glutBitmapWidth( GLUT_BITMAP_HELVETICA_12, message[ x ] ); } if( text_width < 288 ) text_width = 288; message_sx = (x_res - text_width) / 2; message_sy = (y_res - text_height) / 2; glClearColor( 1, 1, 1, 1 ); glClear( GL_COLOR_BUFFER_BIT ); sprintf( message_text, "%s", message ); } void exit_error( char *message ) { printf( "\nAbbruch der Programmausfuehrung nach einem schwerwiegenden Fehler:\n\n\n%s\n\n\n", message ); exit( 1 ); } void set_exit( char *message, char *user ) { char string[ 500 ]; sprintf( string, "%s\n\n%s\n", user, message ); exit_error( string ); } void exit_nofile( char *user, char *filename ) { char string[ 500 ]; sprintf( string, "%s: Fehler beim Oeffnen der Datei '%s'.\n", user, filename ); exit_error( string ); } void exit_nomemory( char *user, char *array ) { char string[ 500 ]; sprintf( string, "%s: Fehler waehrend der Reservierung von Arbeitsspeicher fuer das Array '%s'.\n", user, array ); exit_error( string ); } #endif 

global_definitons.h

#ifndef GLOBAL_DEFINITIONS #define GLOBAL_DEFINITIONS #include "simple_types.h" pixel_32 *screen = NULL; void initialise_platform( void ) { if ( (screen = new pixel_32[ x_res*y_res ]) == NULL ) exit_error( "initialise_world(): Fehler bei der Reservierung von Arbeitsspeicher.\n" ); } void destroy_world( void ) { if( screen ) delete [] screen; } void key_down( uchar key, int mouse_sx, int mouse_sy ) { if( display_func == 2 ) { display_func = 1; glRasterPos2i( 0, 0 ); return; } else { destroy_world(); exit( 1 ); } } void special_down( int key, int mouse_sx, int mouse_sy ) { if( display_func == 2 ) { display_func = 1; glRasterPos2i( 0, 0 ); return; } else { destroy_world(); exit( 1 ); } } #endif 

Simple_Types.h

#ifndef SIMPLE_TYPES_H #define SIMPLE_TYPES_H #include <math.h> typedef unsigned char uchar; typedef unsigned short ushort; typedef unsigned long ulong; struct pixel_32 { uchar blue, green, red, alpha; pixel_32( void ) : red( 0 ), green( 0 ), blue( 0 ), alpha( 0 ) { } pixel_32( uchar r, uchar g, uchar b ) : red( r ), green( g ), blue( b ), alpha( 0 ) { } }; #endif 

Palette.h

#ifndef PALETTE_H #define PALETTE_H #include "simple_types.h" pixel_32 palette[ 256 ] = { pixel_32( 2, 2, 3 ), pixel_32( 3, 2, 171 ), pixel_32( 3, 171, 3 ), pixel_32( 3, 170, 170 ), pixel_32( 170, 2, 2 ), pixel_32( 170, 2, 171 ), pixel_32( 170, 87, 2 ), pixel_32( 171, 171, 170 ), pixel_32( 87, 87, 86 ), pixel_32( 87, 87, 254 ), pixel_32( 86, 255, 86 ), pixel_32( 87, 254, 255 ), pixel_32( 254, 86, 86 ), pixel_32( 255, 86, 254 ), pixel_32( 255, 254, 86 ), pixel_32( 255, 255, 255 ), pixel_32( 2, 3, 2 ), pixel_32( 23, 23, 22 ), pixel_32( 34, 34, 34 ), pixel_32( 46, 46, 47 ), pixel_32( 59, 58, 59 ), pixel_32( 71, 71, 71 ), pixel_32( 83, 83, 83 ), pixel_32( 99, 99, 98 ), pixel_32( 115, 114, 115 ), pixel_32( 131, 131, 130 ), pixel_32( 146, 147, 146 ), pixel_32( 162, 163, 163 ), pixel_32( 183, 183, 183 ), pixel_32( 203, 202, 203 ), pixel_32( 227, 226, 227 ), pixel_32( 255, 255, 255 ), pixel_32( 3, 3, 254 ), pixel_32( 66, 2, 254 ), pixel_32( 126, 3, 255 ), pixel_32( 191, 2, 255 ), pixel_32( 254, 3, 254 ), pixel_32( 254, 3, 191 ), pixel_32( 255, 2, 126 ), pixel_32( 254, 2, 67 ), pixel_32( 255, 3, 2 ), pixel_32( 255, 66, 2 ), pixel_32( 254, 127, 2 ), pixel_32( 255, 191, 3 ), pixel_32( 254, 255, 3 ), pixel_32( 191, 254, 2 ), pixel_32( 126, 254, 2 ), pixel_32( 66, 254, 2 ), pixel_32( 2, 254, 2 ), pixel_32( 3, 254, 67 ), pixel_32( 3, 255, 127 ), pixel_32( 3, 254, 191 ), pixel_32( 3, 254, 255 ), pixel_32( 2, 191, 254 ), pixel_32( 3, 126, 255 ), pixel_32( 2, 66, 254 ), pixel_32( 127, 127, 254 ), pixel_32( 159, 127, 255 ), pixel_32( 191, 126, 255 ), pixel_32( 222, 127, 255 ), pixel_32( 254, 127, 254 ), pixel_32( 254, 127, 223 ), pixel_32( 255, 127, 190 ), pixel_32( 254, 127, 158 ), pixel_32( 255, 126, 126 ), pixel_32( 254, 159, 126 ), pixel_32( 254, 191, 126 ), pixel_32( 255, 222, 126 ), pixel_32( 255, 254, 126 ), pixel_32( 223, 255, 126 ), pixel_32( 191, 255, 127 ), pixel_32( 158, 254, 127 ), pixel_32( 126, 254, 126 ), pixel_32( 126, 254, 158 ), pixel_32( 127, 254, 191 ), pixel_32( 127, 255, 223 ), pixel_32( 127, 255, 255 ), pixel_32( 126, 222, 255 ), pixel_32( 126, 190, 255 ), pixel_32( 127, 159, 255 ), pixel_32( 183, 182, 255 ), pixel_32( 198, 183, 254 ), pixel_32( 218, 183, 255 ), pixel_32( 234, 183, 255 ), pixel_32( 255, 182, 255 ), pixel_32( 255, 183, 235 ), pixel_32( 254, 182, 218 ), pixel_32( 255, 183, 199 ), pixel_32( 254, 183, 183 ), pixel_32( 254, 198, 182 ), pixel_32( 254, 219, 183 ), pixel_32( 254, 234, 183 ), pixel_32( 255, 255, 182 ), pixel_32( 234, 254, 183 ), pixel_32( 218, 254, 182 ), pixel_32( 198, 255, 182 ), pixel_32( 183, 254, 183 ), pixel_32( 183, 254, 198 ), pixel_32( 183, 255, 218 ), pixel_32( 183, 254, 234 ), pixel_32( 183, 254, 255 ), pixel_32( 183, 234, 254 ), pixel_32( 183, 218, 254 ), pixel_32( 183, 198, 255 ), pixel_32( 3, 2, 114 ), pixel_32( 30, 2, 115 ), pixel_32( 58, 2, 114 ), pixel_32( 86, 3, 114 ), pixel_32( 114, 2, 114 ), pixel_32( 115, 3, 86 ), pixel_32( 115, 3, 58 ), pixel_32( 115, 3, 30 ), pixel_32( 115, 2, 3 ), pixel_32( 114, 30, 2 ), pixel_32( 114, 58, 3 ), pixel_32( 115, 87, 2 ), pixel_32( 114, 115, 2 ), pixel_32( 87, 115, 3 ), pixel_32( 58, 115, 3 ), pixel_32( 31, 114, 2 ), pixel_32( 2, 115, 2 ), pixel_32( 3, 115, 30 ), pixel_32( 3, 114, 58 ), pixel_32( 3, 115, 87 ), pixel_32( 2, 114, 115 ), pixel_32( 2, 87, 115 ), pixel_32( 3, 59, 114 ), pixel_32( 2, 31, 114 ), pixel_32( 59, 58, 114 ), pixel_32( 71, 59, 115 ), pixel_32( 87, 59, 115 ), pixel_32( 98, 58, 115 ), pixel_32( 114, 58, 115 ), pixel_32( 114, 58, 99 ), pixel_32( 114, 59, 87 ), pixel_32( 114, 59, 71 ), pixel_32( 114, 58, 59 ), pixel_32( 114, 70, 58 ), pixel_32( 114, 87, 58 ), pixel_32( 115, 98, 58 ), pixel_32( 114, 115, 58 ), pixel_32( 98, 114, 58 ), pixel_32( 87, 115, 59 ), pixel_32( 71, 115, 59 ), pixel_32( 58, 115, 58 ), pixel_32( 59, 115, 71 ), pixel_32( 58, 114, 86 ), pixel_32( 59, 115, 98 ), pixel_32( 58, 115, 115 ), pixel_32( 59, 98, 115 ), pixel_32( 58, 86, 115 ), pixel_32( 59, 71, 115 ), pixel_32( 82, 83, 115 ), pixel_32( 90, 82, 115 ), pixel_32( 99, 83, 114 ), pixel_32( 107, 83, 114 ), pixel_32( 115, 83, 115 ), pixel_32( 114, 83, 106 ), pixel_32( 115, 82, 98 ), pixel_32( 115, 83, 90 ), pixel_32( 115, 83, 82 ), pixel_32( 114, 90, 83 ), pixel_32( 114, 98, 82 ), pixel_32( 115, 106, 83 ), pixel_32( 115, 115, 82 ), pixel_32( 107, 114, 82 ), pixel_32( 98, 114, 83 ), pixel_32( 91, 115, 83 ), pixel_32( 83, 115, 82 ), pixel_32( 82, 114, 90 ), pixel_32( 82, 115, 99 ), pixel_32( 83, 115, 106 ), pixel_32( 83, 114, 115 ), pixel_32( 82, 107, 114 ), pixel_32( 83, 99, 114 ), pixel_32( 82, 90, 115 ), pixel_32( 3, 2, 66 ), pixel_32( 19, 2, 67 ), pixel_32( 34, 3, 66 ), pixel_32( 50, 2, 67 ), pixel_32( 67, 3, 66 ), pixel_32( 67, 2, 51 ), pixel_32( 66, 3, 34 ), pixel_32( 67, 3, 19 ), pixel_32( 66, 2, 3 ), pixel_32( 67, 19, 2 ), pixel_32( 67, 34, 2 ), pixel_32( 66, 50, 2 ), pixel_32( 67, 67, 2 ), pixel_32( 51, 66, 3 ), pixel_32( 34, 66, 2 ), pixel_32( 18, 66, 2 ), pixel_32( 2, 67, 3 ), pixel_32( 2, 66, 19 ), pixel_32( 3, 67, 35 ), pixel_32( 3, 66, 50 ), pixel_32( 3, 66, 66 ), pixel_32( 2, 50, 66 ), pixel_32( 2, 35, 66 ), pixel_32( 3, 18, 67 ), pixel_32( 35, 34, 66 ), pixel_32( 42, 34, 66 ), pixel_32( 50, 35, 67 ), pixel_32( 59, 34, 66 ), pixel_32( 67, 35, 66 ), pixel_32( 66, 34, 59 ), pixel_32( 66, 35, 51 ), pixel_32( 66, 35, 42 ), pixel_32( 67, 35, 34 ), pixel_32( 67, 42, 34 ), pixel_32( 66, 50, 35 ), pixel_32( 67, 58, 34 ), pixel_32( 67, 67, 35 ), pixel_32( 58, 67, 34 ), pixel_32( 51, 66, 34 ), pixel_32( 43, 67, 35 ), pixel_32( 34, 67, 35 ), pixel_32( 34, 66, 42 ), pixel_32( 35, 67, 50 ), pixel_32( 35, 66, 58 ), pixel_32( 35, 66, 66 ), pixel_32( 35, 58, 67 ), pixel_32( 35, 51, 66 ), pixel_32( 34, 43, 66 ), pixel_32( 47, 46, 66 ), pixel_32( 50, 46, 67 ), pixel_32( 55, 46, 66 ), pixel_32( 63, 46, 66 ), pixel_32( 66, 46, 66 ), pixel_32( 67, 46, 63 ), pixel_32( 66, 46, 54 ), pixel_32( 66, 46, 51 ), pixel_32( 67, 46, 47 ), pixel_32( 66, 51, 47 ), pixel_32( 66, 55, 46 ), pixel_32( 67, 63, 47 ), pixel_32( 66, 66, 47 ), pixel_32( 62, 66, 46 ), pixel_32( 55, 66, 47 ), pixel_32( 50, 66, 47 ), pixel_32( 47, 67, 46 ), pixel_32( 46, 66, 51 ), pixel_32( 47, 67, 55 ), pixel_32( 46, 66, 62 ), pixel_32( 46, 67, 67 ), pixel_32( 46, 63, 67 ), pixel_32( 46, 55, 66 ), pixel_32( 46, 50, 67 ), pixel_32( 0, 0, 0 ), pixel_32( 0, 0, 0 ), pixel_32( 0, 0, 0 ), pixel_32( 0, 0, 0 ), pixel_32( 0, 0, 0 ), pixel_32( 0, 0, 0 ), pixel_32( 0, 0, 0 ), pixel_32( 0, 0, 0 ) }; #endif 

Help would be great, because i tried to fix this for days now. I have already tried to set the Entrypoint to wWinMainCRTStartup but it didnt help.

1
  • 1
    Please post an SSCCE. Commented Jun 21, 2014 at 9:37

1 Answer 1

1

It seems you're setting passing /SUBSYSTEM:WINDOWS instead of console, due to which it expects int WinMain(HINSTANCE,HINSTANCE,LPSTR,int) instead of int main( int argc, char **argv ). Change it to /SUBSYSTEM:CONSOLE or change your function to WinMain instead of main.

The reason subsystem is set to WINDOWS is to avoid showing a console window while your GUI/OpenGL program is running. Here's the relevant MSDN page.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot! Changing the Name didnt work, but changing Subsystem to console solved the Problem.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.