How to handle own made include files in order to compile program in SUSE 11.3
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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
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.
@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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.