Compiling Daz SDK for MacOSX (latest version)

samurlesamurle Posts: 94

I've ran into a lot of issues when compiling the DAZ 4.5 SDK for the latest version of XCode and MacOSX,
but I've managed to fix them all.  Here they are if anybody is interested.

I've used:
MacOSX: El Capitan (v10.11.4)
XCode 7.3.1

The DAZ SDK docs on "Compiling on Apple OSX" are slightly outdated.   They mention using MacOSX 10.5.sdk, but as you probably know, you'll get a compilation error saying you need MacOSX 10.7 or later:
"invalid deployment target for -stdlib=libc++ (requires Mac OS X 10.7 or later)"

So, if you're targeting MacOSX 10.7 or later, these fixes should work.  There is absolutely no need to download or install old MacOS SDKs.

The SDK docs also mention selecting "BSD > Dynamic libraries" when creating a new XCode project, but this no longer exists. You can create a new project by selecting "OSX -> Library", click Next, then change the framework from "Cocoa" to "None (Plain C/C++ Library)". This creates both a Project and a Target.  You can also select "Other" in the beginning, but that will only create an empty project, you will have to add a new Target later.

I used one of the DAZ sample examples for compilation testing, so if you can get that compiled, you should be able to get your own projects compiled.  Those samples are setup for 32-bit, but they can be easily changed to 64-bit.  I've ran into no issues here.  Just change DAZ_PLATFORM_NAME from Mac32 to Mac64, and library paths from /Mac32/ to /Mac64/.

All library/header paths should be surrounded by double quotes.  Some paths may have spaces in them, so that will cause some headaches. I've found it better to use $(SRCROOT) in these cases.

The first compilation errors I got:
"Reference to random_access_iterator_tag is ambiguous"
"Reference to bidirectional_iterator_tag is ambiguous"

These are easy to fix.  If you click on the plus icon by the error message, you'll get more information about. It mentions two ambiguities, std:: and std::__1.  The compiler doesn't understand which one to use.

So, you can edit the QT header files directly:
CHANGE: typedef std::random_access_iterator_tag  iterator_category;
    TO: typedef std::__1::random_access_iterator_tag  iterator_category;

That fixes the ambiguity.

The next compilation error I got:
"getSDKVersion has C-linkage specified, but returns user-defined type 'DzVersion' which is incompatible with C."

For my own project, this showed up as an error.  But for the DAZ samples, it showed up as a warning. Now, obviously, there must be a compiler setting that is treating this warning as an error.  I wasn't able to find this specific setting, as there are dozens of compilation settings, so what I did was copy all the Build Settings compiler options from the DAZ Samples to my own project, and the next time I compiled my project, this error turned into a warning.  But, if anyone knows what specific setting it is, please let me know.

After resolving those two errors, things got a lot easier.


Some other tips:
- Don't surround the path to the Exported Symbols file, exportedPluginSymbols.txt, in double quotes.
  You can use $(SRCROOT) here too.

- If you get fopen() errors, such as "no such file or directory", make sure your path is using forward slashes
  instead of backward slashes.  fopen() on MacOSX will choke on backward slashes.

- If you're getting garbled characters in strings, check to see if you're using wchar_t appropriately.  
  wchar_t is UTF-32 (4 bytes) on MacOSX, while, it's UTF-16 (2 bytes) on Windows.


That's basically it.

 

Post edited by samurle on

Comments

  • samurlesamurle Posts: 94
    edited May 2016

    After getting the compiler settings working for the latest version, it's fairly simple to get older MacOSX SDKs working too (10.7 to 10.11).

    First, download all the older SDKs here:
    https://github.com/phracker/MacOSX-SDKs

    Make sure XCode is quit, and goto your Applications folder.  Right-click on XCode.app, and select "Show Package Contents".

    Browse to:
    Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/

    The latest version of XCode 7.3 only comes with one SDK for MacOSX 10.11, so you should only see MacOSX10.11.sdk in this folder.  Copy and paste all the older sdks here:
    MacOSX10.7.sdk
    MacOSX10.8.sdk
    MacOSX10.9.sdk
    MacOSX10.10.sdk

    It will take several minutes for these files to copy over, so I would just copy over one SDK to test it out.

    There's also one more change you made need.  In the same XCode package, edit this file:
    Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist

    Change MinimumSDKVersion from 10.11 to 10.7.

    Run XCode, and you should now be able to select older SDKs as the deployment target.

    All of this works for the latest version of XCode (7.3) and the latest version of MacOSX (10.11). 

     

    Post edited by samurle on
  • shoei321shoei321 Posts: 113

    Thank you for that.  I'd given up on getting it to compile on OSX a while back -- with your instructions in hand I'll give it another try.

     

     

  • shoei321shoei321 Posts: 113
    edited March 2017

    Regarding the compiler error/warning "getSDKVersion has C-linkage specified, but returns user-defined type 'DzVersion' which is incompatible with C."

    In my case this issue came across as an error, not a warning, when compiling the DAZ-provided samples.    I'm running XCode 8.2.1, macOS 10.12.3. 

    The fix for this was to add a custom compiler flag.   Under Build Settings -> Apple LLVM 8.0 -> Custom Compiler Flags -> Other C++ Flags, add/append the flag "-Wno-return-type-c-linkage".

    Post edited by shoei321 on
  • CypherFOXCypherFOX Posts: 3,401

    Greetings,

    Just to put this out there, this was SO INCREDIBLY HELPFUL.  Thank you.

    --  Morgan

     

Sign In or Register to comment.