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

发布于 2024-11-03 21:44:18 字数 745 浏览 0 评论 0原文

我正在尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇俏 2024-11-10 21:44:18

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

如果您运行的是支持 64 位的操作系统/Mac 组合,例如新的 Intel Mac 上的 10.6,它将在 x86_64 中构建。 Carbon 调用仍然可用于您的代码,但仅限那些标记为 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

全部清理并重建。

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:

 *  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

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:

CONFIG -= x86_64
CONFIG += x86

Clean all and rebuild.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文