PureBasic + SDL + Mac ...

Mac OSX specific forum
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: PureBasic + SDL + Mac ...

Post by Danilo »

kenmo wrote:Danilo, does that mean the end-user would have to run that commandline?
No. You do it, and the result is a stand-alone app with included Framework.
You then distribute the final .app to end users, and they don't need to install
SDL themselves or anything, as the framework is included. SDL_Test.app.zip
User avatar
kenmo
Addict
Addict
Posts: 2045
Joined: Tue Dec 23, 2003 3:54 am

Re: PureBasic + SDL + Mac ...

Post by kenmo »

Nice solution! That .app seems to work without installing the SDL2 framework (at least it works on OSX 10.9, I would like to test back to maybe 10.5).

About that commandline action... I don't really know HOW it works. First I assumed it added some information to the .plist, but I was wrong, nothing seems to be added there. Does it modify the executable? Does it store the Framework path in a hidden file within the .app? Does the OS cache that information elsewhere? Or is it just Mac Magic? :)
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: PureBasic + SDL + Mac ...

Post by Danilo »

kenmo wrote:Nice solution! That .app seems to work without installing the SDL2 framework (at least it works on OSX 10.9, I would like to test back to maybe 10.5).
Yes, it works with Mac OS X 10.5 and newer. Older OS are not supported.

For your Reference: Mac Developer Library: Run-Path Dependent Libraries
In OS X v10.5 and later the linker and dynamic loader offer a simple way of allowing multiple executables in an application suite directory to share dependent libraries while providing the suite’s users
the option of relocating the suite directory. Using run-path dependent libraries you can create a directory structure containing executables and dependent libraries that users can relocate without breaking it.
kenmo wrote:About that commandline action... I don't really know HOW it works. First I assumed it added some information to the .plist, but I was wrong, nothing seems to be added there.
Does it modify the executable? Does it store the Framework path in a hidden file within the .app? Does the OS cache that information elsewhere? Or is it just Mac Magic? :)
It is directly added to the Loader information within the executable. You can show the loader commands with otool, option (lowercase) "-l":

Code: Select all

otool -l ./SDL_Test.app/Contents/MacOS/SDL_Test
It lists the loader commands for the executable, and you will see something like that:

Code: Select all

[...]
Load command 14
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name @rpath/SDL2.framework/Versions/A/SDL2 (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 3.1.0
compatibility version 1.0.0
[...]
Load command 24
          cmd LC_RPATH
      cmdsize 44
         path @executable_path/../Frameworks (offset 12)
The loader command LC_RPATH adds the internal Frameworks directory to the path
where the loader looks for libraries/frameworks that start with "@rpath", see otool with option (uppercase) "-L":

Code: Select all

otool -L ./SDL_Test.app/Contents/MacOS/SDL_Test
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Re: PureBasic + SDL + Mac ...

Post by jack »

Danilo, your tips are very useful, I think you should add them to the Programming on the Mac platform thread so they don't get buried.
Post Reply