New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling RoR on Mac OS X (10.11 El Capitan) #1043

Closed
chilledfrogs opened this Issue Jun 6, 2016 · 4 comments

Comments

Projects
None yet
2 participants
@chilledfrogs

chilledfrogs commented Jun 6, 2016

Hello there everyone,

I'm trying to perform the milestone of building RoR on Mac OS X with the help of @Hiradur. So far I managed to get relatively far, but rather ironically the build fails on RoR itself with compiler errors originating from Apple's system headers (absolutely all the errors so far originate from Settings.cpp):

source/main/utils/Settings.cpp:358:
In file included from /System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:23:
In file included from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:23:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:31:
/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Finder.h:246:3: error: reference to 'Rect' is ambiguous
  Rect                windowBounds;           /* The position and dimension of the folder's window */
  ^
/usr/include/MacTypes.h:550:41: note: candidate found by name lookup is 'Rect'
typedef struct Rect                     Rect;
                                        ^
/Users/allen/rigs-of-rods/install/include/OGRE/OgreCommon.h:653:31: note: candidate found by name lookup is 'Ogre::Rect'
        typedef TRect< long > Rect;
                              ^

As well as this:

In file included from /System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:23:
In file included from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:23:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:35:
/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/FixMath.h:25:8: error: expected unqualified-id
extern "C" {
       ^

In file included from /System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:23:
In file included from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:23:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:39:
/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Script.h:29:8: error: expected unqualified-id
extern "C" {
       ^

In file included from /System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:23:
In file included from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:23:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:43:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/UTCUtils.h:22:
/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MacErrors.h:24:8: error: expected unqualified-id
extern "C" {
       ^

In file included from /System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:23:
In file included from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:23:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:43:
/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/UTCUtils.h:34:8: error: expected unqualified-id
extern "C" {
       ^

In file included from /Users/allen/rigs-of-rods/source/rigs-of-rods/source/main/utils/Settings.cpp:358:
In file included from /System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:23:
In file included from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:23:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:47:
/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/TextCommon.h:30:8: error: expected unqualified-id
extern "C" {
       ^

And so on and so on, it goes through quite a few files down the line with the same error. Now an important thing to note is that in this very file (Settings.cpp), there was some Mac OS-specific code which seems to not have been thoroughly looked through since by itself it had tons of functions, datatypes, etc. which were to be found in these system headers, and the appropriate includes weren't put. Here's these lines of Settings.cpp:

#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
    //found this code, will look later ~~ I included the following after some research
#include <sys/cdefs.h>
#include <ApplicationServices/ApplicationServices.h>
#include <CoreFoundation/CFURL.h>
#include <CoreServices/CoreServices.h>
    String path = "./";
    ProcessSerialNumber PSN;
    ProcessInfoRec pinfo;
    FSSpec pspec;
    FSRef fsr;
    OSStatus err;
    /* set up process serial number */
    PSN.highLongOfPSN = 0;
    PSN.lowLongOfPSN = kCurrentProcess;
    /* set up info block */
    pinfo.processInfoLength = sizeof(pinfo);
    pinfo.processName = NULL;
    pinfo.processAppSpec = &pspec;
    /* grab the vrefnum and directory */

    //path = "~/RigsOfRods/";
    //strcpy(user_path, path.c_str());

    err = GetProcessInformation(&PSN, &pinfo);
    if (! err ) {
        char c_path[2048];
        FSSpec fss2;
        int tocopy;
        err = FSMakeFSSpec(pspec.vRefNum, pspec.parID, 0, &fss2);
        if ( ! err ) {
            err = FSpMakeFSRef(&fss2, &fsr);
            if ( ! err ) {
                err = (OSErr)FSRefMakePath(&fsr, (UInt8*)c_path, 2048);
                if (! err ) {
                    path = c_path;
                    path += "/";
                    strcpy(program_path, path.c_str());
                }

                err = FSFindFolder(kOnAppropriateDisk, kDocumentsFolderType, kDontCreateFolder, &fsr);
                if (! err ) {
                    FSRefMakePath(&fsr, (UInt8*)c_path, 2048);
                    if (! err ) {
                        path = c_path;
                        path += "/Rigs\ of\ Rods/";
                        strcpy(user_path, path.c_str());
                    }
                }
            }
        }
    }
#endif

Now the reason why I had to include all those libraries is, at least from what's written here (https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/OSX_Technology_Overview/SystemFrameworks/SystemFrameworks.html), which I would consider that rather trustworthy since it's Apple themselves that wrote that, is that since some of the datatypes, functions, etc. to be included are in umbrella frameworks, I had to include the whole umbrella framework and not the individual header files from the necessary subframeworks in order for the compiler to find it properly. I must admit I didn't try including the files with absolute paths, but I would doubt that that would make a difference to be honest.

I tried using gcc-5 from Homebrew but with pretty much the same errors. Now I am using libc++ but without it produces the same effect :/. Anyway here attached is a patch file for all the changed files (I think), out of necessity actually...
osx.patch

To date my cmake options are the following (for RoR): cmake -DCMAKE_INSTALL_PREFIX=~/rigs-of-rods/install/ -DCMAKE_CXX_FLAGS="-O0 -std=c++11" -DROR_BUILD_CONFIGURATOR=OFF -DOIS_DIR=~/rigs-of-rods/source/rigs-of-rods/CMake/Templates/

@Hiradur

This comment has been minimized.

Show comment
Hide comment
@Hiradur

Hiradur Jun 6, 2016

Contributor

Moving the #includes to the beginning of the file fixed these errors, next error is:

error: no member named 'vRefNum' in 'FSSpec'
                err = FSMakeFSSpec(pspec.vRefNum, pspec.parID, 0, &fss2);
Contributor

Hiradur commented Jun 6, 2016

Moving the #includes to the beginning of the file fixed these errors, next error is:

error: no member named 'vRefNum' in 'FSSpec'
                err = FSMakeFSSpec(pspec.vRefNum, pspec.parID, 0, &fss2);
@Hiradur

This comment has been minimized.

Show comment
Hide comment
@Hiradur

Hiradur Jun 8, 2016

Contributor

Status report: compiler errors fixed, now onto linking errors...

Contributor

Hiradur commented Jun 8, 2016

Status report: compiler errors fixed, now onto linking errors...

@chilledfrogs

This comment has been minimized.

Show comment
Hide comment
@chilledfrogs

chilledfrogs Jun 8, 2016

Concerning

error: no member named 'vRefNum' in 'FSSpec'
err = FSMakeFSSpec(pspec.vRefNum, pspec.parID, 0, &fss2);

turns out that it was old code, too old for Mac OS X now, was replaced entirely (let's hope it works)

chilledfrogs commented Jun 8, 2016

Concerning

error: no member named 'vRefNum' in 'FSSpec'
err = FSMakeFSSpec(pspec.vRefNum, pspec.parID, 0, &fss2);

turns out that it was old code, too old for Mac OS X now, was replaced entirely (let's hope it works)

@Hiradur

This comment has been minimized.

Show comment
Hide comment
@Hiradur

Hiradur Jul 15, 2016

Contributor

All build issues have been fixed, build instructions will hopefully be updated soon.

Contributor

Hiradur commented Jul 15, 2016

All build issues have been fixed, build instructions will hopefully be updated soon.

@Hiradur Hiradur closed this Jul 15, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment