Embarrassingly basic question. sudo apt-get install libmemcached6
- where do the .h's and .o's or .so's live in a typical install on a Linux machine (Ubuntu)? And, how do I make sure g++ can pick them up?
They go to /usr/include and /usr/lib. If you use the -l option (for the libraries) it should find them from these standard places. If you include using <file.h>
it should also get it from the right place.
On Ubuntu (and other Debian variants) you can use the dpkg
command to find out. For example:
$ dpkg -L libxml2
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libxml2
/usr/share/doc/libxml2/AUTHORS
/usr/share/doc/libxml2/NEWS.gz
/usr/share/doc/libxml2/TODO.gz
/usr/share/doc/libxml2/copyright
/usr/share/doc/libxml2/README
/usr/share/doc/libxml2/changelog.Debian.gz
/usr/share/doc/libxml2/README.Debian
/usr/lib
/usr/lib/libxml2.so.2.7.8
/usr/lib/libxml2.so.2
As you can see, Debian packages don't typically include the .h
files; those are normally in corresponding -dev
packages. So you can find the header files here:
$ dpkg -L libxml2-dev
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libxml2-dev
/usr/share/doc/libxml2-dev/AUTHORS
/usr/share/doc/libxml2-dev/NEWS.gz
/usr/share/doc/libxml2-dev/TODO.gz
/usr/share/doc/libxml2-dev/copyright
/usr/share/doc/libxml2-dev/README
/usr/share/doc/libxml2-dev/changelog.Debian.gz
/usr/share/aclocal
/usr/share/aclocal/libxml2.m4
/usr/share/man
/usr/share/man/man3
/usr/share/man/man3/libxml.3.gz
/usr/share/man/man1
/usr/share/man/man1/xml2-config.1.gz
/usr/include
/usr/include/libxml2
/usr/include/libxml2/libxml
/usr/include/libxml2/libxml/HTMLtree.h
/usr/include/libxml2/libxml/tree.h
/usr/include/libxml2/libxml/xmlreader.h
/usr/include/libxml2/libxml/xmlschemastypes.h
...
As for gcc
, the manual explains how it searches for header files. Note that this is different and separate from using -l
to instruct the linker to link with a certain library.
On Linux and the majority of the Unix-based systems, the libraries may be found on either of these two locations:
The difference between these two locations is that the latter is used for the third party libraries. So if you have published your own library or have installed one from a third party repository (for instance ppa),those files should go to /usr/local/lib
.
The storage of header files can be understood using the above analogy. The folders are:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With