Mac OS X linker error in Qt; CoreGraphics & CGWindowListCreate
- by Jake Petroules
Here is my .mm file
#include "windowmanagerutils.h"
#ifdef Q_OS_MAC
#import </System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Headers/CGWindow.h>
QRect WindowManagerUtils::getWindowRect(WId windowId)
{
    CFArrayRef windows = CGWindowListCreate(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
    return QRect();
}
QRect WindowManagerUtils::getClientRect(WId windowId)
{
    return QRect();
}
QString WindowManagerUtils::getWindowText(WId windowId)
{
    return QString();
}
WId WindowManagerUtils::rootWindow()
{
    QApplication::desktop()->winId();
}
WId WindowManagerUtils::windowFromPoint(const QPoint &p, WId parent, bool(*filterFunction)(WId))
{
    return NULL;
}
void WindowManagerUtils::setTopMostCarbon(const QWidget *const window, bool topMost)
{
    if (!window)
    {
        return;
    }
    // Find a Cocoa equivalent for this Carbon function
    // [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
    // OSStatus ret = HIViewSetZOrder(this->winId(), kHIViewZOrderAbove, NULL);
}
#endif
The linker is telling me "_CGWindowListCreate" is undefined. What libraries must I link to? Apple's documentation is not very helpful on telling what to include or link to, like MSDN is. Also I couldn't just do #import <CGWindow.h>, I had to specify the absolute path to it... any way around that?