Where do I put my .c files?
May seem trivial, but where do I put my "hello world" .c file in order for the compiler to find it?
|
nvm I figured it out. I put it in Documents and use the cd command...
Next question, I'm trying to compile a simple helloworld.c in a USB Linux Mint live and get the following error: stdio.h: No such file or directory What do I need to do next? |
you keep it in the folder FOR YOUR PROJECT
The folder needs to be writable by a normal user a lot of people use there HOME folder /home/YourUserName/ProjectName Quote:
WHY !!! the bleep would you move it to the "documents" folder ??????????????? |
> What do I need to do next?
Install package libc-devel (or similar name, eg libc6-devel, glibc-devel etc). |
Assuming gcc, you can compile any C source module by simply telling the compiler where the source files is:
Code:
gcc -c /the/path/to/your/file.c Your question, therefore, should be more about what makes sense to your project organization than about getting the C compiler to find the source file(s). Putting C source code in a directory clearly intended for documentation doesn't seem at all appropriate to me (unless you subscribe to the notion that the best documentation is that which is written in C). That your C compiler cannot find headers from the standard C library makes me think the compiler installation is either broken or incomplete. When gcc is built, it gets a default list of places to look for header files and these are fairly consistent across most builds. If the C header actually exists on your build host, you can always point the compiler to it, by using the -I (minus eye) option with the directory containing the C headers as an argument: Code:
gcc -c -I /the/path/to/header/files /the/path/to/your/file.c |
All times are GMT -5. The time now is 04:13 AM. |