LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   c compiler (https://www.linuxquestions.org/questions/linux-newbie-8/c-compiler-878651/)

Wim Sturkenboom 05-05-2011 06:06 PM

[code]some code here[/code]
will result in
Code:

some code here
And we can not tell you what's wrong without seeing the new program ;)

archie101 05-05-2011 06:42 PM

my program is
Code:

#include <stdio.h>

int main(void) {

printf("hello");

}

and the error is
Code:

gcc: error: c.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.

do i have to take the .c off?

sorry for my knowing nothingness i am used to using a windows compiler.

TobiSGD 05-05-2011 06:52 PM

gcc can't find your file. Did you specify the right path to your source code?

MTK358 05-05-2011 07:17 PM

Quote:

Originally Posted by archie101 (Post 4347866)
[/CODE] and the error is
Code:

gcc: error: c.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.

do i have to take the .c off?

sorry for my knowing nothingness i am used to using a windows compiler.

Do you know the extremely basic concepts such as the current directory and relative paths (note that it's not really programming-related, but very important for doing anything in the command line)? If not, read this before continuing: http://linuxcommand.org/

honeybadger 05-07-2011 03:50 AM

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.

Nermal 05-07-2011 05:22 AM

Hi Archie101;

OK, your code, the content of "hello.c":
Code:

#include <stdio.h> /* include the headers that have printf in them */

int main(int argc, char *argv[]) /* correctly call the main function, yours would work but it will cause a warning when compiling */
{

printf("hello\n");  /* the \n puts a new line at the end */

return (0); /* as main has been defined as returning an int then we should really return something */

}

To compile make sure that hello.c is in the current directory:

Code:

bash$ gcc -o hello hello.c
This in the normal world would compile hello.c into an executable of hello

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.

kindofabuzz 05-07-2011 06:09 AM

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.

MTK358 05-07-2011 08:06 AM

Quote:

Originally Posted by Nermal (Post 4349096)
Can you check that there is a file called "/usr/lib/libstdc++*" ?

How is that relavent? The OP is using C.


All times are GMT -5. The time now is 12:40 PM.