LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 05-01-2011, 11:58 PM   #1
Qudsia
LQ Newbie
 
Registered: Apr 2011
Posts: 6

Rep: Reputation: 0
How to handle own made include files in order to compile program in SUSE 11.3


Dear ALL!

I want to help in advance C programming in Linux suse 11.3

I have made two source files named as sum.c and average.c

I have included sum.c in average.c
both files are saved in Documents directory.

when i compile average.c i got following error

"average.c:4:22: fatal error: sum.c: No such file or directory
compilation terminated.
"

How to solve this issue?

I have tried to copy sum.c to usr\include folder but unable to copy

Waiting for immediate responses
 
Old 05-02-2011, 12:08 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
What is the exact command line you used to compile the code? Maybe you forgot the -I option, to specify a path/directory where includes are placed. If you want to add the current working directory, try something like
Code:
gcc -I. sum.c average.c
And please, don't demand for urgent responses... in a community of volunteers it's considered rude. Thanks.
 
1 members found this post helpful.
Old 05-02-2011, 12:08 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You might include the header file sum.h in average.c, but not the sum.c file itself. You compile both sum.c and average.c and link the respective object files to produce your executable.

You probably want to create a project directory that contains your c code and header files, so they are all together, instead of having files scattered about in Documents.
 
Old 05-02-2011, 12:11 AM   #4
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Did you click the links in this post? http://www.linuxquestions.org/questi...8/#post4341653
 
Old 05-02-2011, 12:28 AM   #5
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by Qudsia View Post
I have included sum.c in average.c
both files are saved in Documents directory.
when i compile average.c i got following error
"average.c:4:22: fatal error: sum.c: No such file or directory
compilation terminated.
"
I hope you have included sum.c as #include "sum.c", rather than #include <sum.c>.

Quote:
Originally Posted by colucix View Post
If you want to add the current working directory, try something like
Code:
gcc -I. sum.c average.c
-I option is not required for specifying the CWD, if all your files are in the CWD.
 
Old 05-02-2011, 12:32 AM   #6
Qudsia
LQ Newbie
 
Registered: Apr 2011
Posts: 6

Original Poster
Rep: Reputation: 0
@jschiwal yes i want one designated directory for this purpose. is thiss possible. if so then how I can make? please tell me command & other required settings
 
Old 05-02-2011, 12:34 AM   #7
Qudsia
LQ Newbie
 
Registered: Apr 2011
Posts: 6

Original Poster
Rep: Reputation: 0
@colucix i just requested as i m newb to linux...never mind please...

@Anisha Kaul yes i have included as #include "sum.c"
 
Old 05-02-2011, 12:35 AM   #8
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
How about presenting the code here in code tags: http://www.linuxquestions.org/questi...do=bbcode#code

and also the output of:

cd ~/Documents
ls

Last edited by Aquarius_Girl; 05-02-2011 at 01:24 AM. Reason: typo
 
Old 05-02-2011, 01:22 AM   #9
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by Anisha Kaul View Post
-I option is not required for specifying the CWD, if all your files are in the CWD.
I stand corrected!
 
  


Reply



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
[SOLVED] How to compile c++ program without changing #include line & header files not system Dstruct0 Programming 3 04-03-2011 08:20 PM
How to include files from other directories in a program? kirit.makwana Programming 2 05-20-2009 01:26 PM
Program to Handle NZB Files CarnageBox Linux - Software 2 11-02-2005 06:14 PM
A linux program that can handle split .rar files? Cinematography Linux - Software 3 05-03-2005 03:04 PM
Webmin cannot handle Samba config files that use the config or include directives allelopath Linux - Networking 3 01-18-2005 09:36 AM

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

All times are GMT -5. The time now is 10:50 PM.

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
Open Source Consulting | Domain Registration