Mail Archives: cygwin/2006/10/22/16:24:03
--------------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 <windows.h>
#include <SDL.h>
#include <GL/gl.h>
#include <cassert>
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 <windows.h>. 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 <SDL.h>
#include <GL/gl.h>
#include <cassert>
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--
- Raw text -