SDL on CodeWarrior for Windows

Hi!

Does anybody know how to make SDL projects compilable under CW7 for Windows?

I did not have problems setting up projects for MSVC++ using the described
procedure from “visualc.html”.

Under CW7 I get several linker errors like

Link Error : Undefined symbol: __imp__exit in
SDLmain.lib (.\Release\SDL_main.obj)
Link Error : Undefined symbol: __imp__strncpy in
SDLmain.lib (.\Release\SDL_main.obj)
Link Error : Undefined symbol: __imp__strrchr in
SDLmain.lib (.\Release\SDL_main.obj)
Link Error : Undefined symbol: __imp__fprintf in
SDLmain.lib (.\Release\SDL_main.obj)
Link Error : Undefined symbol: __imp___iob in
SDLmain.lib (.\Release\SDL_main.obj)
Link Error : Undefined symbol: __imp__remove in
SDLmain.lib (.\Release\SDL_main.obj)
Link Error : Undefined symbol: __imp__fgetc in
SDLmain.lib (.\Release\SDL_main.obj)
Link Error : Undefined symbol: __imp__fopen in
SDLmain.lib (.\Release\SDL_main.obj)
Link Error : Undefined symbol: __imp__fclose in
SDLmain.lib (.\Release\SDL_main.obj)

I was able to solve the same problems under MSVC++ by using the
MultiThreaded DLL target (as described), but I seem not to be able to find
an equivalent option for CW.

Changing the target to DLL links perfectly, but doesn’t create an EXE of
course!?

Any ideas?

Thank you.

Mario

(marioNO at SPAMbonesparkNO.SPAMcom,

simply remove NO and SPAM to email me,

hope this will prevent me from polluting my inbox with spam crap)

Under CW7 I get several linker errors like

Link Error : Undefined symbol: __imp__exit in
SDLmain.lib (.\Release\SDL_main.obj)
Link Error : Undefined symbol: __imp__strncpy in
SDLmain.lib (.\Release\SDL_main.obj)

Any ideas?

The last time I revised the CodeWarrior projects (about a month ago
now), I had the Windows libs & tests compiling. This was under
CodeWarrior 5.x. Do the tests compile under CW7/Windows? If so, you can
use the testers as a guide as to what files should be in your project.

If not, the location of some required libs has changed under CW 7, which
is why you see these errors. The errors you’ve mentioned look like the C
library is missing; it should be located in a subdirectory of the “MSL”
(Metrowerks Standard Library) directory (located in the root CodeWarrior
directory).

-DOn Tuesday, February 5, 2002, at 01:07 PM, Mario Knezovic wrote:

Hi Darrell,

thank you for your fast reply.

I did not even notice there already were CW projects. I implied it would be
only Mac CW projects if at all. Actually this is the first time ever I found
Windows CW project files somewhere. Congratulations, guys!

Here are the problems I had under CW7.2 (Win) with the project files that
were provided with SDL 1.2.3:

  1. There was a path

{Project}…\src\audio\win32

which now seems to have been split into

{Project}…\src\audio\windx5
AND
{Project}…\src\audio\windib

instead.

  1. The next problem was that MWCRTL51.lib does not exist anymore in CW7.
    According to the “MSL C Release Notes.txt” I should have replaced it with
    "MSL_Runtime_x86.lib", but it didn’t work due to Undefined Symbol “__file”.
    So I replaced it with “MSL_C_x86.lib” which did the job. I am not sure
    though if this was absolutely correct.

  2. In the Release version I had to add the file “SDL_expose.c” to the
    "events" group. The debug version still built correctly. Since I am new to
    SDL it is up to you to understand why :wink:

  3. In contrast to the readme file, in the release builds the compiler
    optimizations were still turned off!? Maybe this was due to the changed
    optimization settings after CW5. At Level 4 it perfectly compiles now, but
    of course I can not guarantee that it works perfectly.

  4. None of the Testers could link as no Win32 specific libraries (like
    Kernel32.lib, User32.lib) were built into the LIB files. Seems it is
    necessary to delete them (in the SDL projects) and re-include them. Then it
    works. Oh, well…

  5. All test projects complained about an undefined symbol “_main” in
    SDLmain.x86.lib or MSL-All-DLL_x86.lib (maincrt.obj).

I found this define in SDL_main.c:

#if defined(_MSC_VER) && !defined(_WIN32_WCE)
/* The VC++ compiler needs main defined */
#define console_main main
#endif

Seems it applies to CW7 Win as well. If I use that define, all test programs
can compile and even run :wink:

I changed the first line to

#if (defined(_MSC_VER) || defined(MWERKS)) && !defined(_WIN32_WCE)

Now it works.

I suggest the responsible person changes this in the original source file as
well.

(Btw: Since I am new here… Who is responsible for this? Or how does all
this work generally?)

  1. Now there is only one problem left: Every program crashes when exiting
    with an access violation. Since it took me over 5 hours now to be able to
    run the test programs, I guess I will leave this problem to either someone
    else or tomorrow…

Best regards,
Mario

“Darrell Walisser” schrieb im Newsbeitrag
news:mailman.1012939742.31167.sdl at libsdl.org…>

On Tuesday, February 5, 2002, at 01:07 PM, Mario Knezovic wrote:

Under CW7 I get several linker errors like

Link Error : Undefined symbol: __imp__exit in
SDLmain.lib (.\Release\SDL_main.obj)
Link Error : Undefined symbol: __imp__strncpy in
SDLmain.lib (.\Release\SDL_main.obj)

Any ideas?

The last time I revised the CodeWarrior projects (about a month ago
now), I had the Windows libs & tests compiling. This was under
CodeWarrior 5.x. Do the tests compile under CW7/Windows? If so, you can
use the testers as a guide as to what files should be in your project.

If not, the location of some required libs has changed under CW 7, which
is why you see these errors. The errors you’ve mentioned look like the C
library is missing; it should be located in a subdirectory of the “MSL”
(Metrowerks Standard Library) directory (located in the root CodeWarrior
directory).

-D

Hi Darrell,

thank you for your fast reply.

I did not even notice there already were CW projects. I implied it
would be
only Mac CW projects if at all. Actually this is the first time ever I
found
Windows CW project files somewhere. Congratulations, guys!

Here are the problems I had under CW7.2 (Win) with the project files
that
were provided with SDL 1.2.3:

  1. There was a path

{Project}…\src\audio\win32

which now seems to have been split into

{Project}…\src\audio\windx5
AND
{Project}…\src\audio\windib

instead.

In the projects I have already fixed this?! Ok, a quick examination
tells me that the projects in CVS are not the ones I posted in December
(Alert to Sam! ;-). I have updated the files with the fixes you
mentioned below, grab the projects at:

http://icdweb.cc.purdue.edu/~walisser/sdl/devel/CWprojects.sit

  1. In the Release version I had to add the file “SDL_expose.c” to the
    "events" group. The debug version still built correctly. Since I am new
    to
    SDL it is up to you to understand why :wink:

The “Debug” library is a static library. Static libs don’t normally
expose linking problems since they just gather object code together and
don’t really link it (i.e. the compiler doesn’t try to resolve
symbols). Of course, as soon as you link an application or shared lib
with a static library you discover any missing or duplicate symbols.

  1. In contrast to the readme file, in the release builds the compiler
    optimizations were still turned off!? Maybe this was due to the changed
    optimization settings after CW5. At Level 4 it perfectly compiles now,
    but
    of course I can not guarantee that it works perfectly.

My bad, that will be fixed.

-DOn Tuesday, February 5, 2002, at 08:13 PM, Mario Knezovic wrote: