Hello!
Question #1: Is it possible at all to use SDL with Codewarrior 9.1 on
the Macintosh, writing my code in C/C++?
I’ve checked the archives and I only find discussions regarding
ProjectBuilder and xcode. I don’t know the first thing about PB/xcode,
Cocoa and Objective-C. I have a large amount of code for a game written
in C/C++ I need to get working with SDL.
This is what I have tried:
- Create SimpleAlert project using the Codewarrior template project
"Mac OS C++ Stationary" - > “Mac OS X Mach-O” -> “C++ Toolbox Mach-O”.
=> The project compiles and runs properly.
- Add the SDL framework to the Codewarrior Frameworks tab.
=> The project compiles and runs properly.
- Add "#include <STD.h> at top of SimpleHello.cp - the source file
containing the main() function.
=> The project compiles and runs properly.
- Adding a header file access path to point to the SDL framework in
Codewarrior’s target settings.
=> Linker error:
“Link Error : undefined: ‘main’ (code)
Referenced from ‘start’ in crt1.o”
Question 2: What to do? I know about the SDL trick about renaming my
program’s main() function and calling my main() from SDL’s main.
Doesn’t this require me to add a piece of SDL code that contains the
real C main() function? How? Where?
Any help very much appreciated!
/Marcus
Marcus Zetterquist <marcus propellerheads.se> writes:
Hello!
Question #1: Is it possible at all to use SDL with Codewarrior 9.1 on
the Macintosh, writing my code in C/C++?
I’ve checked the archives and I only find discussions regarding
ProjectBuilder and xcode. I don’t know the first thing about PB/xcode,
Cocoa and Objective-C. I have a large amount of code for a game written
in C/C++ I need to get working with SDL.
This is what I have tried:
- Create SimpleAlert project using the Codewarrior template project
"Mac OS C++ Stationary" - > “Mac OS X Mach-O” -> “C++ Toolbox Mach-O”.
=> The project compiles and runs properly.
- Add the SDL framework to the Codewarrior Frameworks tab.
=> The project compiles and runs properly.
- Add "#include <STD.h> at top of SimpleHello.cp - the source file
containing the main() function.
=> The project compiles and runs properly.
- Adding a header file access path to point to the SDL framework in
Codewarrior’s target settings.
=> Linker error:
“Link Error : undefined: ‘main’ (code)
Referenced from ‘start’ in crt1.o”
Question 2: What to do? I know about the SDL trick about renaming my
program’s main() function and calling my main() from SDL’s main.
Doesn’t this require me to add a piece of SDL code that contains the
real C main() function? How? Where?
Any help very much appreciated!
/Marcus
Marcus,
Maybe you already solved it (it has been more than a month since your post), but
this is how I did it:
-
create a new project -> Mac OS X Cocoa Stationary -> Objective-C++
Application (I read somewhere that SDL needs to be a Cocoa app);
-
add the SDL framework to the project;
-
add the OpenGL framework to the project if you need it for your app;
-
add the files SDLMain.h & SDLMain.m to the project, you can get them from the
cvs (http://www.libsdl.org/cgi/cvsweb.cgi/SDL12/src/main/macosx/). They are
normally part of a new ProjectBuilder project, but we need to add them manually;
-
remove main.mm which was automatically created by codewarrior and add your
own cpp files;
-
optional step: you can also remove MainMenu.nib from the project.
-
compile and enjoy…
/George