LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-13-2014, 01:15 PM   #1
eatup
LQ Newbie
 
Registered: Apr 2014
Posts: 13

Rep: Reputation: Disabled
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?
 
Old 04-13-2014, 01:40 PM   #2
eatup
LQ Newbie
 
Registered: Apr 2014
Posts: 13

Original Poster
Rep: Reputation: Disabled
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?
 
Old 04-13-2014, 01:45 PM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,400

Rep: Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584
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:
stdio.h: No such file or directory
add that " #include "




WHY !!! the bleep would you move it to the "documents" folder ???????????????

Last edited by John VV; 04-13-2014 at 01:47 PM.
 
Old 04-14-2014, 12:23 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,609

Rep: Reputation: 1105Reputation: 1105Reputation: 1105Reputation: 1105Reputation: 1105Reputation: 1105Reputation: 1105Reputation: 1105Reputation: 1105
> What do I need to do next?

Install package libc-devel (or similar name, eg libc6-devel, glibc-devel etc).
 
Old 04-14-2014, 12:57 PM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,398
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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
This will compile the C source code, creating the resulting object code in the present working directory. Conventionally, one runs the compiler from the directory where the C source files are, and the object code is then left in that same directory.

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

Last edited by theNbomr; 04-14-2014 at 01:00 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
using header files: how do you ref and put fumulas in headers files cuthbertmd1 Programming 7 02-15-2011 07:25 AM
[SOLVED] Where to put my files????? t1nm@n Linux - Newbie 3 11-25-2010 02:42 AM
Where do you put your files? dbc001 Linux - General 7 02-23-2004 11:04 AM
Where to put files? codedv Linux - General 2 12-14-2003 12:26 PM
*.h files....where to put them for #include centr0 Programming 7 03-13-2003 07:26 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration