* * *

Author Topic: Issues with SDL and linking to the framework (OSX)  (Read 1199 times)

ZXDunny

  • New member
  • *
  • Posts: 7
Issues with SDL and linking to the framework (OSX)
« on: January 07, 2017, 05:58:28 pm »
Hi all -

I've written this little BASIC interpreter with its own editor built-in and I'd like to port it to OSX. I've ported to Linux (x86 and ARM) from the Windows delphi original, and now am building for my MacbookPro (El-Cap, not Sierra as debugging is currently broken in Sierra!).

My interpreter uses SDL and SDL_Image, with BASS for sound.

Now, as you're all aware, there are two ways to get SDL 1.2 for OSX - as a framework and as unix-style libraries. I've got both installed as I couldn't build without the unix-style, and I'd like to put the two frameworks inside the app bundle, but have run into some real problems.

I can link (according to otool -L) to the SDL_Image framework, but the linker refuses to link to the SDL framework and instead links to the library in /opt/local/lib which also creates a dependency to libX11.6.dylib... and so on.

This is the command line I'm using to build (can't build for 64 bit cocoa from Lazarus due to huge UI issues):

yes, it's CodeTyphon as I didn't want to spend 8 hours getting FPC and Lazarus installed, sorry about that.

/usr/local/codetyphon/fpc/fpc64/bin/x86_64-darwin/fpc -MDelphi -Sghi -CX -O4  -OoUNCERTAIN -OoREGVAR -Xs -uDarwin -dMacOS -k-framework -kCocoa -k-framework -kOpenGL -k-framework -kSDL_image -k/usr/local/lib/libbass.dylib  -k-framework -kCocoa -l -vewnhibq -Fu/usr/local/codetyphon/typhon/lcl/units/x86_64-darwin/cocoa -Fu/usr/local/codetyphon/typhon/lcl/units/x86_64-darwin -Fu/usr/local/codetyphon/typhon/components/BaseUtils/lib/x86_64-darwin -Fu/usr/local/codetyphon/typhon/packager/units/x86_64-darwin -Fu/Users/zxdunny/projects/specbas/ -dLCL -dLCLcocoa SpecBAS.pas

I can use install_name_tool from xcode to change where libbass is searched for, and the above as I said creates a dependency on SDL_Image.framework, which I can also change the search path for with install_name_tool. But inserting -k-framework -kSDL results in FPC complaining that it can't find the SDL framework, which has been installed properly into /library/frameworks/ along with SDL_Image. I'd ideally like to link to @rpath so I can include the two frameworks inside the app bundle for a self-contained installation.

Anyone know why it fails so hard?

mischi

  • Jr. Member
  • **
  • Posts: 76
Re: Issues with SDL and linking to the framework (OSX)
« Reply #1 on: January 07, 2017, 06:18:29 pm »
Just 2 ideas:

1) On OS X you may use the $linklib directive for a successful build with dylibs, but it you want a framework you need $linkframework.

2) You may have to increase verbosity of fpc and/or linker, so you can see the search sequences of directories. For fpc -vt has been useful for me in some cases. -va gives so much, that you better redirect the output to a file, which you can search with an editor. I do not know the options for the linker. "man ld" should tell.

Michael.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus