Lil problem with mingw32 compiler

Dan wrote:

I want a good explanation how to get it started, i always get the
undefined reference eroor but i dont understand what the stuff with
sdl-config --libs says! i’m using windows, not linux!

I don?t know exactly, what problems you have.
Ok, I?ll explain it in detail.

I presume you have downloaded the mingw32 development runtime for
windows
from http://www.libsdl.org/download-1.2.html .

If you have extracted *.tar.gz archive, you have a new folder called
SDL-1.2.1.
Within that folder, there is a file called i386-mingw32msvc.tar.gz.
Copy that to your mingw32 folder ( normally C:\gcc-2.95.2 ).

There should be a folder called i386-mingw32msvc.
If you extract the file i386-mingw32msvc.tar.gz into your mingw32
folder,
your SDL headers are now within
c:\gcc-2.95.2\i386-mingw32msvc\include\SDL,
your SDL library files in c:\gcc-2.95.2\i386-mingw32msvc\lib and the
sdl-config script in c:\gcc-2.95.2\i386-mingw32msvc\bin.

You should edit the sdl-config file.
Find the line which looks like that ( normally line 3 ):
prefix=/usr/local/cross-tools/i386-mingw32msvc

and change it to
prefix=/gcc-2.95.2/i386-mingw32msvc

If you have installed mingw32 to another folder, change
"gcc-2.95.2" to the location of that folder.

Now, you can execute sdl-config [args] and get the results.

args = --libs : the libraries needed by SDL
args = --cflags : the SDL compiler flags

You must use these outputs to compile your file.
For example: gcc -o test test.c sdl-config --cflags --libs

For more information about using sdl-config,
have a look at ( even if you use windows ):

http://www.libsdl.org/faq/FAQ-Linux.html#LINUX_2

I hope this helps :slight_smile:

cu
Johannes

Dan wrote:

ok, i solved my little problem but now i got a new one! the file testgl of
the test directory compiles with no problem but when i run it, it says that
opengl is not supported by my computer, but it is, i have geforce mx! is it
know problem or have i done something wrong?

Did you run the configure script within the test directory?
( Don?t forget to put the ./ in front of the script name, to invoke it.
for example: ./configure
)

Within the testgl.c, there is an check for a compiler macro, called
HAVE_OPENGL.
( #ifdef HAVE_OPENGL

#else
// do nothing

#endif
)

The configure script checks for openGL and sets this compiler macro.

If the configure script recognizes openGL, the makefile executes
now gcc with the compiler flag -DHAVE_OPENGL, which means that
HAVE_OPENGL is set true.

If you don?t want to execute the configure script, you must only add
-DHAVE_OPENGL to your param list of gcc.

For example:
gcc -o testgl.exe testgl.c $(sdl-config --cflags --libs) -lopengl32
-lglu32 -DHAVE_OPENGL

If you have invoked the configure script, perhaps OpenGL isn?t
recognized.
Then you could edit the testgl.c file and remove the checks for the
HAVE_OPENGL macro ( should be line 8, line 511 and line 519. Just
uncomment
these lines ).

cu
Johannes

p.s.:
sorry, I made a little mistake last time ;-))
I copied the lines of the SDL FAQ and didn?t check if it worked with
mingw32.

the correct way adding the sdl-config output is:
gcc -o foobar.exe foobar.c $(sdl-config --cflags --libs)

or add the the params manually:
invoke sdl-config ( simply type sdl-config --cflags --libs at the
prompt )
run gcc
e.g.: gcc -o foobar.exe foobar.c
-I/gcc-2.95.2/i386-mingw32msvc/include
-I/gcc-2.95.2/i386-mingw32msvc/include/SDL -Dmain=SDL_main
-L/gcc-2.95.2/i386-mingw32msvc/lib -lmingw32 -lSDLmain -lSDL -mwindows

p.p.s:
sorry, used false mail settings last time.
My name is not Ned Flanders ;-)))

Dan wrote:

C:\DEV-C_~1\LIB\libSDLmain.a(SDL_main.o): In function console_main': /home/hercules/public_cvs/SDL12/src/main/SDL_main.c:212: undefined reference toSDL_main’

the error!

Which file with which parameters have you compiled ?

I need an example to rebuild that error.

cu
Johannes

Dan wrote:

C:\DEV-C_~1\LIB\libSDLmain.a(SDL_main.o): In function console_main': /home/hercules/public_cvs/SDL12/src/main/SDL_main.c:212: undefined reference toSDL_main’

from:

Compiling files :
C:\DEV-C_~1\BIN\gcc c:\dev-c_~1\testgl.c -o
c:\dev-c_~1\Testgl.exe -s -mwindows -lmingw32 -lSDLmain -lSDL -mwindows -lo
pengl32 -lglu32 -DHAVE_OPENGL -IC:\DEV-C_~1\INCLUDE\ -IC:\DEV-C_~1\INCLUDE\G
~1 -IC:\DEV-C~1\INCLUDE\ -LC:\DEV-C~1\LIB\ -BC:\DEV-C_~1\BIN\

$(sdl-config …) doesnt go, so the output is in the command line!

Upps, I thought you are using the native minge32 environment from
the sdl homepage ( http://www.libsdl.org/Xmingw32/ ).

The scripts sdl-config, configure, … work only with a command
line interpreter which can interpret shell scripts.
Of course, the windows command line can?t process linux shell scripts.
AFAIK, dev-cpp also have no shell script interpreter, so you can forget
this
sdl-config thing.

Ok, I just downloaded the dev-cpp environment.
I made a new project, deleted the untitled file and added testgl.c.
Then I opened the project options ( ALT + p ) and added some things:

Further object files or linker options:
-lmingw32 -lSDLmain -lSDL -mwindows -lopengl32 -lglu32

Extra compiler options:
-DHAVE_OPENGL

Extra include directories ( this may/will different on your machine ):
C:\gcc-2.95.2\i386-mingw32msvc\include\SDL

With these project options, I could compile and execute testgl.c

At the console, I tried

C:\Dev-C++\Bin>gcc c:\Dev-C++\test\testgl.c -o
c:\Dev-C++\test\testgl.exe
-lmingw32 -lSDLmain -lSDL -mwindows -lopengl32 -lglu32 -DHAVE_OPENGL

This worked, too. Perhaps you have another problem.

AFAIK, SDL replaces your main function with the SDL_main function.
You should try some things like adding -Dmain=SDL_main to compiler
options.

See http://www.libsdl.org/faq/FAQ-Win32.html#WIN32_8

I hope this helps. I never used dev-cpp before ;-))

cu
Johannes

I want a good explanation how to get it started, i always get the undefined reference eroor but i dont understand what the stuff with sdl-config --libs says! i’m using windows, not linux!

Dan wrote:

I want a good explanation how to get it started, i always get the
undefined reference eroor but i dont understand what the stuff with
sdl-config --libs says! i’m using windows, not linux!

I don?t know exactly, what problems you have.
Ok, I?ll explain it in detail.

I presume you have downloaded the mingw32 development runtime for
windows
from http://www.libsdl.org/download-1.2.html .

If you have extracted *.tar.gz archive, you have a new folder called
SDL-1.2.1.
Within that folder, there is a file called i386-mingw32msvc.tar.gz.
Copy that to your mingw32 folder ( normally C:\gcc-2.95.2 ).

There should be a folder called i386-mingw32msvc.
If you extract the file i386-mingw32msvc.tar.gz into your mingw32
folder,
your SDL headers are now within
c:\gcc-2.95.2\i386-mingw32msvc\include\SDL,
your SDL library files in c:\gcc-2.95.2\i386-mingw32msvc\lib and the
sdl-config script in c:\gcc-2.95.2\i386-mingw32msvc\bin.

You should edit the sdl-config file.
Find the line which looks like that ( normally line 3 ):
prefix=/usr/local/cross-tools/i386-mingw32msvc

and change it to
prefix=/gcc-2.95.2/i386-mingw32msvc

If you have installed mingw32 to another folder, change
"gcc-2.95.2" to the location of that folder.

Now, you can execute sdl-config [args] and get the results.

args = --libs : the libraries needed by SDL
args = --cflags : the SDL compiler flags

You must use these outputs to compile your file.
For example: gcc -o test test.c sdl-config --cflags --libs

For more information about using sdl-config,
have a look at ( even if you use windows ):

http://www.libsdl.org/faq/FAQ-Linux.html#LINUX_2

I hope this helps :slight_smile:

cu
Johannes

execute sdl-config??? how?

----- Original Message -----
From: ned.flanders@myrealbox.com (Neddie)
To:
Sent: Friday, June 22, 2001 7:33 PM
Subject: [SDL] Re: lil problem with mingw32 compiler

emh, ok, gcc doesnt recognize the file!

ok, i solved my little problem but now i got a new one! the file testgl of
the test directory compiles with no problem but when i run it, it says that
opengl is not supported by my computer, but it is, i have geforce mx! is it
know problem or have i done something wrong?

Dan wrote:

ok, i solved my little problem but now i got a new one! the file testgl
of

the test directory compiles with no problem but when i run it, it says
that

opengl is not supported by my computer, but it is, i have geforce mx! is
it

know problem or have i done something wrong?

Did you run the configure script within the test directory?
( Don?t forget to put the ./ in front of the script name, to invoke it.
for example: ./configure
)

Within the testgl.c, there is an check for a compiler macro, called
HAVE_OPENGL.
( #ifdef HAVE_OPENGL

#else
// do nothing

#endif
)

The configure script checks for openGL and sets this compiler macro.

If the configure script recognizes openGL, the makefile executes
now gcc with the compiler flag -DHAVE_OPENGL, which means that
HAVE_OPENGL is set true.

If you don?t want to execute the configure script, you must only add
-DHAVE_OPENGL to your param list of gcc.

For example:
gcc -o testgl.exe testgl.c $(sdl-config --cflags --libs) -lopengl32
-lglu32 -DHAVE_OPENGL

If you have invoked the configure script, perhaps OpenGL isn?t
recognized.
Then you could edit the testgl.c file and remove the checks for the
HAVE_OPENGL macro ( should be line 8, line 511 and line 519. Just
uncomment
these lines ).

cu
Johannes

p.s.:
sorry, I made a little mistake last time ;-))
I copied the lines of the SDL FAQ and didn?t check if it worked with
mingw32.

the correct way adding the sdl-config output is:
gcc -o foobar.exe foobar.c $(sdl-config --cflags --libs)

or add the the params manually:
invoke sdl-config ( simply type sdl-config --cflags --libs at the
prompt )
run gcc
e.g.: gcc -o foobar.exe foobar.c
-I/gcc-2.95.2/i386-mingw32msvc/include
-I/gcc-2.95.2/i386-mingw32msvc/include/SDL -Dmain=SDL_main
-L/gcc-2.95.2/i386-mingw32msvc/lib -lmingw32 -lSDLmain -lSDL -mwindows

p.p.s:
sorry, used false mail settings last time.
My name is not Ned Flanders ;-)))

C:\DEV-C_~1\LIB\libSDLmain.a(SDL_main.o): In function console_main': /home/hercules/public_cvs/SDL12/src/main/SDL_main.c:212: undefined reference toSDL_main’

the error!

----- Original Message -----
From: johannes.f.schmidt@gmx.de (Johannes Schmidt)
To:
Sent: Sunday, June 24, 2001 1:18 PM
Subject: [SDL] Re: lil problem with mingw32 compiler

C:\DEV-C_~1\LIB\libSDLmain.a(SDL_main.o): In function console_main': /home/hercules/public_cvs/SDL12/src/main/SDL_main.c:212: undefined reference toSDL_main’

from:

Compiling files :
C:\DEV-C_~1\BIN\gcc c:\dev-c_~1\testgl.c -o
c:\dev-c_~1\Testgl.exe -s -mwindows -lmingw32 -lSDLmain -lSDL -mwindows -lo
pengl32 -lglu32 -DHAVE_OPENGL -IC:\DEV-C_~1\INCLUDE\ -IC:\DEV-C_~1\INCLUDE\G
~1 -IC:\DEV-C~1\INCLUDE\ -LC:\DEV-C~1\LIB\ -BC:\DEV-C_~1\BIN\

$(sdl-config …) doesnt go, so the output is in the command line!

oops, i found the problem, main2 :))) i renamed it to solve myself the
problem and forget to rerename it :slight_smile: