How do I compile a GNUstep application that uses NSApplication on Windows?

I am learning about 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 snippet, to say the least, and it obviously won't do anything. I've tried several different import statements including Cocoa / Cocoa.h, GNUstepGUI / GMAppKit.h, etc. But I've always run into compilation errors that I can't find help on the internet.

This is my compile command that I run 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 am getting:

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 for #import or what needs to be fixed in my compile command?

Thank!

+2


source to share


2 answers


Thanks to Peter Hosey I was able to google myself on the answer page:

http://psurobotics.org/wiki/index.php?title=Objective-C

Unlike OS X development, you need a "makefile":

Place this in 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 run

make

The page indicates execution

openapp ./MyAppName.app
but the .exe file in the .app folder seems to start on its own.
+3


source


This is a linker error. #import

is a preprocessor directive; it won't resolve the linking error, and you wouldn't get to the link if you had a preprocessor error. Anyway.



You need to link with Foundation and AppKit (especially the latter, for NSApplication) or any GNUstep equivalents.

+2


source







All Articles