c compiler
i was wandering if there was any good c compilers that are free for linux?
|
mh, I think you should read more in the manuals for your system. Every Linux-distribution comes with gcc, most distributions install it by default.
Markus |
The standard compiler for Linux is GCC (it's free and open-source). It should be in pretty much every distro's package repository.
Quote:
|
Hello
@MTK358: thanks, maybe I was wrong. I helped archie101 in several threads here at LQ, he's using Arch and should not have any problems finding gcc (I don't indeed remember if it is installed by default ;) ). Markus |
Quote:
The package for all the development tools is called "base-devel". I'd recommend that the OP installs this instead of just GCC individually. |
I have it installed but i do not know how to open it up and write a program. i looked on archlinux.org and did not find out how to.
|
You will have to write a C-program with your favorite text-editor (i.e. vim ;) ) and then compile it
Code:
gcc -o myprogram myprogram.c Markus |
Write a simple c program. Then compile it using gcc -o <progname.o> <progname.c>.
You can also compile it straightaway with gcc <progname>. In this case the compiled binary name would be a.out. You can then execute the compiled binary using ./<progname.o> or ./<a.out>. Hope this helps. PS: AFAIK _all_ distros come with gcc - unless you specifically did not install it. You can check that with 'whereis gcc'. |
Quote:
|
i made a file put a simple c program in it saved it and ran gcc -o nameofmyprogram nameofmyprogram.c and it said gcc: error: hello.c: No such file or directory
gcc: fatal error: no input files compilation terminated |
if your program is hello.c, you should try
Code:
gcc -o hello hello.c |
and this is my program to anyone who knows c and might find an error with it:
#include <stdio.h> #include <conio.h> int main(void) { printf("hello"); getch(); } |
you should use code-tags for programtext in your posts.
If you delete the line #include <conio.h> and the getch() line it will compile and run. |
now it says hello.c:3:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
and how do i use code-tags? |
You may use the "Go Advanced" button at the bottom of your new post, then you end up in an advanced editor where there is this # character where you can click in order to wrap code-tags around the text.
You may as well use the "quote" button for any post where someone used code-tags and see how it works. Markus |
[code]some code here[/code]
will result in Code:
some code here |
my program is
Code:
#include <stdio.h> Code:
gcc: error: c.c: No such file or directory sorry for my knowing nothingness i am used to using a windows compiler. |
gcc can't find your file. Did you specify the right path to your source code?
|
Quote:
|
Well, this is speculation but it looks like there is a compiler but nothing to compile.
I would suggest going into the directory that has the c.c file and then executing gcc c.c. Else provide the full path name eg 'gcc /home/name/dir/c.c'. Hope this helps. |
Hi Archie101;
OK, your code, the content of "hello.c": Code:
#include <stdio.h> /* include the headers that have printf in them */ Code:
bash$ gcc -o hello hello.c Now if it throwing errors on compile time then the problem is likely that it cannot find the libraries it needs. Can you check that there is a file called "/usr/lib/libstdc++*" ? also a quick explanation of how you installed gcc and the Linux version/distribution you are using would help. |
It's not finding it because you're not in the directory that's the c file is in. cd to that dir then run gcc again.
|
Quote:
|
All times are GMT -5. The time now is 12:06 PM. |