A problem with Objective-C headers when compiling C++ JUCE application on OSX 10.10.5, XCode 6.4, QtCreator 3.5 on Macbook Pro.
I am transferring to OSX a C++ application that uses JUCE and which builds and runs fine on Windows 7. I am using Qt Creator as the IDE for building the files. The juce modules I need are being compiled in situ, e.g. the file include_juce_audio_basics.cpp which does #include "../../juce/modules/juce_audio_basics/juce_audio_basics.cpp". My own (generic) code builds fine, but when the compiler hits the juce modules it tries to include NSObjCRuntime.h. which I believe is an Objective C module which is not fully compilable with the c++ compiler and I get syntax errors. I read that such inclusions can be avoided with #ifdef __OBJC__ ... #endif, but where woudl I put these conditional compilation directives and is this the correct solution?
You shouldn't be including the juce_audio_basics.cpp. On Mac you need to include juce_audio_basics.mm. You need to do the same with any other modules which have .mm file in the modue folder. The file suffix will tell the compiler to expect Obj-C.
(Except that the backslashes are each followed by a new line - it doesn't format well in this post)
This solves the compilation errors, but now I get link errors, e.g. "undefined symbol _AudioDeviceCreateIOProcID". Yes, I know these errors are due to OSX libraries that need to be linked and that I need to add to the LIBS section of my project file, but do you have any advice for the best way to find the names of the OSX libraries corresponding to each missing symbol?
P.S. In case readers are wondering why I am using QtCreator to build a JUCE project, it is because QtCreator has a good debugger, which I like using.
To use Qt Creator to build C++ files with JUCE and link to the OSX frameworks, a QtCreator .pro file needs to be formatted as below. I found out how to do this after a lot of searching on the web. Of course, the detail of directory paths and which juce modules you wish to include will be specific to your project. If you get link errors, then Google the missing symbol (without the underscore prefix) and look at the OSX help page. It will usually have a #import statement on the right hand side, telling you the name of the framework required. Please note the \ symbols that mark line ends. They have not formatted properly in ths post.