fert Posted January 5, 2007 Share Posted January 5, 2007 I'm using Ubuntu linux and i'm trying to compile a C code file using gcc, but when i try to do it i get these errors[quote]os.c: In function ‘main’:os.c:3: warning: incompatible implicit declaration of built-in function ‘printf’/usr/bin/ld: crt1.o: No such file: No such file or directorycollect2: ld returned 1 exit status[/quote]as far as i can tell i've done everything right Quote Link to comment https://forums.phpfreaks.com/topic/32912-solved-compiling-c-code/ Share on other sites More sharing options...
the_oliver Posted January 6, 2007 Share Posted January 6, 2007 what did you run to start with? gcc blaaaa . . . . Odvious question does /usr/bin/ld exist? Quote Link to comment https://forums.phpfreaks.com/topic/32912-solved-compiling-c-code/#findComment-154409 Share on other sites More sharing options...
neylitalo Posted January 6, 2007 Share Posted January 6, 2007 You're going to have to rename your function printf to something else, or declare it so it's compatible with the C printf. That's my guess.And please let us have the command you're using to compile this code. Quote Link to comment https://forums.phpfreaks.com/topic/32912-solved-compiling-c-code/#findComment-154448 Share on other sites More sharing options...
fert Posted January 7, 2007 Author Share Posted January 7, 2007 command[code]gcc test.c -o test[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32912-solved-compiling-c-code/#findComment-154722 Share on other sites More sharing options...
trq Posted January 7, 2007 Share Posted January 7, 2007 Its your code, can we see it? Quote Link to comment https://forums.phpfreaks.com/topic/32912-solved-compiling-c-code/#findComment-154730 Share on other sites More sharing options...
fert Posted January 7, 2007 Author Share Posted January 7, 2007 [code]#include <stdio.h>int main(){ printf("Hello world!"); return 0;}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32912-solved-compiling-c-code/#findComment-154739 Share on other sites More sharing options...
trq Posted January 7, 2007 Share Posted January 7, 2007 Well, it doesn't really get much simpler does it? And funnilly enough, there is nothing wrong with your code.Compiles fine here on Gentoo with GCC 4.1.1, and on Debian using GCC 3.3.5.ld refers to Linux's standard linker which is part of binutils. Im not sure, but installing/ reinstalling binutils may help.PS; Im not that sure that Ubuntu is really much of a choice when it comes to building apps. Quote Link to comment https://forums.phpfreaks.com/topic/32912-solved-compiling-c-code/#findComment-154980 Share on other sites More sharing options...
btherl Posted January 9, 2007 Share Posted January 9, 2007 fert, can you try a few other common functions? Like puts() or fprintf()?Also, can you give the full output, from the command executed through to the error messages? The error messages in your first post don't match the command line in the later post. This makes me less confident that I am getting all the necessary information. Even seemingly unimportant things can make the difference. Quote Link to comment https://forums.phpfreaks.com/topic/32912-solved-compiling-c-code/#findComment-156390 Share on other sites More sharing options...
fert Posted January 9, 2007 Author Share Posted January 9, 2007 using puts() and fprintf() gives me the same errors and the errors I posted are all the errors generated Quote Link to comment https://forums.phpfreaks.com/topic/32912-solved-compiling-c-code/#findComment-156878 Share on other sites More sharing options...
trq Posted January 10, 2007 Share Posted January 10, 2007 Im pretty sure this is an Ubuntu issue. By default I don't think its setup to compile anything. though I would have thought it would be dragged in as a dep of gcc, you might try (re)installing the C libraries.[code]apt-get install glibc[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32912-solved-compiling-c-code/#findComment-156952 Share on other sites More sharing options...
fert Posted January 10, 2007 Author Share Posted January 10, 2007 [quote]E: Couldn't find package glibc[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/32912-solved-compiling-c-code/#findComment-156959 Share on other sites More sharing options...
trq Posted January 10, 2007 Share Posted January 10, 2007 Sorry, I dont use Ubuntu. Try...[code]apt-get install libc6-dev[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32912-solved-compiling-c-code/#findComment-156977 Share on other sites More sharing options...
fert Posted January 10, 2007 Author Share Posted January 10, 2007 thanks it worked Quote Link to comment https://forums.phpfreaks.com/topic/32912-solved-compiling-c-code/#findComment-157010 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.