X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Eric Lilja Subject: SDL/OpenGL program fails to link when I want to use wgl-function Date: Sun, 22 Oct 2006 22:23:46 +0200 Lines: 194 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050800070005070105030107" User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) Cc: sdl AT libsdl DOT org X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com --------------050800070005070105030107 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hello, I'm using a fully updated cygwin and mingw developement binaries of SDL (version 1.2.11). Consider the following program: //#include #include #include #include static void display() { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glVertex2f(-0.5f,-0.5f); glVertex2f(-0.5f, 0.5f); glVertex2f( 0.5f, 0.5f); glVertex2f( 0.5f,-0.5f); glEnd(); SDL_GL_SwapBuffers(); } int main(int argc, char *argv[]) { (void)argc; (void)argv; int retval = SDL_Init(SDL_INIT_VIDEO); assert(retval == 0); SDL_Surface *surface = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL); assert(surface != NULL); SDL_WM_SetCaption("Simple SDL/OpenGL demo", NULL); SDL_Event event; //wglGetProcAddress("foo"); while (true) { while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: { SDL_Quit(); exit(EXIT_SUCCESS); } } } display(); } assert(0); /* Not reached. */ } Makefile I use: CXX = g++ CXXFLAGS = -Wall -Wextra -std=c++98 -pedantic -g -O0 -I ~/SDL-1.2.11/include -c LDFLAGS = -L ~/SDL-1.2.11/lib -lSDL -lopengl32 -o $(EXEC) EXEC = 1-1.exe OBJECTS = simple_1-1.o all: $(OBJECTS) $(CXX) $^ $(LDFLAGS) %.o: %.cpp $(CXX) $(CXXFLAGS) $< clean: rm -f $(OBJECTS) $(EXEC) *~ *.stackdump This compiles, links, and runs just fine. However, now I want to use one of the wgl-functions (namely wglGetProcAddress). For that I have to include . The program compiles, but the linker fails with: $ make g++ -Wall -Wextra -std=c++98 -pedantic -g -O0 -I ~/SDL-1.2.11/include -c simple_1-1.cpp g++ simple_1-1.o -L ~/SDL-1.2.11/lib -lSDL -lopengl32 -o 1-1.exe /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libcygwin.a(libcmain.o):(.text+0xab): undefined reference to `_WinMain AT 16' I tried adding -lSDLmain and -mwindows to the linker options, but it didn't help. Still the same linking error. Posting this to both the cygwin and sdl mailing list, hope that it doesn't offend anyone. Attaching the working program and Makefile. What must I do to get it to work? Works just fine under MSVC++ but I'd much rather use cygwin/gcc. / E --------------050800070005070105030107 Content-Type: text/plain; name="simple_1-1.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="simple_1-1.cpp" #include #include #include static void display() { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glVertex2f(-0.5f,-0.5f); glVertex2f(-0.5f, 0.5f); glVertex2f( 0.5f, 0.5f); glVertex2f( 0.5f,-0.5f); glEnd(); SDL_GL_SwapBuffers(); } int main(int argc, char *argv[]) { (void)argc; (void)argv; int retval = SDL_Init(SDL_INIT_VIDEO); assert(retval == 0); SDL_Surface *surface = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL); assert(surface != NULL); SDL_WM_SetCaption("Simple SDL/OpenGL demo", NULL); SDL_Event event; while (true) { while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: { SDL_Quit(); exit(EXIT_SUCCESS); } } } display(); } assert(0); /* Not reached. */ } --------------050800070005070105030107 Content-Type: text/plain; name="Makefile" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="Makefile" CXX = g++ CXXFLAGS = -Wall -Wextra -std=c++98 -pedantic -g -O0 -I ~/SDL-1.2.11/include -c LDFLAGS = -L ~/SDL-1.2.11/lib -lSDL -lopengl32 -o $(EXEC) EXEC = 1-1.exe OBJECTS = simple_1-1.o all: $(OBJECTS) $(CXX) $^ $(LDFLAGS) %.o: %.cpp $(CXX) $(CXXFLAGS) $< clean: rm -f $(OBJECTS) $(EXEC) *~ *.stackdump --------------050800070005070105030107 Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ --------------050800070005070105030107--