@ -67,7 +67,7 @@ _Tutorial written by Aleix Rafegas and trasnlated to english by Ray_
You can create a build.sh file that you can run to compile your project. In the example below your project is named test.cpp (for c++) and compiles to test.
Now running build.sh (After setting permissions appropriately) will compile your program! No XCode needed.
Now running build.sh (After setting permissions appropriately) will compile your program! No XCode needed.
# Building Statically, so you can Run on Other Computers
Let me show you something cool.
````
otool -L my_app
````
This shows you everything your application links to. Basically, if anything is pointing to anything but /usr/lib/* or /System/Library/*, your application will throw an error if you run it on any other Mac. It's not portable. Right now, perhaps it's linking to something in /usr/local/lib, or a relative folder. This is bad. We must fix.
Another thing to observe:
````
otool -l my_app
````
Whoa that was a bunch of stuff. Disregard most of it and try to find "LC_VERSION_MIN_MACOSX", look below and find the version number, this will likely be the version of the computer you are currently on. That means anyone on an older OS will receive an error. Again: Bad. We Fix.
First things first, let's make sure we get a reasonable amount of playability on older versions of MacOS. Executing this code before compiling packages, will make sure that your program will run without error on Macs 10.9 and up. (Perhaps you can do older, but you get a warning at 10.8 and lower when compiling)
````
export MACOSX_DEPLOYMENT_TARGET=10.9
````
You'll need to rebuild raylib + glfw for the above to affect anything, fortunately that's what we're doing next.
Next, let's make sure we are statically generating the build. This pulls in raylib and glfw, so that your computer isn't seeking these libraries out dynamically during run time.
Perhaps this isn't required - I suppose you can just pull in the dylib from a relative directory when you package your executeable in a bundle, but this is what I got to work for now.
Unfortunately, when you built glfw in a step above using Homebrew, it builds a dylib, not a static .a file. I had to clone from github and then build the library from scractch using cmake -DBUILD_SHARED_LIBS=OFF
Let's confirm MACOSX_DEPLOYMENT_TARGET did it's thing.
````
otool -l libglfw3.a
````
Check under LC_VERSION_MIN_MACOSX for version. It should read 10.9
Rebuild raylib, so the OSX version command above takes effect, and confirm.
````
otool -l libraylib.a
````
All good? Good.
Once that's done, copy libglfw3.a and librarylib.a into the root directory, and you can link to it like so: