Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with shared objects on a unix(aix) machine

Status
Not open for further replies.

Kruzer

Programmer
Jun 16, 2000
117
US
I created a simple file to understand the gcc compiler

#include "stdio.h"
void main()
{
printf("Hello World!");
}


$ gcc -o hello hello.c
gcc: hello: A file or directory in the path name does not exist.
hello.c: In function `main':
hello.c:3: warning: return type of `main' is not `int'

the hello.o file was created, now I ran this command---
$ gcc -c hello.c
hello.c: In function `main':
hello.c:3: warning: return type of `main' is not `int'

then finally the last command---
$ ld -lc -o hello hello.c
ld: 0711-715 ERROR: File hello.c cannot be processed.
The file must be an object file, an import file, or an archive.

What went wrong? I need some help...

Thanks!



Dano
dan_kryzer@hotmail.com
What's your major malfunction
 
As I can see from descripions of errors you have posted there, your code hsould look at least like this:
#include <stdio.h>
int main()
{
printf("Hello World!");
return 0;
}

Ion Filipski
1c.bmp
 
The brackets just ensure the preprocessor does not automatically search in the same directory as the source file when looking for the include file.

The return value for main just fixes the warning, not the error.

Any idea about the actual error? I can't figure it out. Unless the version of gcc is really old or something?
 
It was a very unconsidered idea: pass C source file to the linker...
 
void main is a Microsoft thing. In standard C++, main always returns an int.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top