Troubles compiling...
After several hours of attempting to compile a program with SDL and after trying cygwin, mingw, and dev-c++ I'm about to give up trying. Each time, with every compiler, I'm getting almost the exact same error: "undefined reference to". It says this on about every SDL function in the code.
Note that I've tried each compiler with a bunch of different example programs so I don't think it has anything to do with the actual code. I've also tried using all the suggested parameters for the compiler (-mwindows -lSDL etc...)
Im trying to use SDL 1.2.8 on Windows XP and I haven't yet found any information on what could be happening as I've followed the directions exactly when installing the programs.
If someone has any information on whats happening I would be grateful if you could help me.
Note that I've tried each compiler with a bunch of different example programs so I don't think it has anything to do with the actual code. I've also tried using all the suggested parameters for the compiler (-mwindows -lSDL etc...)
Im trying to use SDL 1.2.8 on Windows XP and I haven't yet found any information on what could be happening as I've followed the directions exactly when installing the programs.
If someone has any information on whats happening I would be grateful if you could help me.
a) this is a Mac programming board, so probably few people can help you.
b) "undefined reference to" means you haven't linked in the library containing that function. -lSDL is the linker flag you need for GCC-based compilers (such as mingw and dev-c++). Check that you've got SDL.DLL and/or SDL.LIB somewhere the compiler can find them.
b) "undefined reference to" means you haven't linked in the library containing that function. -lSDL is the linker flag you need for GCC-based compilers (such as mingw and dev-c++). Check that you've got SDL.DLL and/or SDL.LIB somewhere the compiler can find them.
Well, thanks for the tips. I guess I just missed the part about this being a mac site (kind of hidden). Also since SDL is still under major development for macs I made a jumpy assumption
InflamedSpirit Wrote:After several hours of attempting to compile a program with SDL and after trying cygwin, mingw, and dev-c++ I'm about to give up trying. Each time, with every compiler, I'm getting almost the exact same error: "undefined reference to". It says this on about every SDL function in the code.If you are getting an "Undefined reference to 'SDL_main'", check that your main function is declared exactly like this:
Code:
int main(int argc, char *argv[])
(I had a hard disk crash a while ago, so that template must be "somewhere" among all those "backup ####" CDs I have lying around...
)
InflamedSpirit Wrote:Well, thanks for the tips. I guess I just missed the part about this being a mac site (kind of hidden).
How'd you miss the sticky thread that was labeled in bold "Required Reading"?
http://www.idevgames.com/forum/announcement.php?f=58
Or the big banner on the main page that says "iDevGames The Macintosh Games Developer Community"?
I mean, while not stated all over the place, I don't think it's particularly kind of hidden...
The brains and fingers behind Malarkey Software (plus caretaker of the world's two brattiest felines).
People don't come here via the main page, and the forums are so fragmented that it'd be dead easy to miss a single thread.
It needs to say "Macintosh Game Development" at the top of every forum page, but Carlos apparently has something against doing that.
It needs to say "Macintosh Game Development" at the top of every forum page, but Carlos apparently has something against doing that.
Well, I just got it working this morning (around midnight). Just in case some of you are curious, it turns out that I needed the main function like this:
Also, it turned out that the parameters had to be in a different order than I had.
Bad: gcc -lSDL -lSDLmain -mwindows example.c
Good: gcc example.c -lSDL -lSDLmain -mwindows
As for me not noticing the mac part, I did a google search on "simple directmedia layer forum" and the first hit was "iDevGames - Community Forum - Simple DirectMedia Layer" which brought me right to this subforum.
Anyways, I might stick around a little on these forums, all you people seem nice and SDL IS portable as well... and mac has some cool games like the original escape velocity (I bought a mac emulator just for that
)
Code:
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)Also, it turned out that the parameters had to be in a different order than I had.
Bad: gcc -lSDL -lSDLmain -mwindows example.c
Good: gcc example.c -lSDL -lSDLmain -mwindows
As for me not noticing the mac part, I did a google search on "simple directmedia layer forum" and the first hit was "iDevGames - Community Forum - Simple DirectMedia Layer" which brought me right to this subforum.
Anyways, I might stick around a little on these forums, all you people seem nice and SDL IS portable as well... and mac has some cool games like the original escape velocity (I bought a mac emulator just for that
)
Welcome here, InflamedSpirit!
It's nice to know we hit higher than the official SDL forum.
It's nice to know we hit higher than the official SDL forum.
I would #ifdef out that WinMain function so it replaces it with int main(int argc, char *argv[]) on non-Windows platforms.
Newest game: Glow, a sci-fi RPG with lots of zombie bashing. Get it: OS X
InflamedSpirit Wrote:As for me not noticing the mac part, I did a google search on "simple directmedia layer forum" and the first hit was "iDevGames - Community Forum - Simple DirectMedia Layer" which brought me right to this subforum.That's mostly because we're heavily moderated. No room for Slashdot-style comments here. Profanity and general jerkiness are highly discouraged. Mainly because none of us care for that kind of behavior on this particular forum and it just gets in the way, and also because we all realize there are kids visiting regularly as well. That said, game development is, by its very nature, pretty platform agnostic and we all just wanna have fun in the end. This is strictly a Mac game development forum, but sshh... don't tell anyone, there are many of us here who secretly (or not so secretly as it may be) develop for Windows too. I've noticed a growing number of (what seems like) primarily/exclusively Windows developers stumbling upon these forums and sticking around like yourself. Have fun!![]()
Anyways, I might stick around a little on these forums, all you people seem nice...
You know, it's funny but I've never used "int WINAPI WinMain(H..." before and my SDL app has been running on XP for months now. The only cross platform problem I have had (other than general compiler confusion) is the fact that my data is stored in [app dir]/Data/ and to get [app dir] from a bundled application requires a different approach that simply grabbing it from the main() arguments. Windows and Linux are both a bit more logical about this. As it is, porting a 6-7k line C/SDL/openGL/openAL program from VC++ or DevCpp with 50+ source files (I like my source files) takes only a few hours (8 or so), as long as no major parts of the game are platform specific.
AnotherJake Wrote:This is strictly a Mac game development forum, but sshh... don't tell anyone, there are many of us here who secretly (or not so secretly as it may be) develop for Windows too. I've noticed a growing number of (what seems like) primarily/exclusively Windows developers stumbling upon these forums and sticking around like yourself. Have fun!
Heh. I think next time, we should help the next Windows programmer that cones in and see how long it takes for him/her to notice that this is a Mac game development forum.
@InflamedSpirit: Hey, if you stick around and wouldn't mind a Mac version of anything you're working on, we'd be happy to help out.
The brains and fingers behind Malarkey Software (plus caretaker of the world's two brattiest felines).
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| OpenAL install troubles | m3the01 | 3 | 2,925 |
Feb 20, 2009 12:46 PM Last Post: DaveJ |
|
| Bit Depth troubles | Jones | 2 | 2,220 |
Aug 21, 2006 01:20 PM Last Post: Jones |
|
| Golden Oldie: Fullscreen troubles | Fenris | 4 | 2,873 |
Jul 27, 2006 02:42 PM Last Post: Fenris |
|
| Material Troubles | Nick | 2 | 2,391 |
Apr 12, 2005 06:39 AM Last Post: Nick |
|
| Fullscreen troubles (Cocoa) | DJBlufire | 5 | 3,026 |
Dec 12, 2003 11:36 PM Last Post: kelvin |
|

