Obective-C undefined reference to ___objc_class_name_NSObject on Windows

View: New views
3 Messages — Rating Filter:   Alert me  

Obective-C undefined reference to ___objc_class_name_NSObject on Windows

by ASHKAN HOVEYDAI :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi,

I'm a newcomer to Objective-C. I have Windows XP.
I have downloaded and installed the followings:

gnustep-system-0.23.0-setup
gnustep-core-0.23.1-setup
gnustep-devel-1.0.0-setup

Here is mu first program from a tutorial which is very simple:

#include <stdio.h>
#import <stdio.h>
#import <Foundation/NSObject.h>

@interface MyClass:NSObject{
    int a;
    int b;
    }
    -(void) setvara : (int) x;
    -(void) setvarb : (int) y;
    -(int) add;
@end

@implementation MyClass
   -(void) setvara :(int) x{
     a=x;
   }
   -(void) setvarb :(int) y{
     b=y;
   }
   -(int) add{
     return a+b;
   }
@end


int main(int argc, char *argv[]){

  MyClass *class = [[MyClass alloc]init];
  [class setvara : 5];
  [class setvarb : 6];
  printf("Sum is : %d",[class add]);
  [class release];
  return ;
}


When I use:
   gcc -o filename  filename.h  -I /c/gnustep/gnustep/system/library/headers  -L /c/gnustep/gnustep/system/library/libraries
to compile the file I receive the following errors:

undefined reference to   ___objc_class_name_NSObject
undefined reference to  ___objc_exec_class

1- Could you kindly tell me how I can tackle this problem
2- How can I set any environmental variables so that I can avoid typing
       -I /c/gnustep/gnustep/system/library/headers  -L /c/gnustep/gnustep/system/library/libraries
every time.

Thank you very much for your assistance in advance.

Ashkan












Windows Live: Keep your friends up to date with what you do online.
_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@...
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

Re: Obective-C undefined reference to ___objc_class_name_NSObject on Windows

by David Chisnall :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 19 Oct 2009, at 19:06, ASHKAN HOVEYDAI wrote:

> undefined reference to   ___objc_class_name_NSObject

This means that you have not linked against the library that provides  
the NSObject class (gnustep-base).

> undefined reference to  ___objc_exec_class

This means that you have not linked against the Objective-C runtime  
library.

> 2- How can I set any environmental variables so that I can avoid  
> typing
>        -I /c/gnustep/gnustep/system/library/headers  -L /c/gnustep/
> gnustep/system/library/libraries
> every time.

Either use GNUstep make to build, or add `gnustep-config {options}` to  
your GCC command line.

David

-- Sent from my Apple II



_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@...
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

Re: Obective-C undefined reference to ___objc_class_name_NSObject on Windows

by Nicola Pero-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>
> When I use:
>    gcc -o filename  filename.h  -I /c/gnustep/gnustep/system/library/
> headers  -L /c/gnustep/gnustep/system/library/libraries
> to compile the file I receive the following errors:
>
> undefined reference to   ___objc_class_name_NSObject
> undefined reference to  ___objc_exec_class
>
> 1- Could you kindly tell me how I can tackle this problem
> 2- How can I set any environmental variables so that I can avoid  
> typing
>        -I /c/gnustep/gnustep/system/library/headers  -L /c/gnustep/
> gnustep/system/library/libraries
> every time.

The easiest way to start is to use gnustep-make to compile and link  
your tool for you.  Check

http://www.gnustep.it/nicola/Tutorials/WritingMakefiles/index.html

for a tutorial on writing GNUmakefiles and using gnustep-make.

Thanks



_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@...
http://lists.gnu.org/mailman/listinfo/discuss-gnustep