Recent

Author Topic: Unable to copy SDL2.framework into /Library/Frameworks directory  (Read 2117 times)

gfuggetta

  • New member
  • *
  • Posts: 8
Unable to copy SDL2.framework into /Library/Frameworks directory
« on: September 05, 2021, 02:52:05 pm »
Dear Lazarus team,

I am very new in the use MacOs (I have started using Big Sur three days ago).

I have the Lazarus source code of my software which currently compiles for Windows and Linux.

To compile my software for MacOs I would need to copy the following four frameworks into the System frameworks folder.

Library/Frameworks/SDL2.framework

Library/Frameworks/SDL2_mixer.framework

Library/Frameworks/SDL2_ttf.framework

Library/Frameworks/SDL2_image.framework


So,I downloaded the four corresponding versions of .dmg MacOS installer files. When I opened them, I found the four directories listed above (e.g. SDL_image.framework, etc..). Unfortunately, when I tried to copy one by one the the four "framework" to the place where all other SDL frameworks are stored (/Library/Frameworks directory), the access was denied. 

Consequently, the Lazzaus Mac Os compiler is writing this message:
Error: Id:framework not found SDL2.

I am the only user on this machine, so I should have the rights as administrator.



Is there an alternative simple way I should use to be able to copy these four frameworks to the framework directory perhaps using the terminal (e.g. sudo, etc...)?

Please note: I am a beginner in using Mac Os. So it would be nice if you could write in simple words the procedure to solve the issue. Many thanks

Best wishes

Giorgio


madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Unable to copy SDL2.framework into /Library/Frameworks directory
« Reply #1 on: September 06, 2021, 08:04:21 am »
How did you install them in Windows and Linux...
Should be the same way
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Unable to copy SDL2.framework into /Library/Frameworks directory
« Reply #2 on: September 06, 2021, 08:46:16 am »
Any app-specific frameworks should be included in your app bundle.
ie. project1.app/Contents/Frameworks/SDL2.framework

and then use the command line utility install_name_tool thus:

Code: [Select]
cd project1.app/Contents/MacOS
install_name_tool -add_rpath "@executable_path/../Frameworks/." project1

Full details in the Wiki at macOS Dynamic Libraries.

gfuggetta

  • New member
  • *
  • Posts: 8
Re: Unable to copy SDL2.framework into /Library/Frameworks directory
« Reply #3 on: September 06, 2021, 12:07:34 pm »
Thank you very much,

I will try what you have written.

Giorgio

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Unable to copy SDL2.framework into /Library/Frameworks directory
« Reply #4 on: September 08, 2021, 06:26:47 am »
To compile my software for MacOs I would need to copy the following four frameworks into the System frameworks folder.

Library/Frameworks/SDL2.framework
Library/Frameworks/SDL2_mixer.framework
Library/Frameworks/SDL2_ttf.framework
Library/Frameworks/SDL2_image.framework

Unfortunately, when I tried to copy one by one the the four "framework" to the place where all other SDL frameworks are stored (/Library/Frameworks directory), the access was denied.

OK, to compile the application you need to either copy the SDL2 frameworks to /Library/Frameworks or tell the linker where to find them.

To copy them to /Library/Frameworks you will need to open am Applications > Utilities > Terminal, change to the directory in which the frameworks are located and copy them to the destination using eg:

 sudo rsync -rv SDL2* /Library/Frameworks

Alternatively, to tell the linker where to find them, in the Lazarus IDE go to Project > Project Options > Compiler Options > Compilation and Linking and there you will have to check the option "Pass options to linker with -k, delimiter is space" and enter the following:

 -F/path/to/SDL2_frameworks

(The trick here is NOT to enter -k at all as Lazarus does this automatically).

Of course you will probably also need the {$linkframework whatever} directive(s) in your Pascal unit(s).

When it comes to distributing your application, you will need to include the frameworks as previously indicated in the application bundle.
« Last Edit: September 08, 2021, 06:41:40 am by trev »

 

TinyPortal © 2005-2018