Open CuriousMike56 opened 1 year ago
It appears /proc/self/exe
doesn't exist on macOS, and chilledfrogs patch addresses this: https://gist.github.com/chilledfrogs/a98f9457f81163f0e90c86f72d1dc60a#file-osx-patch-L214
So I replaced
https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/utils/PlatformUtils.cpp#L179-L191
with
std::string GetExecutablePath()
{
const int BUF_SIZE = 500;
std::string buf_str(BUF_SIZE, 0);
// program path
uint32_t lenb = (uint32_t) BUF_SIZE;
char procpath[BUF_SIZE];
if (_NSGetExecutablePath(procpath, &lenb) == -1)
{
RoR::LogFormat("[RoR] Internal error: GetExecutablePath() failed; readlink() sets errno to %d", static_cast<int>(errno));
return std::string();
}
return std::move(buf_str);
}
Which gave me this output:
[RoR] Rigs of Rods (www.rigsofrods.org) version 2022.12-dev-503b6b0a-dirty
[RoR] Current date: 2022-12-09
[RoR|CVar] sys_config_dir: "/Users/mike/RigsOfRods/config" (was: "")
[RoR|CVar] sys_cache_dir: "/Users/mike/RigsOfRods/cache" (was: "")
[RoR|CVar] sys_thumbnails_dir: "/Users/mike/RigsOfRods/thumbnails" (was: "")
[RoR|CVar] sys_savegames_dir: "/Users/mike/RigsOfRods/savegames" (was: "")
[RoR|CVar] sys_screenshot_dir: "/Users/mike/RigsOfRods/screenshots" (was: "")
FATAL ERROR: An internal error occured in Rigs of Rods.
Technical details below:
Resources folder not found. Check if correctly installed.
Program ended with exit code: 255
/Users/mike/RigsOfRods/logs/RoR.log
was created, only contains the beginning [RoR*]
lines though.
I apologize for my ignorance with C++, all I do is just copy paste code and hope it works 😄
@CuriousMike56 Would you like to do a PR for this? The patch would then be
diff --git a/source/main/utils/PlatformUtils.cpp b/source/main/utils/PlatformUtils.cpp
index 4fc61204..828050ed 100644
--- a/source/main/utils/PlatformUtils.cpp
+++ b/source/main/utils/PlatformUtils.cpp
@@ -36,6 +36,10 @@
#include <unistd.h> // readlink()
#endif
+#ifdef __APPLE__
+#include <mach-o/dyld.h>
+#endif
+
#include <OgrePlatform.h>
#include <OgreFileSystem.h>
#include <string>
@@ -181,7 +185,12 @@ std::string GetExecutablePath()
const int BUF_SIZE = 500;
std::string buf_str(BUF_SIZE, 0);
// Linux or POSIX assumed; http://stackoverflow.com/a/625523
+#ifdef __APPLE__
+ uint32_t buf_size = BUF_SIZE;
+ if (_NSGetExecutablePath(&buf_str[0], &buf_size) != 0)
+#else
if (readlink("/proc/self/exe", &buf_str[0], BUF_SIZE-1) == -1)
+#endif
{
RoR::LogFormat("[RoR] Internal error: GetExecutablePath() failed; readlink() sets errno to %d", static_cast<int>(errno));
return std::string();
@wegank I can absolutely make a PR! That patch now gives me this log
I'm going to do a clean clone of the latest master branch and build Ogre 1.11.6 + MyGUI 3.4.0 again (this time with the same CMake build options as ror-dependencies) and see if that improves anything.
Just got RoR master branch with Ogre 1.11.6 + MyGUI 3.4.0 built, all under Debug mode. I had to change https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/phc.h#L42-L43 to
#include <OpenAL/al.h>
#include <OpenAL/alc.h>
along with applying the above patch. Build failed: https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gui/panels/GUI_RepositorySelector.cpp#L1290 This was caused by curl being disabled, enabling it (also enabled OpenSSL to match my previous build) fixed this.
Next problem was a MyGUI linking error. fixed by changing MyGUI_MyGUIEngine_LIBRARY_DBG
and MyGUI_MyGUIEngine_LIBRARY_REL
in CMake to /usr/local/lib/libMyGUIEngine.3.4.0.dylib
. The old path ended in .framework
.
Finally RoR successfully builds. Unfortunately running it ends with:
dyld: Library not loaded: @executable_path/../Frameworks/OgreBites.framework/Versions/1.11.6/OgreBites
Referenced from: /Users/mike/Documents/GitHub/rigs-of-rods/build/bin/Debug/RoR
Reason: image not found
(lldb)
This was fixed in Ogre 1.12.6: https://github.com/OGRECave/ogre/commit/d13e03f209c411579562aa13209523a8b983f895 It looks like I'll have to backport those changes over to 1.11.6.
So, great news: After applying the changes from the above commit and rebuilding Ogre, RoR runs!... but no visible game window is created. No sign of it in the Dock either. However, I can use the CLI options to load a terrain and vehicle:
./RoR -terrain simple2 -truck b6b0UID-semi.truck -enter
Cg fails to load with the same "Image not found" error:
14:21:10: Loading library /Users/mike/Documents/ogre-1.11.6/build/sdk/lib/debug/Debug/Plugin_CgProgramManager
14:21:10: InternalErrorException: Could not load dynamic library /Users/mike/Documents/ogre-1.11.6/build/sdk/lib/debug/Debug/Plugin_CgProgramManager. System Error: dlopen(/Users/mike/Documents/ogre-1.11.6/build/sdk/lib/debug/Debug/Plugin_CgProgramManager.framework/Plugin_CgProgramManager, 9): Library not loaded: libCg.dylib
Referenced from: /Users/mike/Documents/ogre-1.11.6/build/sdk/lib/debug/Debug/Plugin_CgProgramManager.framework/Versions/1.11.6/Plugin_CgProgramManager
Reason: image not found in DynLib::load at /Users/mike/Documents/ogre-1.11.6/OgreMain/src/OgreDynLib.cpp (line 112)
Creating the render window:
14:21:10: GLRenderSystem::_createRenderWindow "Rigs of Rods version 2022.12-dev-75730fc7-dirty", 800x600 windowed miscParams: FSAA=0 border=fixed gamma=No vsync=Yes
14:21:10: Creating a Cocoa Compatible Render System
14:21:10: Cocoa: Window created 800 x 600 with backing store size 800 x 572 using content scaling factor 1.0
I do see the mouse cursor change position after it tries creating the window. Also after spawning the truck I can hear the engine sounds playing through the speakers. So the window techincally "exists" it seems, just not visible. Could be spawning off the screen?
Quite a few "not supported" errors related to shaders, including the ones used for the terrain:
14:21:12: [RoR|PleaseWaitUI] <44%> Loading terrain pages ...
14:21:12: Terrain created; size=1025 minBatch=17 maxBatch=65 treeDepth=5 lodLevels=7 leafLods=3
14:21:16: RenderingAPIException: Failed to preprocess shader OgreTerrain/3691710056/sm2/vp/hlod/hlod in loadFromSource at /Users/mike/Documents/ogre-1.11.6/RenderSystems/GLSupport/src/GLSL/OgreGLSLShaderCommon.cpp (line 132)
14:21:16: High-level program 'OgreTerrain/3691710056/sm2/vp/hlod/hlod' is not supported: Failed to preprocess shader OgreTerrain/3691710056/sm2/vp/hlod/hlod
14:21:16: RenderingAPIException: Failed to preprocess shader OgreTerrain/3691710056/sm2/fp/hlod in loadFromSource at /Users/mike/Documents/ogre-1.11.6/RenderSystems/GLSupport/src/GLSL/OgreGLSLShaderCommon.cpp (line 132)
14:21:16: High-level program 'OgreTerrain/3691710056/sm2/fp/hlod' is not supported: Failed to preprocess shader OgreTerrain/3691710056/sm2/fp/hlod
14:21:16: RenderingAPIException: Failed to preprocess shader OgreTerrain/3691710056/sm2/vp/llod/llod in loadFromSource at /Users/mike/Documents/ogre-1.11.6/RenderSystems/GLSupport/src/GLSL/OgreGLSLShaderCommon.cpp (line 132)
14:21:16: High-level program 'OgreTerrain/3691710056/sm2/vp/llod/llod' is not supported: Failed to preprocess shader OgreTerrain/3691710056/sm2/vp/llod/llod
14:21:16: RenderingAPIException: Failed to preprocess shader OgreTerrain/3691710056/sm2/fp/llod in loadFromSource at /Users/mike/Documents/ogre-1.11.6/RenderSystems/GLSupport/src/GLSL/OgreGLSLShaderCommon.cpp (line 132)
14:21:16: High-level program 'OgreTerrain/3691710056/sm2/fp/llod' is not supported: Failed to preprocess shader OgreTerrain/3691710056/sm2/fp/llod
14:21:16: Warning: material OgreTerrain/3691710056 has no supportable Techniques and will be blank. Explanation:
Pass 0: vertex program OgreTerrain/3691710056/sm2/vp/hlod/hlod cannot be used - compile error.
Pass 0: vertex program OgreTerrain/3691710056/sm2/vp/llod/llod cannot be used - compile error.
I decided to then make it join a MP server:
/RoR -joinserver="<ip>:12000" -truck b6b0UID-semi.truck
Joined the server using my main PC, and sure enough, its there! (I'm controlling macOS through VNC Viewer)
I'll try launching with OpenGL 3+ next. But overall, it seems we've now much closer to a working macOS build 😄
Thanks to #2983 I was able to get RoR running with OpenGL 3+:
Current OpenGL3Plus issues apply (terrain shaders fail to compile, Cg is dead, etc)
OpenGL2 is currently broken due how macOS handles OpenGL, based on the research I've done it seems you need to tell SDL to specifically request the correct GL version to use, otherwise it falls back to GL 2.1 (results in all shaders failing to compile)
https://stackoverflow.com/a/32958210
Although the This means that on OSX, you never can mix old, deprecated GL featuers with modern features
part might mean OpenGL2 will never work on macOS and we'll have to wait until we fully move to DX11/GL3Plus.
Repository: https://github.com/CuriousMike56/rigs-of-rods/commits/macos-sdl
Great research!
Status: Builds, reaches main menu and in-game, see: https://github.com/RigsOfRods/rigs-of-rods/issues/2981#issuecomment-1347569445
Original post:
In late July, I decided to repurpose an old laptop of mine by installing macOS 11 (Big Sur) onto it using OpenCore. I installed it mostly because I've never owned a Mac before and wanted to experience macOS without going out and buying an actual Apple machine. One of the things I've really wanted to do with it is make another attempt at getting RoR running on macOS. The last attempt was in 2016 (#1078). I didn't say anything about this back in September as I got stuck with compile errors. Thanks to #2979 the code now builds successfully. I am creating this issue ticket to report my findings and to maybe inspire others with macOS to help out.
My setup
Acer R3-471T-560A CPU: i5-4210U GPU: Intel HD 4400 RAM: 12 GB Storage: 512GB SSD Network card: Qualcomm AR9565 ![Screen Shot 2022-12-08 at 1 20 04 PM](https://user-images.githubusercontent.com/46073351/206571713-c7185754-1b42-470b-b19a-8b20dec5a525.png) What doesn't work: - Sleep mode causes reboot (I tried all the fixes on the install guide, ended up just disabling sleep) - Bluetooth - WiFi works but is slower than normal (capped at ~1 MB/s) due to issues with the network card introduced after High Sierra. I am lucky the internal card even works at all)
I have managed to get all the required dependencies configured with CMake 3.24.2 using the Ogre 13 branch:
CMakeCache
Using Xcode 13.2.1, I finally managed to successfully compile a Debug build with .... 1759 warnings. Here is the full build log, along with a log containing just the warnings.
The
dylib was built for newer macOS version (11.7) than being linked (11.6)
is just due to a macOS security update (from 11.6 to 11.7.1) I did a couple weeks ago. Shouldn't be a problem hopefully.When running RoR it requests access to my Downloads folder (which I obviously allow) then it segfaults immediately after.
Stack traces:
It seems the game can't access the file system despite giving it read, write and execute privileges.