Add IOKIT framework to *.pro file



  • Hi

    I am trying to use IOKIt framework in my macOS application developed with Qt5.9.1. I have added into the *.pro file this code

    LIBS += -framework IOKit

    but the compilation line does not contain any reference to this framework and IOKitLib.h file is not found. Can anyone tell me what I am doing wrong ?

    thanks
    Bogdan


  • Lifetime Qt Champion

    Hi,

    Did you re-run qmake after add the framework ?

    How are you including the headers from the framework ?



  • Hi
    Yes, I have rerun qmake. Following this link
    http://doc.qt.io/qt-5/qmake-platform-notes.html#using-frameworks
    no explicit path to IOKit framework header was added.

    Also, at compile time I can see 2 other frameworks from macOS being used, but not IOKit. Below is the error I get:

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++11  -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.10 -Wall -W -fPIC -DAPP_VERSION=\"6.0.7.4\" -DQT_QML_DEBUG -DQT_QUICK_LIB -DQT_SVG_LIB -DQT_WIDGETS_LIB -DQT_MACEXTRAS_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I../FM -I. -I../FM/sources/FocusGroup -I../FM/headers -I../FM/sources/Controllers -I../FM/sources/Utils -I../FM/sources -I../../../Qt/5.9.1/clang_64/lib/QtQuick.framework/Headers -I../../../Qt/5.9.1/clang_64/lib/QtSvg.framework/Headers -I../../../Qt/5.9.1/clang_64/lib/QtWidgets.framework/Headers -I../../../Qt/5.9.1/clang_64/lib/QtMacExtras.framework/Headers -I../../../Qt/5.9.1/clang_64/lib/QtGui.framework/Headers -I../../../Qt/5.9.1/clang_64/lib/QtQml.framework/Headers -I../../../Qt/5.9.1/clang_64/lib/QtNetwork.framework/Headers -I../../../Qt/5.9.1/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/AGL.framework/Headers -I../../../Qt/5.9.1/clang_64/mkspecs/macx-clang -F/Users/b/Qt/5.9.1/clang_64/lib -o DialogTrayIcon.o ../FM/sources/Controllers/DialogTrayIcon.cpp
    ../FM/sources/Controllers/DialogTrayIcon.cpp:8:10: fatal error: 'IOKitLib.h' file not found
    

    Bogdan


  • Lifetime Qt Champion

    What version of Xcode are you using ?

    Can you show how you include IOKitLib.h ?
    Can you show the complete .pro file for your project ?



  • Hi
    I am using latest Xcode version from macOS Sierra. Unfortunately I cannot post the entire *.pro file. However, after specifying in INCLUDEPATH IOKitLib.h path it seems that I can get past the above error.
    Bogdan


  • Lifetime Qt Champion

    Are you using #include <IOKitLib.h> or #include <IOKit/IOKitLib.h> ?



  • Just #include <IOKitLib.h>. The problem seems to solved, I just needed to add in INCLUDEPATH the path to the framework header and in LIBS "-framework IOKit"


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.