这个程序有什么问题?
// main.m
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **)argv);
}
我尝试编译并得到此错误:
$ clang -framework Foundation main.m
Undefined symbols for architecture x86_64:
"_NSApplicationMain", referenced from:
_main in main-c04948.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$
答案 0 :(得分:1)
你已经与基金会联系,但不是AppKit或Cocoa。 NSApplicationMain()
是AppKit的一部分。您需要将-framework Foundation
替换为-framework AppKit
或-framework Cocoa
(它们或多或少是同义词)。