gpt4 book ai didi

macos - 在 Inline::C 中链接 macos 的框架

转载 作者:行者123 更新时间:2023-12-04 07:46:31 26 4
gpt4 key购买 nike

正在尝试使用 Inline::CApplicationServices.h Macos 中的框架。
我的简单代码是:

#!/usr/bin/env perl
use 5.014;
use warnings;
use Inline Config => force_build => 1, clean_after_build => 0;
use Inline C => Config => libs => '-framework ApplicationServices';
use Inline C => 'DATA';

mmove(10,40);
__DATA__
__C__
#include <ApplicationServices/ApplicationServices.h>
#include <unistd.h>

void mmove(int x, int y) {
CGEventRef move = CGEventCreateMouseEvent( NULL, kCGEventMouseMoved, CGPointMake(x, y), kCGMouseButtonLeft );
CGEventPost(kCGHIDEventTap, move);
CFRelease(move);
}
不幸的是,运行时出现链接错误。
dyld: lazy symbol binding failed: Symbol not found: _CGEventCreateMouseEvent
Referenced from: /Users/clt/.Inline/lib/auto/g_649d/g_649d.bundle
Expected in: flat namespace

dyld: Symbol not found: _CGEventCreateMouseEvent
Referenced from: /Users/clt/.Inline/lib/auto/g_649d/g_649d.bundle
Expected in: flat namespace

Abort trap: 6
纯净 C源代码:
#include <ApplicationServices/ApplicationServices.h>
#include <unistd.h>

void mmove(int x, int y);

int main() {
mmove(100,100);
}

void mmove(int x, int y) {
CGEventRef move = CGEventCreateMouseEvent( NULL, kCGEventMouseMoved, CGPointMake(x, y), kCGMouseButtonLeft );
CGEventPost(kCGHIDEventTap, move);
CFRelease(move);
}
gcc -o cl cl.c -Wall -framework ApplicationServices 编译按预期工作。
问题 : 如何正确通过 -framework ApplicationServicesInline::C链接器? (我的 use Inline C => Config => libs => '-framework ApplicationServices'; )不起作用。 (我错过了什么?)

最佳答案

似乎它可能是 ExtUtils::MakeMaker 中的错误,但我还没有能够确切地理解是什么问题。同时,可以使用以下解决方法:

use Config;
use Inline Config => build_noisy => 1, force_build => 1, clean_after_build => 0;
#use Inline C => Config => libs => '-framework ApplicationServices';
use Inline C => Config => lddlflags
=> "$Config{lddlflags} -framework ApplicationServices";
use Inline C => 'DATA';

mmove(10,40);

关于macos - 在 Inline::C 中链接 macos 的框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67172388/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com