Reputation: 1448
I am exploring with compiling an application with GNUstep on Windows. This is my main.m file:
#import <???/???.h>
int main(int argc, const char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
[pool release];
}
I realize this is an incomplete fragment to say the least and it obviously won't do anything. I have tried several different import statements including Cocoa/Cocoa.h, GNUstepGUI/GMAppKit.h, etc. But I always run into errors with compiling that I can't seem to find help with online.
This is my compile command, which I am running from the mingw shell:
gcc -o test main.m -I /GNUstep/System/Library/Headers/ \ -L /GNUstep/System/Library/Libraries/ -lobjc -lgnustep-base \ -fconstant-string-class=NSConstantString -enable-auto-import
These are the errors I get:
c:/WINDOWS/TEMP/ccHxKZG2.o:main.m(.data+0x390): undefined reference to '___objc_class_name_NSApplication' collect2:ld returned 1 exit status
Any ideas on what I need to #import, or what needs fixing in my compile command?
Thanks!
Upvotes: 3
Views: 4251
Reputation: 21
Under Linux, you can compile with gcc :
gcc ``gnustep-config --objc-flags --gui-libs`` -o main main.m -L /usr/include/GNUstep/ -lobjc -lgnustep-base -lgnustep-gui
Upvotes: 0
Reputation: 1448
Thanks to Peter Hosey I was able to Google myself to the page with the answer:
http://psurobotics.org/wiki/index.php?title=Objective-C
Unlike OS X development, you need a "makefile":
Put this into a file called "GNUmakefile" in the same directory as your source:
include $(GNUSTEP_MAKEFILES)/common.make APP_NAME = MyAppName MyAppName_HEADERS = MyAppName_OBJC_FILES = main.m MyAppName_RESOURCE_FILES = include $(GNUSTEP_MAKEFILES)/application.make
Then execute
make
The page says to execute
openapp ./MyAppName.appbut the .exe file within the .app folder appears to run on its own.
Upvotes: 4
Reputation: 96373
That's a linker error. #import
is a preprocessor directive; it won't solve an error in linking, and you wouldn't have gotten as far as linking if you'd had a preprocessor error, anyway.
You need to link against Foundation and AppKit (especially the latter, for NSApplication), or whatever GNUstep's equivalents are.
Upvotes: 3