LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 07-14-2005, 02:10 AM   #1
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Rep: Reputation: 45
compile libraries within


Hi i have the two basic file

main.c
and constants.h

How i can compile these two files with gcc the constants.h includes some functions and declared constants... any ideas?
Thx
 
Old 07-14-2005, 03:11 AM   #2
Hosiah
Member
 
Registered: Sep 2004
Location: Des Moines, Iowa
Distribution: Slackware, Mandriva, Debian derivatives, +BSD/ Solaris/ Minix/ plan9/ GNU/HURD...
Posts: 185

Rep: Reputation: 31
must be new!

If "constants.h" is in your default include path (i.e. in a folder with a bunch of other .h files) then you put

#include <constants.h>

at the top of your C program. The preprocessing fairy takes it from there.
If, however, "constants.h" is your own home-brewed creation and it's sitting in the same directory right next to main.c, you would change that first line of your C program to:

#include "constants.h"

which tells the preprocessor to look in the same directory as the C source file.

Another trick is to have the include statement point to the full path relative to the default include search path:

#include <subdirectory/my_includes/constants.h>

for those one-shot deals where it's not worth messing with changing your settings.

PS these tricks also work with including plain.C files.
 
  


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
ntop compile/post-compile problem? tjb Linux - Software 3 12-28-2004 04:22 PM
Missing libraries to compile and to start mozilla (very basic libs) Necronomicom Slackware 3 07-30-2004 03:50 AM
What compilers/ libraries ect do I need installed so that I can compile most software jimdaworm Linux - Newbie 2 09-12-2003 03:45 PM
Can't get MOTIF to compile with my libraries... jwblair Programming 2 04-28-2002 06:35 PM
libraries to use fatpig Programming 6 02-08-2002 06:50 PM

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

All times are GMT -5. The time now is 07: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
Open Source Consulting | Domain Registration