Compiling SDL app on mac os x 10.4

Hi, I I’m new to the forms but certainly not to SDL!
I have been coding and compiling SDL programs on Linux and Windows but I am running into some problems with compiling an SDL program on a mac in both X-code and the shell.

When I try to compile this basic test:
#include “SDL/SDL.h”

int main( int argc, char* args[] )
{
SDL_Init( SDL_INIT_EVERYTHING );L
SDL_Quit();
return 0;
}

Using this code in Terminal:
g++ lesson01.cpp -framework SDL

I get this error:
/usr/bin/ld: /Library/Frameworks/SDL.framework/SDL load command 5 unknown cmd field
collect2: ld returned 1 exit status

I have installed the SDL framework in the /library/frameworks location but I don’t know how to get rid of this type of error. Like I said, I have successfully done this on other systems but I am confused here. Has anyone had a problem like this or knows how to fix it? Am I doing something wrong?
reply soon, ~Takide

takide <takide6of8 gmail.com> writes:

Hi, I I’m new to the forms but certainly not to SDL!
I have been coding and compiling SDL programs on Linux and Windows but I am
running into some problems with compiling an SDL program on a mac in both X-code
and the shell.
When I try to compile this basic test:#include "SDL/SDL.h"
int main( int argc, char* args[] )
{
SDL_Init( SDL_INIT_EVERYTHING );L
SDL_Quit();
return 0;
}
Using this code in Terminal:g++ lesson01.cpp -framework SDL
I get this error:/usr/bin/ld: /Library/Frameworks/SDL.framework/SDL load
command 5 unknown cmd field
collect2: ld returned 1 exit status
I have installed the SDL framework in the /library/frameworks location but I
don’t know how to get rid of this type of error. Like I said, I have
successfully done this on other systems but I am confused here. Has anyone had a
problem like this or knows how to fix it? Am I doing something wrong?
reply soon, ~Takide


SDL mailing list
SDL lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I believe you have to compile SDLmain.m (available in the
OS X developer archive) along with your code, and also add
-framework Cocoa.

This is what my Mac OS X build script looks like:

