如何从Qt Creator项目中调用Carbon函数?

时间:2011-04-28 16:26:43

标签: c++ qt macos

我正在尝试在Mac OS X上的Qt Creator项目中使用ChangeWindowAttributes()函数。 但我无法建立这个项目。

我尝试了什么:

#include <MacWindows.h>

结果(编译器):找不到文件

#include <Carbon/Carbon.h>

// Or the same:
#include </Developer/Headers/FlatCarbon/MacWindows.h>

结果(编译器):未在此范围内声明ChangeWindowAttributes

#include <Carbon/Carbon.h>
extern OSStatus ChangeWindowAttributes (
   WindowRef window,
   WindowAttributes setTheseAttributes,
   WindowAttributes clearTheseAttributes
);

// And in *.pro file:
LIBS += -framework Carbon

结果(链接器):未定义的符号ChangeWindowAttributes(...

我哪里错了?

根据Google的说法,似乎每个人都知道如何包含它,所以在任何地方都没有指南。也许有人在这里也有指南或其他东西的链接?

1 个答案:

答案 0 :(得分:1)

默认情况下,QT Creator会在Mac的CPU架构中构建您的项目。这些库本身有x86和x86_64通用二进制文件。如果您使用的是诺基亚的prebuild SDK,那就是这样。

如果您正在运行支持64位的OS / Mac组合,例如在新的Intel Mac上运行10.6,它将在x86_64中构建它。碳调用仍然可用于您的代码,但仅限于那些标记为64位兼容的代码。打开MacWindows.h并找到ChangeWindowAttributes。您将在评论中看到:

 *  Availability:
 *    Mac OS X:         in version 10.0 and later in Carbon.framework [32-bit only]
 *    CarbonLib:        in CarbonLib 1.0 and later
 *    Non-Carbon CFM:   not available

如果必须调用此(以及其他仅32位)函数,则必须强制Creator以32位(x86)构建它。将这些行添加到.pro文件中:

CONFIG -= x86_64
CONFIG += x86

全部清理并重建。