我有一个简单的" Hello world"在Xcode中键入程序,我尝试使用外部库,但是我收到了编译错误。该库是Magtek edynamo macOS sdk:
https://www.magtek.com/Content/SoftwarePackages/1000004036.zip
(父页面为https://www.magtek.com/support/edynamo?tab=software;下载为macOS SCRA SDK)
这是我的代码:
#import "MTSCRA.h"
int main (int argc, const char * argv[])
{
MTSCRA* mtSCRALib = [[MTSCRA alloc] init];
return 0;
}
所以基本上我只是导入库并尝试实例化其中一个类。 Xcode不会在任何地方显示任何内联编译错误,但是当我尝试构建和运行时,会导致各种未定义的符号错误,例如:
Undefined symbols for architecture x86_64:
"_NSApplicationWillTerminateNotification", referenced from:
-[HIDManager init] in libMTSCRAOSX.a(HIDManager.o)
和诸如此类的警告:
ld: warning: object file (/path/HelloWorld/libMTSCRAOSX.a(MTSCRA.o)) was built for newer OSX version (10.12) than being linked (10.11)
(如果我注释掉MTSCRA* mtSCRALib = [[MTSCRA alloc] init];
行,它运行正常。)
这些是我在Xcode项目中包含库的步骤:
这是我的环境:
尝试了所有谷歌解决方案;没有用。任何帮助......其他任何人都可以成功导入和使用这个库吗?
答案 0 :(得分:0)
解决了这个问题。不确定这些是否是新手错误,但我有两个问题:
1)我还需要包含库/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX. platform / Developer / S DKs / MacOSX.sdk / usr / l ib / libstdc ++。6.0 .9.t BD
2)我还必须导入#import <Cocoa/Cocoa.h>
。所以:
#import "MTSCRA.h"
#import <Cocoa/Cocoa.h>
int main (int argc, const char * argv[])
{
MTSCRA* mtSCRALib = [[MTSCRA alloc] init];
return 0;
}