gcc MacOSX/SDLmain.m src/*.c -framework SDL -framework Cocoa -o bin/ssm

If you are using the latest binary of SDL, I don’t think it is
compiled to support 10.4 any more. You will need to recompile SDL
yourself for 10.4 or download an older binary of SDL.On 2/19/12, Bl0ckeduser wrote:

takide <takide6of8 gmail.com> writes:

Hi, I I’m new to the forms but certainly not to SDL!
I have been coding and compiling SDL programs on Linux and Windows but I
am
running into some problems with compiling an SDL program on a mac in both
X-code
and the shell.
When I try to compile this basic test:#include "SDL/SDL.h"
int main( int argc, char* args[] )
{
SDL_Init( SDL_INIT_EVERYTHING );L
SDL_Quit();
return 0;
}
Using this code in Terminal:g++ lesson01.cpp -framework SDL
I get this error:/usr/bin/ld: /Library/Frameworks/SDL.framework/SDL load
command 5 unknown cmd field
collect2: ld returned 1 exit status
I have installed the SDL framework in the /library/frameworks location but
I
don’t know how to get rid of this type of error. Like I said, I have
successfully done this on other systems but I am confused here. Has anyone
had a
problem like this or knows how to fix it? Am I doing something wrong?
reply soon, ~Takide


SDL mailing list
SDL lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I believe you have to compile SDLmain.m (available in the
OS X developer archive) along with your code, and also add
-framework Cocoa.

This is what my Mac OS X build script looks like:

gcc MacOSX/SDLmain.m src/*.c -framework SDL -framework Cocoa -o bin/ssm


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/

Thanks for the responses you guys, they were really helpful. This time I put the SDLmain.m and SDLmain.h in my project directory and ran this code:

gcc -I/Library/Frameworks/SDL.framework/Headers test02.cpp SDLmain.m -framework SDL -framework Cocoa

and got this error:
SDLmain.m: In function ‘getApplicationName’:
SDLmain.m:52: warning: invalid receiver type `NSDictionary *’
/usr/bin/ld: /Library/Frameworks/SDL.framework/SDL load command 5 unknown cmd field
collect2: ld returned 1 exit status

is there some way that I can get rid of this or something? I think this is happening because of cocoa but Im not quite sure how to fix it.
I’m thinking about changing the SDLmain.m file to not have the ‘NSDictionary’

replies appreciated,
~Takide

I think the warning (compiler related) and the ld command (linker
related) are unrelated. I don’t think the compiler warning is a
problem at all. I’m not sure what line 52 is. This one maybe?
dict = (NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
I would expect the cast to suppress that warning. This might work as
an alternative.

dict = [[NSBundle mainBundle] infoDictionary]

But my guess is your real problem is that the SDL.framework you are
using is not compiled to be 10.4 compatible. You must get several of
things correct when you build a library for backwards compatibility:

  • You must specify the minimum OS version the code will work on
    (something like mmacosx-version-min, you’ll need to check the docs)
  • You must get the architectures correct for your platform (10.4
    supports both ppc and i386).On 2/23/12, takide wrote:

Thanks for the responses you guys, they were really helpful. This time I put
the SDLmain.m and SDLmain.h in my project directory and ran this code:

gcc -I/Library/Frameworks/SDL.framework/Headers test02.cpp SDLmain.m
-framework SDL -framework Cocoa

and got this error:
SDLmain.m: In function ‘getApplicationName’:
SDLmain.m:52: warning: invalid receiver type `NSDictionary *’
/usr/bin/ld: /Library/Frameworks/SDL.framework/SDL load command 5 unknown
cmd field
collect2: ld returned 1 exit status

is there some way that I can get rid of this or something? I think this is
happening because of cocoa but Im not quite sure how to fix it.
I’m thinking about changing the SDLmain.m file to not have the
’NSDictionary’

replies appreciated,
~Takide


Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/

Just noticed I missed a semi-colon:

dict = [[NSBundle mainBundle] infoDictionary];On 2/23/12, Eric Wing <@Eric_Wing> wrote:

I think the warning (compiler related) and the ld command (linker
related) are unrelated. I don’t think the compiler warning is a
problem at all. I’m not sure what line 52 is. This one maybe?
dict = (NSDictionary
*)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
I would expect the cast to suppress that warning. This might work as
an alternative.

dict = [[NSBundle mainBundle] infoDictionary]

But my guess is your real problem is that the SDL.framework you are
using is not compiled to be 10.4 compatible. You must get several of
things correct when you build a library for backwards compatibility:

  • You must specify the minimum OS version the code will work on
    (something like mmacosx-version-min, you’ll need to check the docs)
  • You must get the architectures correct for your platform (10.4
    supports both ppc and i386).

On 2/23/12, takide wrote:

Thanks for the responses you guys, they were really helpful. This time I
put
the SDLmain.m and SDLmain.h in my project directory and ran this code:

gcc -I/Library/Frameworks/SDL.framework/Headers test02.cpp SDLmain.m
-framework SDL -framework Cocoa

and got this error:
SDLmain.m: In function ‘getApplicationName’:
SDLmain.m:52: warning: invalid receiver type `NSDictionary *’
/usr/bin/ld: /Library/Frameworks/SDL.framework/SDL load command 5 unknown
cmd field
collect2: ld returned 1 exit status

is there some way that I can get rid of this or something? I think this
is
happening because of cocoa but Im not quite sure how to fix it.
I’m thinking about changing the SDLmain.m file to not have the
’NSDictionary’

replies appreciated,
~Takide


Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/


Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/

I am sure that the version of SDL that I am using is for 10.4 because the .dmg file is: SDL-1.2.15-OSX10.4.dmg

I also tried linking with the Foundation framework because NSDictionary is in there. No success here either.

I tried what Eric said too. - is there some way to take NSDictionary out o the equation?

Thanks for the help, Takide.

Ps: Why is it so much easier to compile SDL on linux? Why can’t Mac os X be that easy, they’re both Unix based systems?

It looks like special 10.4 binaries were released
for SDL 1.2.15 (“SDL-1.2.15-OSX10.4.dmg (Intel/PPC 10.4)”),
have you tried these?

http://www.libsdl.org/download-1.2.php

Bl0ckeduser <bl0ckedusersoft gmail.com> writes:

It looks like special 10.4 binaries were released
for SDL 1.2.15 (“SDL-1.2.15-OSX10.4.dmg (Intel/PPC 10.4)”),
have you tried these?

http://www.libsdl.org/download-1.2.php

I see that that’s what you’re already using. Nevermind.

takide <takide6of8 gmail.com> writes:

I am sure that the version of SDL that I am using is for 10.4 because the
.dmg file is: SDL-1.2.15-OSX10.4.dmg
I also tried linking with the Foundation framework because NSDictionary is in
there. No success here either.
I tried what Eric said too. - is there some way to take NSDictionary out o the
equation?
Thanks for the help, Takide.
Ps: Why is it so much easier to compile SDL on linux? Why can’t Mac os X be
that easy, they’re both Unix based systems?

If all else fails, you might want to try using a package
manager like fink to get prebuilt SDL binaries for 10.4.

I’ve had success using such a system for 10.2.

Mac OS X builds are probably tricky because Apple seems
to change a lot of things often, break backward compatibility,
etc.

I’m also having problems with 10.4-specific 1.2.15 build. It complains
about rpath or something (not in from of my Mac right now), even though I
don’t use rpath, loader_path, etc. And if I turn on rpath or loader_path,
then it complains that 10.5 is needed.

SteveOn February 24, 2012 6:47:51 PM Bl0ckeduser wrote:

Bl0ckeduser <bl0ckedusersoft gmail.com> writes:

It looks like special 10.4 binaries were released
for SDL 1.2.15 (“SDL-1.2.15-OSX10.4.dmg (Intel/PPC 10.4)”),
have you tried these?

http://www.libsdl.org/download-1.2.php

I see that that’s what you’re already using. Nevermind.

@rpath is only available on 10.5+. That means the 10.4 binaries are mis-built.On 2/24/12, Stephen Anthony wrote:

On February 24, 2012 6:47:51 PM Bl0ckeduser wrote:

Bl0ckeduser <bl0ckedusersoft gmail.com> writes:

It looks like special 10.4 binaries were released
for SDL 1.2.15 (“SDL-1.2.15-OSX10.4.dmg (Intel/PPC 10.4)”),
have you tried these?

http://www.libsdl.org/download-1.2.php

I see that that’s what you’re already using. Nevermind.

I’m also having problems with 10.4-specific 1.2.15 build. It complains
about rpath or something (not in from of my Mac right now), even though I
don’t use rpath, loader_path, etc. And if I turn on rpath or loader_path,
then it complains that 10.5 is needed.

Steve


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/

@rpath is only available on 10.5+. That means the 10.4 binaries are mis-built.

That’s what I thought. According to this page
(http://www.dribin.org/dave/blog/archives/2009/11/15/rpath), you use
@loader_path for 10.4. However, when I do that (and don’t physically
type @rpath at all), it still complains that @rpath required 10.5. I’m
using XCode 3.2.6 (last in the 3.x line). At this point I’m not sure if
it’s a problem with how SDL is compiled, XCode, or my project file.

Steve A.
Stella maintainerOn 12-02-24 7:31 PM, Eric Wing wrote:

On 2/24/12, Stephen Anthony<@Stephen_Anthony> wrote:

On February 24, 2012 6:47:51 PM Bl0ckeduser wrote:

Bl0ckeduser<bl0ckedusersoft gmail.com> writes:

It looks like special 10.4 binaries were released
for SDL 1.2.15 (“SDL-1.2.15-OSX10.4.dmg (Intel/PPC 10.4)”),
have you tried these?

http://www.libsdl.org/download-1.2.php
I see that that’s what you’re already using. Nevermind.
I’m also having problems with 10.4-specific 1.2.15 build. It complains
about rpath or something (not in from of my Mac right now), even though I
don’t use rpath, loader_path, etc. And if I turn on rpath or loader_path,
then it complains that 10.5 is needed.

Steve


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I forgot to report the entire bug. If I don’t use rpath or loader_path
at all, then the application reports an error that it can’t find SDL.
If I then follow the instructions on the previously mentioned page and
add loader_path, then it complains that 10.5 is needed. Either way, I
can’t create a build meant for 10.4. Using SDL 1.2.14 with rpath or
loader_path works fine.

Thanks,
Steve A.
Stella maintainerOn 12-02-24 7:31 PM, Eric Wing wrote:

@rpath is only available on 10.5+. That means the 10.4 binaries are mis-built.

We used to use @executable_path/…/Frameworks for SDL.On 2/24/12, Stephen Anthony wrote:

On 12-02-24 7:31 PM, Eric Wing wrote:

@rpath is only available on 10.5+. That means the 10.4 binaries are
mis-built.

I forgot to report the entire bug. If I don’t use rpath or loader_path
at all, then the application reports an error that it can’t find SDL.
If I then follow the instructions on the previously mentioned page and
add loader_path, then it complains that 10.5 is needed. Either way, I
can’t create a build meant for 10.4. Using SDL 1.2.14 with rpath or
loader_path works fine.

Thanks,
Steve A.
Stella maintainer


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/

OK, I’ll try that when I get access to my G5 again.

SteveOn 12-02-24 9:00 PM, Eric Wing wrote:

We used to use @executable_path/…/Frameworks for SDL.

This is the error I get with XCode 3.2.6, SDL 1.2.15 10.4 build, without
specifying executable_path, loader_path, rpath when trying to run the
app (it compiles fine):

dyld: Library not loaded: @rpath/SDL.framework/Versions/A/SDL
Referenced from:
/Users/stephen/src/stella_ppc/src/macosx/build/Deployment/Stella.app/Contents/MacOS/Stella
Reason: image not found

I haven’t tried setting executable_path yet, but it seems to me that SDL
was built with reference to rpath, which shouldn’t be happening if it’s
built for 10.4.

Thanks,
Steve A.
Stella maintainerOn 12-02-24 9:00 PM, Eric Wing wrote:

We used to use @executable_path/…/Frameworks for SDL.

Yes, that would be the problem. SDL and your app must not be compiled
with any flags related to @rpath if you intend to use it on 10.4.

If you are compiling with 3.2.6, that means you are compiling on Snow
Leopard I think. That means you must be extra careful to not set any
illegal 10.4 flags.On 2/24/12, Stephen Anthony wrote:

On 12-02-24 9:00 PM, Eric Wing wrote:

We used to use @executable_path/…/Frameworks for SDL.

This is the error I get with XCode 3.2.6, SDL 1.2.15 10.4 build, without
specifying executable_path, loader_path, rpath when trying to run the
app (it compiles fine):

dyld: Library not loaded: @rpath/SDL.framework/Versions/A/SDL
Referenced from:
/Users/stephen/src/stella_ppc/src/macosx/build/Deployment/Stella.app/Contents/MacOS/Stella
Reason: image not found

I haven’t tried setting executable_path yet, but it seems to me that SDL
was built with reference to rpath, which shouldn’t be happening if it’s
built for 10.4.

Thanks,
Steve A.
Stella maintainer


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/

Bl0ckeduser, you mentioned Fink. Will I be able to build me SDL app like I did on linux with it? and have it work on mac os x?

I also have access to XCode 3.1 on a PPC G5 with Leopard 10.5. Can you
offer any advice on how to debug this? Basically, how do I go about finding
the thing that’s causing rpath to be referenced??

Thanks,
Steve A.
Stella maintainerOn February 25 2012, Eric Wing wrote:

Yes, that would be the problem. SDL and your app must not be compiled
with any flags related to @rpath if you intend to use it on 10.4.

If you are compiling with 3.2.6, that means you are compiling on Snow
Leopard I think. That means you must be extra careful to not set any
illegal 10.4 flags.