在 Inline::C 中链接 macos 的框架
Linking macos's frameworks in Inline::C
尝试在 Macos 中使用 Inline::C 和 ApplicationServices.h
框架。
我的简单代码是:
#!/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 ApplicationServices
传递给Inline::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 和 ApplicationServices.h
框架。
我的简单代码是:
#!/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 ApplicationServices
传递给Inline::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);