Troubles compiling...

InflamedSpirit
Unregistered
 
Post: #1
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. Sad

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.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
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.
Quote this message in a reply
InflamedSpirit
Unregistered
 
Post: #3
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 Smile
Quote this message in a reply
Moderator
Posts: 770
Joined: 2003.04
Post: #4
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. Sad
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[])
This is in the official FAQ which I'm guessing you must have already looked into. There are some tutorials there too, but if that doesn't work, I can try to find my Visual C++ 6 SDL project template, although I would need to find it first. Rasp
(I had a hard disk crash a while ago, so that template must be "somewhere" among all those "backup ####" CDs I have lying around... Blush )
Quote this message in a reply
Member
Posts: 257
Joined: 2004.06
Post: #5
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... Wink

The brains and fingers behind Malarkey Software (plus caretaker of the world's two brattiest felines).
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
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.
Quote this message in a reply
InflamedSpirit
Unregistered
 
Post: #7
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:
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. LOL

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 Wink )
Quote this message in a reply
Oldtimer
Posts: 832
Joined: 2002.09
Post: #8
Welcome here, InflamedSpirit! Smile It's nice to know we hit higher than the official SDL forum. Wink
Quote this message in a reply
Member
Posts: 86
Joined: 2005.01
Post: #9
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
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #10
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. LOL

Anyways, I might stick around a little on these forums, all you people seem nice...
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!
Quote this message in a reply
Nibbie
Posts: 1
Joined: 2010.11
Post: #11
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.
Quote this message in a reply
Member
Posts: 257
Joined: 2004.06
Post: #12
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. Smile

@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).
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenAL install troubles m3the01 3 3,193 Feb 20, 2009 12:46 PM
Last Post: DaveJ
  Bit Depth troubles Jones 2 2,417 Aug 21, 2006 01:20 PM
Last Post: Jones
  Golden Oldie: Fullscreen troubles Fenris 4 3,068 Jul 27, 2006 02:42 PM
Last Post: Fenris
  Material Troubles Nick 2 2,576 Apr 12, 2005 06:39 AM
Last Post: Nick
  Fullscreen troubles (Cocoa) DJBlufire 5 3,231 Dec 12, 2003 11:36 PM
Last Post: kelvin