- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Where to put C header (.h) and library (.sl,.a) fi...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2007 09:16 AM
тАО05-07-2007 09:16 AM
Where to put C header (.h) and library (.sl,.a) files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2007 09:33 AM
тАО05-07-2007 09:33 AM
Re: Where to put C header (.h) and library (.sl,.a) files
e.g. in foo.c
#include
#include
int main()
{
}
------------------------------------------
A common practice is to list all the needed header files in a local header file, local.h
#include
#include
------------------------------------------
and then simply include the one file, local.h, in all of your .c files,
e.g.
#include "local.h"
Now the slared and arcive libraries are not included until the link phase although they can be included in the normal cc command line with the source files.
e.g.
To compile foo1.c and foo2.c (which presumably have #include "local.h" lines in them) and link with /usr/lib/dummy1.sl and local library mylib.a and create an executable file, foo, something like this should suffice:
cc foo1.c foo2.c -ldummy1 mylib.a -o foo
You could also do this in two-steps like this:
cc -c foo1.c foo2.c
this will create foo1.o and foo2.o
You then link these:
cc foo1.o foo2.o -ldummy1 mylib.a -o foo
Of course, the preferred way to do this is to create a makefile. Look for a few examples of makefiles because any serious development should use them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2007 11:24 AM
тАО05-07-2007 11:24 AM
Re: Where to put C header (.h) and library (.sl,.a) files
third-party product normally stay with the
source. Files which need to be available for
other uses are often installed under
"/usr/local" (like "/usr/local/include" for
the header files, "/usr/local/lib" for the
object libraries, and so on), but the user
normally gets to choose this directory when
the product is installed.
In some places, "/opt" is popular instead of
"/usr/local".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2007 12:14 AM
тАО05-08-2007 12:14 AM
Re: Where to put C header (.h) and library (.sl,.a) files
thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2007 12:48 AM
тАО05-08-2007 12:48 AM
Re: Where to put C header (.h) and library (.sl,.a) files
> library and header files by default?
The linker doesn't search for header files.
Compilers search for header files.
"man aCC" or "man cc". Look for "-I".
"aCC +help" or "cc +help"?
"man ld". Look for "+b", LD_LIBRARY_PATH,
LPATH, RPATH, and SHLIB_PATH. "ld +help"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2007 01:02 AM
тАО05-08-2007 01:02 AM
Re: Where to put C header (.h) and library (.sl,.a) files
Instead of using LPATH, use -L path instead.
>automatically I might want to put header and library files there.
There is no default locations for your libs and headers. I don't think you should put user headers and libs in /usr/include/ and /usr/lib/. (Though it maybe reasonable to put shlibs in /usr/lib/.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2007 01:19 AM
тАО05-08-2007 01:19 AM
Re: Where to put C header (.h) and library (.sl,.a) files
of the *PATH variables, but looking for them
in the "man" output helps to find the better
methods and the explanations.
And I also would advise not adding one's own
files to "/usr/include" or "/usr/lib".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2007 07:34 AM
тАО05-08-2007 07:34 AM
Re: Where to put C header (.h) and library (.sl,.a) files
Choose AND DOCUMENT an environment variable for your application, e.g. MYAPP.
The executables are installed in ${MYAPP}/bin, the header files go in ${MYAPP}/include, and the libraries are installed in ${MYAPP}/lib. It's then an easy matter to have your makefiles change the -I path for include files and the set the path for libraries.