如何从 Qt Creator 项目中调用 Carbon 函数?
我正在尝试在 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 看来每个人都已经知道如何包含它,所以任何地方都没有指南,也许这里有人也有指南的链接或其他东西?
I'm trying to use ChangeWindowAttributes() function in Qt Creator project on Mac OS X.
But I can't build the project.
What I've tried:
#include <MacWindows.h>
Result (compiler): File not found
#include <Carbon/Carbon.h>
// Or the same:
#include </Developer/Headers/FlatCarbon/MacWindows.h>
Result (compiler): ChangeWindowAttributes was not declared in this scope
#include <Carbon/Carbon.h>
extern OSStatus ChangeWindowAttributes (
WindowRef window,
WindowAttributes setTheseAttributes,
WindowAttributes clearTheseAttributes
);
// And in *.pro file:
LIBS += -framework Carbon
Result (linker): Undefined Symbols ChangeWindowAttributes( ...
Where am I wrong?
According Google it seems that everybody already knows how to include it, so there are no guides anywhere. Maybe someone here also has a link to the guide or something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,QT Creator 在 Mac 的 CPU 架构中构建您的项目。这些库本身采用 x86 和 x86_64 通用二进制文件。如果您使用的是诺基亚的预构建 SDK,则会出现这种情况。
如果您运行的是支持 64 位的操作系统/Mac 组合,例如新的 Intel Mac 上的 10.6,它将在 x86_64 中构建。 Carbon 调用仍然可用于您的代码,但仅限那些标记为 64 位兼容的代码。打开 MacWindows.h 并找到 ChangeWindowAttributes。您将在评论中看到:
如果您必须调用此(以及其他仅 32 位)函数,则必须强制 Creator 以 32 位 (x86) 构建它。将这些行添加到您的 .pro 文件中:
全部清理并重建。
By default, QT Creator build your project in your Mac's CPU architecture. The libraries themselves come in x86 and x86_64 universal binaries. This is if you are using the prebuild SDK from Nokia.
If you are running 64-bit capable OS/Mac combination, like 10.6 on a new Intel Mac, it will build it in x86_64. Carbon calls are still available to your code but only those marked as 64-bit compatible one. Open MacWindows.h and find ChangeWindowAttributes. You will see in the comment:
If you have to call this (and other 32-bit only) function, you'll have to force Creator to build it in 32-bit (x86). Add these lines to your .pro file:
Clean all and rebuild.