Skip to content

Commit 6f865ee

Browse files
JudgeGroovymanGuvaCode
authored andcommitted
added readme for mac m-series and linked to it from other readmes
1 parent b5f7ee1 commit 6f865ee

File tree

4 files changed

+121
-2
lines changed

4 files changed

+121
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Windows | :heavy_check_mark: |
5757
Linux | :heavy_check_mark: |
5858
Haiku | :heavy_check_mark: |
5959

60-
*to compile examples for the Apple m-series, watch this [video](https://www.youtube.com/watch?v=h2-GrChtwMY).
60+
\* to compile examples for the Apple m-series, see the [m-series readme](README_mac_mseries.md) or watch this [video](https://www.youtube.com/watch?v=h2-GrChtwMY)
6161

6262

6363
build and installation raylib

README_mac_mseries.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
2+
_tldr: Option 3 below will convert all of the example projects to run on Mac Mseries_
3+
4+
---
5+
# Background
6+
7+
For M-series Macs (M1, M2, etc. aka Apple Silicon or arm64 or aarch64) the included examples won't work without doing a few small things.
8+
9+
These **one-time** changes will probably also need to be done to any other example projects you get off the internet or any projects you created in the past.
10+
11+
### What needs to be done in plain english
12+
13+
In the project file (`<`Project Name`>`.lpi) there are two options that need to be set:
14+
```
15+
-framework IOKit
16+
```
17+
and
18+
```
19+
-WM11.0
20+
```
21+
22+
In the main .lpr or .pas file in the project folder add this to the uses list:
23+
```
24+
CocoaAll,
25+
```
26+
27+
# How to make these changes
28+
29+
There are three options:
30+
1. Manually change one project/example at a time **(most informative)**
31+
2. Commands to change one project/example at a time
32+
3. Commands to change all of the examples at once **(easiest)**
33+
34+
### Option 1 - Manually change one project/example at a time
35+
Edit the `<`Project Name`>`.lpi file of a project with a text editor
36+
37+
1. Find this near the bottom of the file
38+
```
39+
</Linking>
40+
</CompilerOptions>
41+
```
42+
and replace it with
43+
```
44+
<Options>
45+
<PassLinkerOptions Value="True"/>
46+
<LinkerOptions Value="&apos;-framework IOKit&apos;"/>
47+
</Options>
48+
</Linking>
49+
<Other>
50+
<CustomOptions Value="&apos;-WM11.0&apos;"/>
51+
</Other>
52+
</CompilerOptions>
53+
```
54+
55+
2. Edit the main `.lpr` or `.pas` file of the project with a text editor find the uses section and add ` CocoaAll` to that section. OR you can load the project in Lazarus and change it in the `.lpr` or `.pas` file from there. hint: you will probably only need to change the `.pas` file if there is no `.lpr` file.
56+
57+
### Option 2 - Use a command to change one project/example at a time
58+
59+
Run these commands in the folder of the project you wish to change:
60+
61+
```
62+
sed -i '' '/<\/Linking>/,/<\/CompilerOptions>/c\
63+
     <Options>\
64+
        <PassLinkerOptions Value="True"/>\
65+
        <LinkerOptions Value="&apos;-framework IOKit&apos;"/>\
66+
      </Options>\
67+
    </Linking>\
68+
    <Other>\
69+
      <CustomOptions Value="&apos;-WM11.0&apos;"/>\
70+
    </Other>\
71+
  </CompilerOptions>' *.lpi
72+
sed -i '' '/^uses/ s/^uses/& CocoaAll,/' *.lpr
73+
sed -i '' '/^uses/ s/^uses/& CocoaAll,/' *.pas
74+
75+
```
76+
77+
### Option 3 - Use a command to change all of the examples at once
78+
79+
Run these commands from the _root folder of the repo_ to make these changes to every project in the examples folder.
80+
```
81+
find examples -type f -name "*.lpi" -print0 | xargs -0 sed -i '' '/<\/Linking>/,/<\/CompilerOptions>/c\
82+
     <Options>\
83+
        <PassLinkerOptions Value="True"/>\
84+
        <LinkerOptions Value="&apos;-framework IOKit&apos;"/>\
85+
      </Options>\
86+
    </Linking>\
87+
    <Other>\
88+
      <CustomOptions Value="&apos;-WM11.0&apos;"/>\
89+
    </Other>\
90+
  </CompilerOptions>'
91+
find examples -type f -name "*.lpr" -print0 | xargs -0 sed -i '' '/^uses/ s/^\(uses\)/\1 CocoaAll,/'
92+
find examples -type f -name "*.pas" -print0 | xargs -0 sed -i '' '/^uses/ s/^\(uses\)/\1 CocoaAll,/'
93+
```
94+
##### Note about running this twice
95+
If you run this twice then you will probably have to edit the .lpr files manually to remove the extra `CocoAll,` which is easy and not a big deal. The compiler will tell you about it if you run it twice and don't notice.
96+
97+
98+
# FAQ
99+
## Q: What if this doesn't work?
100+
After doing one of the options above you should be able to run the examples by choosing one and loading that projects `.lpi` file into Lazarus. At that point select the menu option: `Run->Run Without Debugging` and the example should fire right up. You should be able to tweak the examples to your hearts content and it should all work.
101+
102+
This should work for all of the included example projects but if a few of them don't work then a little manual investigation into that project should solve it.
103+
1. The main pascal file should have `CocoaAll` in its uses section. Usually its a `.lpr` file but sometimes it might be `.pas` file.
104+
2. The .lpi file should have the `-WM11` and the `-framework IOKit` options added near the end
105+
3. I [made a video about this process](https://youtu.be/h2-GrChtwMY?si=QbW_rwmVjI7JGDvP&t=341) since it could help to see me do it.
106+
4. If you need to redownload the examples [from the github](https://github.com/GuvaCode/Ray4Laz) I don't blame you, I had to do that several times to make this :)
107+
5. You can use Option 2 above to try again on just one project.
108+
## Q: What about the `macosx_version_min` error?
109+
This is not a problem wth Ray4Laz. This is a small problem with the build of the Free Pascal Compiler on Mac Mseries and can *safely be ignored*. It shows up as an error but I have seen no ill effects and everything I have done has worked in spite of this error showing up in every build.
110+
#### What can you do to fix the macosx_version_min_error?
111+
This is a small problem related to the fpc compiler that you can either *safely ignore* or you can fix it in your own local build by changing just one character in a file if you want to. [I made a video about fixing this](https://www.youtube.com/watch?v=0otHOdNNuaE) which in a nutshell involves editing `lazarus/fpcsrc/compiler/systems/t_darwin.pas` and in that file changing `macosx_version_min` to `macos_version_min` and recompiling fpc. Yes It is literally just a one character change. That should fix it until you update fpc from source in which case you will have to do this small fix again.
112+
## Q: Do any of the examples not work on Mac Mseries?
113+
1. `examples/shaders/shaders_custom_uniform` compiles fine but doesn't seem to run. Can you figure out why?
114+
Clues: Once you have compiled it if you go into the ray4laz/binary folder you can run the compiled version and see what error you get. I got `ERROR: 0:46: Use of undeclared identifier 'color'` among others.
115+

example_ Mac_Mseries/for mac m1

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11

2+
3+
#### Specifics for mac m-series:
4+
To compile examples for the Apple m-series, see the [m-series readme](../README_mac_mseries.md) or watch this [video](https://www.youtube.com/watch?v=h2-GrChtwMY)
5+
6+
27
### category: textures
38

49
example | image | difficulty<br>level |

0 commit comments

Comments
 (0)