Skip to content

Instantly share code, notes, and snippets.

@ssrlive
Last active October 30, 2021 04:45
Show Gist options
  • Save ssrlive/8c84deeed2f4bbaf0f769b292e00313d to your computer and use it in GitHub Desktop.
Save ssrlive/8c84deeed2f4bbaf0f769b292e00313d to your computer and use it in GitHub Desktop.
Objective-C on Linux

install

sudo apt-get install -y build-essential gobjc gobjc++ gnustep gnustep-devel libgnustep-base-dev

sample.m

#import <Foundation/Foundation.h>

@interface C
: NSObject
{
    float f;
}
- (void) gamerHell:(NSString *)name lastName:(NSString *)lastName;
@end

@implementation C

- (void) gamerHell:(NSString *)firstName lastName:(NSString *)lastName {
    NSLog(@"Welcome, %@ %@", firstName, lastName);
}

@end

int main(int argc , const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    C *ob = [[C alloc] init];
    [ob gamerHell:@"SHAN" lastName:@"UL=HAQ"];
    [ob release];
    [pool drain];
    return 0;
}

build

gcc `gnustep-config --objc-flags` *.m -lgnustep-base -lobjc

run

./a.out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment