Reputation: 8185
Whats wrong with this program?
// main.m
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **)argv);
}
I try to compile and get this error:
$ 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)
$
Upvotes: 4
Views: 2709
Reputation: 90531
You've linked against Foundation, but not AppKit or Cocoa. NSApplicationMain()
is part of AppKit. You need to replace -framework Foundation
with -framework AppKit
or -framework Cocoa
(they are more or less synonymous).
Upvotes: 3