cc-compiler problem

shean

Registered
This is probably something stupid, but I'm not very experienced whit this unix stuff. I have installed the "Developer tools" CD that came with Os X. When I'm trying to compile my simple "hello world" program (written in C) in terminal using command

% cc helloworld.c

it says

/usr/bin/ld: /usr/lib/libSystem.dylib load command 6 unknown cmd field

and that's it. What am I doing wrong? Thanks in advance!

-shean
 
Try this, exactly as I say it:

Put your HelloWorld.c file onto your desktop, and title it "HelloWorld.c" exactly (without the quotations)! Then launch terminal. Once terminal comes up type: ".." (again without the quotations), then type: "cd desktop" (without quotations). Finally type: "cc HelloWorld.c" (without quotations). That should do it for you. :)
 
I'm not sure why'd you follow the white rabbit down the rabbit whole on this one. As typed, no matter how he capitalized or spaced his source file, he won't get that error (at least it doesn't sound related and I can't reproduce it).

I'd be more interested to see the actual source code, there might be an issue in there.

If Trip's comments helped, then ignore me, but I don't see where they're going.

Matt Fahrenbacher
 
The source code looks like that:

#include<stdio.h>

int main()
{
printf("Hello world!\n");
}

I can compile this and many other programs without any problems at work (Digital UNIX V4.0F). I doubt such a simple code could be somehow machine-dependent, so I guess there is something wrong with my system. Any ideas?

-shean
 
The source code got somehow messed up in my first posting, after #include there should of course be <stdio.h>
 
Everything I write in angle brackets seems to be invisible (to me at least). Anyway, after this #include statement there should be stdio.h in angle brackets.
 
Originally posted by shean
This is probably something stupid, but I'm not very experienced whit this unix stuff. I have installed the "Developer tools" CD that came with Os X. When I'm trying to compile my simple "hello world" program (written in C) in terminal using command

% cc helloworld.c

it says

/usr/bin/ld: /usr/lib/libSystem.dylib load command 6 unknown cmd field

and that's it. What am I doing wrong? Thanks in advance!

-shean

I think you should update to the developers tools of december/february 2001/2002. It would seem that shared library format has changed somewhat, and the linker (ld) available on your developer tools cannot understand it.
 
IT'S NOT THAT HARD PEOPLE, shean make this your code:

main()
{
printf("Hello World!\n");
}

A few problems in the old code was: 1) main shouldn't be called an int. You put int Main() and that wouldn't compile correctly. 2) You don't need to include the "#include" statement in your C file if you are compiling through terminal.

If that doesn't help then you're not explaning your problem correctly.

Sheesh!
 
Trip, it should be clear from shean s error that he s not having a problem finding the right directory, like you say in your first post. if he tried to compile his code from the wrong directory, the shell would give him an error.

He is also not having a compiler error, like you claim in your second. if his code had errors in it, the compiler would give him an error.

actually i don t think there are errors. it is fine for main to be of type int.

he is getting an error from ld so he is having a problem with his linker, ld. a linker is what links together binary shared libraries with compiled code.

i m gonna go with ladavacm on this, cause i don t know how to solve his problem.

good to see you are back. no hard feelings, OK?

shean: a good way to post code so that the message board doesn t eat your brackets is to enclose it in code tags, encased by square brackets, instead of quote tags. it works better for preserving code formatting. but for some reason it is still eating my include statement. so is this what your code looks like (delete the spaces in the include statement)?

Code:
#include < stdio.h >

int main()
{
printf("Hello world!\n");
}
 
Hey, it's good to have somebody who knows what they're talking about on these forums! Thanks lethe! :)
 
Back
Top