Feedback

type to search

Compiling erroes when trying to compile Objective-C source file using gcc

Asked by [ Editor ] , Edited by Fernando C. Estrada [ Admin ]

hello.
I’ve been trying to compile an objective-c file source file (*.m) but I always get the following error:
gcc: error trying to exec ‘cc1obj’: execvp: No such file or directory
(syntax: gcc file.m/gcc -x objective-c file.m, everything google came up with ).

I’d be happy if you can help me figure it out.

Thanks.

NN comments
oz123
-

Niv, It’s the third time you ask an abstract question here. My suggestion to you is before you ask a question. Try making it concrete. Then, when your question is specific google it. Maybe you find that someone already had that problem.

In this case, you could have asked – I am trying to compile software X which is written in objective C.

From that you can see you need an objective-c compiler installed. Also, you see that from the answer you got, no one else can learn because we don’t know what is your problem …

skuend
-
Google didn’t seem to solve my question ( at least not that i saw it ) believe me, if i would’ve asked everything i have problems with without googleing before the servers would’ve been down ;–) I’m not trying to compile a software… just some sample source code. anyways, I’ve added the error output and the files im trying to compile ( although it’s extremely unreadable, plus i can’t use all the graphic ( Bold, italian, ident, whatever ) features of this system for some reason.

or Cancel

2 answers

-1

skuend [ Editor ]

installed now, still have the same problem.

Edit: Weirdest thing in the world- it didn't install it. when i ran aptitude again it gave me this crazy solution to resolve conflicts ( including removing build-essential gcc, g++, gcc 4.4, g++ 4.4, and alot of libs ).

Im not sure how smart it is to accept his solution :)

Edit #2: After upgrading system there was no need for solution. compiler is working now, although i have some linking issues: it complains about alot of unidentified refrences ( both of math.h and objc/Object.h ).

Command i ran: gcc try.o (after running gcc -c try.m successfully )

output:

/tmp/ccLnDo1L.o: In function `_i_Point__magnitude':
try.m:(.text+0x91): undefined reference to `sqrt'
/tmp/ccLnDo1L.o: In function `main':
try.m:(.text+0xad): undefined reference to `objc_get_class'
try.m:(.text+0xc0): undefined reference to `objc_msg_lookup'
try.m:(.text+0xe7): undefined reference to `objc_msg_lookup'
try.m:(.text+0x114): undefined reference to `objc_msg_lookup'
try.m:(.text+0x141): undefined reference to `objc_msg_lookup'
try.m:(.text+0x168): undefined reference to `objc_msg_lookup'
/tmp/ccLnDo1L.o:try.m:(.text+0x18f): more undefined references to `objc_msg_lookup' follow
/tmp/ccLnDo1L.o: In function `__objc_gnu_init':
try.m:(.text+0x1dd): undefined reference to `__objc_exec_class'
/tmp/ccLnDo1L.o:(.data+0x190): undefined reference to `__objc_class_name_Object'
collect2: ld returned 1 exit status


files:

try.m:

#import "try.h"
#import <math.h>
#import <stdio.h>
Point

- (id) x: (double) x_value
{
   x = x_value;
   return self;
}

- (double) x
{
   return x;
}

- (id) y: (double) y_value
{
   y = y_value;
   return self;
}

- (double) y
{
   return y;
}

- (double) magnitude
{
   return sqrt(x*x+y*y);
}


int main(void)
{
   Point *point = [Point new];
   [point x:10.0];
   [point y:12.0];
   printf("The distance from the point (%g, %g) to the origin is %g.\n", [point x], [point y], [point magnitude]);

   return 0;
}


try.h:

#import <objc/Object.h>
Point : Object
{
   double x;
   double y;
}

- (id) x: (double) x_value;
- (double) x;
- (id) y: (double) y_value;
- (double) y;
- (double) magnitude;

NN comments
rhonda
-

Please don’t leave comments as new answers – this works a little bit against the system and makes following what’s going on a bit weird.

asjo
-

Shouldn’t you have linked the libraries you are using? Say, -lm, for math?

or Cancel

Your answer

You need to join Debian to complete this action, click here to do so.