SDL/OpenGL Initialization Code

Sage
Posts: 1,066
Joined: 2004.07
Post: #1
Does anyone have any initialization code for SDL using OpenGL that works with SDL 1.2.9 that they'd be willing to send me? All my code seems to be incompatible with the update for whatever reason. It worked fine until I downloaded it, but now it fails to link without getting numerous errors. Thanks in advance. Smile
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #2
I'm serious about the SDL update messing with something. I found a backup of the older version (1.2.8 probably) and used that to build my projects and they all went flawlessly. Then I used the new version (1.2.9) and got my 88 errors of symbols that were defined multiple times.

Am I the only one here who seems to have this problem? I think I may just have to use 1.2.8 instead of 1.2.9.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #3
I think that, for some reason, you're using both versions or something along those lines (i.e, you're including both frameworks). Can you post some specific errors?

It's not magic, it's Ruby.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #4
Right now this is holding me back from working on my updated initialization code (for 1.2.9):
Code:
StandaloneExecutable.LinkUsingFileList /Users/NicholasGravelyn/Documents/Programming/Spyscroller/build/Spyscroller.app/Contents/MacOS/Spyscroller
    /usr/bin/g++-3.3  -o /Users/NicholasGravelyn/Documents/Programming/Spyscroller/build/Spyscroller.app/Contents/MacOS/Spyscroller  "-L/Users/NicholasGravelyn/Documents/Programming/Spyscroller/build"  "-F/Users/NicholasGravelyn/Documents/Programming/Spyscroller/build"  -filelist /Users/NicholasGravelyn/Documents/Programming/Spyscroller/build/Spyscroller.build/Spyscroller.build/Objects-normal/LinkFileList  "-arch" "ppc" "-Wl,-no_arch_warnings"   "-framework" "SDL_image" "-framework" "SDL" "-framework" "AppKit" "-framework" "Cocoa" "-framework" "Foundation"
ld: /usr/lib/gcc/darwin/3.3/libstdc++.a(eh_personality.o) illegal reference to symbol: ___cxa_allocate_exception defined in indirectly referenced dynamic library /usr/lib/libstdc++.6.dylib
ld: /usr/lib/gcc/darwin/3.3/libstdc++.a(eh_personality.o) illegal reference to symbol: __Unwind_GetDataRelBase defined in indirectly referenced dynamic library /usr/lib/libgcc_s.1.dylib
...failed StandaloneExecutable.LinkUsingFileList /Users/NicholasGravelyn/Documents/Programming/Spyscroller/build/Spyscroller.app/Contents/MacOS/Spyscroller ...
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #5
What version of Mac OS X are you using? That looks like a problem caused by a C++ library built for Tiger being linked with an application built on Panther.

You could try building your own SDL framework to see if that eliminates the problem.

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #6
I'm on 10.3.9. How would I build my own SDL framework? I don't see why it would be built for Tiger (unless SDL 1.2.9 comes that way). The only frameworks I'm using are the standard SDL, Cocoa, Foundation, and AppKit frameworks.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #7
I suppose for now I'll just work with the old library until I can figure out what those errors mean. I have never heard of that library before so I'm really confused. It says it's "indirectly referenced", whatever that means.

It is weird that if I just use the old SDL framework it works fine, switch to the new one, and it's broken. Yay me.
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #8
Apple changed the way C++ is linked to its standard library in Tiger (I think only for GCC 4, but I forget the details). It used to be a static library, and it's now dynamic. When you try to use C++ code built on Tiger on Panther, it can't find the dynamic library and you get a link error. That said, I was under the impression that if you were using exactly 10.3.9 you also had access to the dynamic library, so maybe I'm missing something.

Hopefully someone with a better memory than myself can explain this more clearly!

Nick Wrote:How would I build my own SDL framework?
Download the source code and build it. I haven't checked recently, but I'd hope there would be some instructions in the source archive that give you a clue about how to build it, or possibly even an Xcode project.

You're not doing something weird like linking to the SDL static library and the framework at the same time, are you?

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #9
Building the source did it for me. Whatever the reason, I just downloaded the source and did the standard UNIX ./configure, make, sudo make install commands and I was up and running with 1.2.9. Thanks NCarter! Smile (it's way too early for me but I have physics at 7:45. Otherwise I'd be sleeping for another 4 hours Smile).
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #10
Ok I take that back. It worked for a while, allowed me to compile and run, and was great for about 30 minutes. Now I get those same two errors as stated above. What's the most confusing is that it was building just fine. All I've been doing is writing up my initialization code. I've tried commenting out all the stuff I've added since it last successfully compiled and ran, but I still get the errors. Too random for me. Not sure what to think.
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #11
It might be that Xcode is seeing another copy of SDL 1.2.9 somewhere and linking with that instead the one you just made. Check your Library/Frameworks folders in all the usual places to see if there are any extra copies that you can get rid of.

Are you sure you haven't built and/or linked with a static version of SDL as well as the framework?

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #12
As far as I know I've only linked with one version of SDL. I'll try getting rid of them all and rebuilding the source files. Maybe that'll help.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #13
1. remove all sdl libraries.
2. build the source using the xcode thingymajig. It's much more user friendly, though I couldn't say it's faster.
3. move the frameworks or static libraies that you just built to /System/Library/Frameworks.
4. Build some test code. If it doesn't build, try toggling the compilers on the test/frameworks.

It's not magic, it's Ruby.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #14
I followed your instructions (except using the UNIX shell rather than Xcode for building) and it works find now. Thanks for all the help. I guess there was an extra library sitting around somewhere that I forgot, but I got it this time.
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #15
Just realised what Ryan said....

Nayr Wrote:3. move the frameworks or static libraies that you just built to /System/Library/Frameworks.
/Library/Frameworks would be a better idea. Don't put things in /System without good reason - it's not supposed to be user editable, even for administrators or application developers.

Pleased to hear that it worked out, Nick. Smile

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  NEED HELP! OpenGL code for my exam doesn't work mr02077 2 2,830 Feb 9, 2007 05:44 PM
Last Post: stevejohnson
  OpenGL code optimization unknown 38 13,773 Jul 28, 2005 10:22 PM
Last Post: unknown
  OpenGL Source Code Generator Leisure Suit Lurie 2 4,079 Jul 5, 2005 11:55 AM
Last Post: Cochrane
  bus error with opengl code mnorton 2 3,914 Jan 21, 2005 02:53 PM
Last Post: ThemsAllTook
  OpenGL Setup - NIB or Code? Justin Brimm 16 7,152 Jun 24, 2004 02:48 PM
Last Post: kelvin