Go Back   openSUSE Forums > Archives > SF Archives > ARCHIVES - Programming & Scripting
Forums FAQ Members List Search Today's Posts Mark Forums Read


ARCHIVES - Programming & Scripting A place to discuss website design, programming, shell scripts, etc

 
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 15-Dec-2007, 13:21
eeijlar
Guest
 
Posts: n/a
Default

Hi,

I am trying to compile the old classic Hello World C program and I am getting this error:

/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/libc.a when searching for -lc
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/bin/ld: cannot find -lc
collect2: ld returned 1 exit status

Here's the source:
Code:
#include <stdio.h>
#include <stdlib.h>

void main() {

printf ("\nhello world\n");

}
Any thoughts?
  #2 (permalink)  
Old 15-Dec-2007, 14:57
Phoenix76
Guest
 
Posts: n/a
Default

First of all, make sure your source file has a .c extension. Next, compile your code with this command: "gcc -o sourcefile sourcefile.c". The -o sourcefile part makes an executable file called sourcefile. Next, type "./sourcefile" to execute your program. It ran on my machine, so your code is correct. I think you compiled it incorrectly. You may get a compiler warning such as "warning: return type of ‘main’ is not ‘int’", but this can be ignored.
  #3 (permalink)  
Old 17-Dec-2007, 17:43
eeijlar
Guest
 
Posts: n/a
Default

Hi,

Thanks for your reply. I tried it with the extra parameters but I still get the errors. It looks like there is a library missing or something...

Code:
jlawlor@apollo:~/Documents/scripts> gcc -o hello hello.c
hello.c: In function ‘main’:
hello.c:4: warning: return type of ‘main’ is not ‘int’
hello.c:8:2: warning: no newline at end of file
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/libc.a when searching for -lc
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/bin/ld: cannot find -lc
collect2: ld returned 1 exit status
jlawlor@apollo:~/Documents/scripts>
  #4 (permalink)  
Old 17-Dec-2007, 20:45
DareDefyMe
Guest
 
Posts: n/a
Default

Check that you have glibc packages installed.
  #5 (permalink)  
Old 26-Dec-2007, 17:35
Eng:Muhammed _Afefy
Guest
 
Posts: n/a
Default

hi
the problem is not about your code it's correnct
but
the compiler told you that you don't have the needed libs
which enable your programme to be executable
when you use printf by include it's implementation
there still some thing it's the binary lib which open
stream between your programme and the screen and it's
called glibc libs
so check that you have these libs in ur system
in any lib directory which execution permission for any user
such /usr/lib/
you can search using some thing like this

find / |grep glibc

try it
  #6 (permalink)  
Old 26-Dec-2007, 19:59
0xDEADBEEF
Guest
 
Posts: n/a
Default

C likes for the main function to return an integer between 0 and 255 to the operating system. C++ popularized "void main()".

So change "void main" to "int main".

At the end of the main function, add a line,
return 0;

The warning "hello.c:8:2: warning: no newline at end of file" seems strange. Maybe in your code, add one more blank line after the closing "}".

Code:
#include <stdio.h>
#include <stdlib.h>

int main() {

********printf ("\nhello world\n");
********return 0;
}
  #7 (permalink)  
Old 04-Feb-2008, 12:22
atindra
Guest
 
Posts: n/a
Default

Quote:
Hi,

I am trying to compile the old classic Hello World C program and I am getting this error:

/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/libc.a when searching for -lc
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-suse-linux/bin/ld: cannot find -lc
collect2: ld returned 1 exit status

Here's the source:
Code:
#include <stdio.h>
#include <stdlib.h>

void main() {

printf ("\nhello world\n");

}
Any thoughts?
[/b]
Try it like this.
Change the source to


#include<stdio.h>
main()
{
printf ("\nhello world\n");
}

Give it a name say hello.c
compile it with

cc hello.c
I think it will work.
  #8 (permalink)  
Old 04-Feb-2008, 12:51
Hieronymous
Guest
 
Posts: n/a
Default

No, it looks like a problem between the 32 & 64 bit versions of libc installed. Are you running opensuse 64 bit? Did you install the correct libraries for your development? The error has nothing to do with your code. The libc it is looking for is missing. Maybe you are running the 32bit version of gcc?
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2