ofxSyphon icon indicating copy to clipboard operation
ofxSyphon copied to clipboard

Compilation on OSX with QT-creator

Open Daandelange opened this issue 8 years ago • 3 comments

Hey, I'v been trying to compile ofxSyphon with Qt creator instead of Xcode and finally succeeded. :)

  • Generate a qt-creator project with the Project Generator frontend app.
  • Then set your ofApp.qbs file to match these lines:
ofApp {
    // dirty workaround for Qt Creator not parsing .mm files from the addons folder
    files: [
        // main.cpp, ofApp.h+cpp, etc.
        '../../../addons/ofxSyphon/src/ofxSyphonClient.mm',
        '../../../addons/ofxSyphon/src/ofxSyphonServer.mm',
        '../../../addons/ofxSyphon/src/ofxSyphonServerDirectory.mm',
        '../../../addons/ofxSyphon/libs/Syphon/src/SyphonNameboundClient.m'
    ]
    of.includePaths: [
        '../../../addons/ofxSyphon/libs',
        '../../../addons/ofxSyphon/libs/Syphon',
        '../../../addons/ofxSyphon/libs/Syphon/lib',
        '../../../addons/ofxSyphon/libs/Syphon/lib/osx',
        '../../../addons/ofxSyphon/libs/Syphon/src',
        '../../../addons/ofxSyphon/src',
    ]
    // include macosx framework
    of.frameworks: ['Syphon']
}
  • Adding the .framework library search path doesn't work so you have to copy the Syphon.framework to /Library/Frameworks in order to link against it.
  • Then it should compile correctly but won't launch on other computers. To fix this, either copy /addons/ofxSyphon/libs/Syphon/lib/Syphon.Framework to /bin/ofApp/Contents/Frameworks/Syphon.Framework or copy Syphon.framework to /Library/Frameworks on the computer you'd like to run your ofApp on.

So that's about how far I got, the next step would be using the Syphon.Framework from the addons folder rather then from /Library/Frameworks. Any ideas ? With these lines I couldn't get it to work while it should. (even using absolute paths) of.linkerFlags: ['-F../../../addons/ofxSyphon/libs/Syphon/lib/osx'] of.cxxFlags: ['-F../../../addons/ofxSyphon/libs/Syphon/lib/osx']

Including the Syphon.Framework copy step in the Qt build process would be nice too.

(Still looking for better solutions so no PR yet, leaving issue open until then.)

Daandelange avatar Mar 19 '16 15:03 Daandelange

The linker will also need -framework Syphon

Don't know much about Qt Creator so not sure about the framework copy I'm afraid

bangnoise avatar Mar 03 '19 00:03 bangnoise

Hey, thanks for your reply. Feeding the linker with -framework Syphon throws an unrecognized linker argument warning, but it links fine with of.frameworks: ['Syphon'].

For the record, here's an updated .qbs snippet to get ofxSyphon to compile with QtCreator. This example works fine with Simple Client.app.

So I'm back on getting ofxSyphon to work with QtCreator and hopefully resolve this issue, could you give me some insights ?

The issue is about how #include <Syphon/Syphon.h> is resolved ( in 4 different files).

  • Option 1 : Using #include "Syphon.h" instead works great, but that breaks compilation on Xcode, so I made a compilation flag to make it work without breaking ofxSyphon.
  • Option 2 : Make an alias in an included search directory, so Syphon/Syphon.h can be resolved. .QBS : of.includePaths: ['../../../addons/ofxSyphon/libs/Syphon/lib/osx/'] cd ofxSyphon/libs/Syphon/lib/osx && ln -s Syphon.framework/Headers Syphon : image
  • Option 3: Any other idea ?

Also, C++ references state that #include <something> is for system includes (/System/Library/Frameworks/), while ofxSyphon seems to use a local framework. So shouldn't it be #include "Syphon/Syphon.h" ?

Daandelange avatar Dec 05 '20 20:12 Daandelange

Ok, I found the right solution.

Qt Creator provides a way of setting framework search paths, together with the frameworks.
While oF wraps and documents cpp.frameworks, there's no trace of frameworkPaths. But there's a way of setting it trough qt's cpp module directly, and that works !

Also, regarding my last question, #include <Framework/Something.h> seems to be the way to go for including Apple Frameworks.

Here's an updated example of ofxSyphon working with Qt Creator.

Daandelange avatar Dec 05 '20 22:12 Daandelange