0

I'm trying to compile some Objective-C code that was written by another programmer on a Mac. I'm using GNUstep for Windows to try and get this code working on my home computer. I really just need his code bits to run, and have little (read: zero) experience with Objective-C. Here is the code:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  AntennaPatternGenAppDelegate.m
//  AntennaPatternGen
//
//

#import "AntennaPatternGenAppDelegate.h"

@implementation AntennaPatternGenAppDelegate

@synthesize window;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Insert code here to initialize your application 
}

@end
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

and here is the header file:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  AntennaPatternGenAppDelegate.h
//  AntennaPatternGen
//
//

#import <Cocoa/Cocoa.h>

@interface AntennaPatternGenAppDelegate : NSObject <NSApplicationDelegate> {
    NSWindow *window;
}

@property (assign) IBOutlet NSWindow *window;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

I am using the following command to try to compile:

gcc -o AntennaPatternGenAppDelegate AntennaPatternGenAppDelegate.m -I /GNUstep/System/Library/Headers \
-L /GNUstep/System/Library/Libraries -lobjc -lgnustep-base

and getting an error saying "cannot find protocol declaration for 'NSApplicationDelegate'", along with several errors that look like syntax errors (stray '@' in program, and some expected identifiers that aren't there)

I've been googling this problem and it seems like the way that protocol declarations happen in Objective C might have changed at some point? People talk about the difference between 10.6 and previous versions of OSX... I'm not sure if this is the same problem I'm facing, or how to make GNUstep work with this older syntax. Again, I have very little idea what I'm talking about, just beginning to get into this programming, so if I've left crucial information out, please let me know.

Thanks for your time!

Eric
  • 1
  • 1
  • These are the exact errors that I'm getting: AntennaPatternGenAppDelegate.h:10:1: error: cannot find protocol declaration for 'NSApplicationDelegate' AntennaPatternGenAppDelegate.h:14:1: error: stray '@' in program AntennaPatternGenAppDelegate.h:14:29: error: expected '=', ',', ';', 'asm' or '_ _attribute__' before 'NSWindow' AntennaPatternGenAppDelegate.m:9:1: error: expected identifier or '(' before 'im plementation' AntennaPatternGenAppDelegate.m:11:1: error: stray '@' in program AntennaPatternGenAppDelegate.m:13:71: error: expected ';' before '{' token – Eric Jul 12 '11 at 20:01
  • 1
    I don't think there is a formal protocol. It must be the informal protocol. You should be able to remove it i.e. remove the `` part. – Deepak Danduprolu Jul 12 '11 at 20:15
  • Removing that part does indeed get rid of the first error on the list, Thank you! Does anybody have any idea how to get rid of the other errors? It doesn't seem to me like the syntax is wrong here, and these programs ostensibly compile just fine on some system somewhere, since they have been used. Am I using the wrong version/options of something here? Thanks! – Eric Jul 12 '11 at 21:19
  • Do you have a corresponding `@end` for `@interface`? – Deepak Danduprolu Jul 13 '11 at 05:33
  • I think it would be easier for you to use GNUstep Makefiles to compile your code. This would prevent you from forgetting to pass some compiler flags. A Tutorial can be found here: http://www.gnustep.it/nicola/Tutorials/WritingMakefiles/index.html – MKroehnert Jul 27 '11 at 13:32

2 Answers2

1

I also had same problem. But removing this NSApplicationDelegate from @interface AntennaPatternGenAppDelegate : NSObject NSApplicationDelegate { it worked fine(compiled with no errors).

surendran
  • 478
  • 1
  • 8
  • 19
0

I've never used GNUStep, but it looks like they might have renamed the protocol GSAppDelegateProtocol. You could try changing any references to NSApplicationDelegate to that and see what happens.

EDIT:

On second thought, it looks like it might be an informal protocol, so you could probably just take it out of the header file entirely (along with the pointy brackets, remove those too) and everything should work fine.

Nate Thorn
  • 2,193
  • 2
  • 23
  • 27