Reputation: 83
I created a new cocoa application in Xcode with 3 *.m files (main.m, AppDelegate.m, and projectnameTests.m). In order to to use object-cpp, I renamed the 3 *.m files to *.mm files.
Then I get this following error from Xcode:
"Undefined symbols for architecture x86_64: "_NSApplicationMain", referenced from: _main in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)"
I have never dealt .o files, so am not sure what's wrong. Please help.
P.S.: I use the latest Xcode, version(6.1.1).
Upvotes: 8
Views: 1788
Reputation: 902
Add AppKit.framework to the "Link Binary With Libraries" section under the Build Phases for your project target, and that should fix the problem.
P.S. Don't ask me why XCode automatically finds the necessary framework (i.e. AppKit.framework) for .m files but not for .mm files, but adding AppKit.framework fixes the issue because NSApplicationMain is defined in AppKit. Adding Cocoa.framework also fixes the issue, likely because it triggers XCode to automatically link with AppKit.framework.
Upvotes: 12