Header file location in linux

Where do library C header files go on Linux

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?

g++ can pick them up if they are properly installed because they should be in the PATH. Otherwise, you could compile the library yourself statically and place the output somewhere in a folder of your choice.

3 Answers 3

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 it should also get it from the right place.

Found the so in /usr/lib. No header in /usr/include. Is this likely something not included in an apt-get install and I’ll just need to acquire the source myself?

mostprobably your library has a -dev version that installs the header and this one just installs the runtime requirements (aka the .so) try doing apt-cache search libmemcached6 and see if there’s a libmemcached6-dev package for development files. that will add the header file

Linking with -lmemcached seems like it compiles but fails to link the C functions in, not sure how to tell where to find them (or where they are.)

@djechlin, try running objdump -T /usr/lib/libmemcached.so.6 and checking to make sure the names match what you have in your code.

Читайте также:  Linux unzip files to folder

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.

Источник

How can I find the header files of the C programming language in Linux?

When I write C programs in Linux, and then compile them using gcc, I am always curious about where those header files are. For example, where stdio.h is. More generally, where is stdbool.h ? What I want to know is not only where it is, but also how to get those places, for example, using shell command or using the C programming language.

10 Answers 10

gcc -H . will print the full path of every include file as a side-effect of regular compilation. Use -fsyntax-only in addition to get it not to create any output (it will still tell you if your program has errors). Example (Linux, gcc-4.7):

$ cat > test.c #include #include ^D $ gcc -H -fsyntax-only test.c . /usr/lib/gcc/x86_64-linux-gnu/4.7/include/stdbool.h . /usr/include/stdio.h .. /usr/include/features.h . /usr/include/x86_64-linux-gnu/bits/predefs.h . /usr/include/x86_64-linux-gnu/sys/cdefs.h . /usr/include/x86_64-linux-gnu/bits/wordsize.h . /usr/include/x86_64-linux-gnu/gnu/stubs.h . /usr/include/x86_64-linux-gnu/bits/wordsize.h . /usr/include/x86_64-linux-gnu/gnu/stubs-64.h .. /usr/lib/gcc/x86_64-linux-gnu/4.7/include/stddef.h .. /usr/include/x86_64-linux-gnu/bits/types.h . /usr/include/x86_64-linux-gnu/bits/wordsize.h . /usr/include/x86_64-linux-gnu/bits/typesizes.h .. /usr/include/libio.h . /usr/include/_G_config.h . /usr/lib/gcc/x86_64-linux-gnu/4.7/include/stddef.h . /usr/include/wchar.h . /usr/lib/gcc/x86_64-linux-gnu/4.7/include/stdarg.h .. /usr/include/x86_64-linux-gnu/bits/stdio_lim.h .. /usr/include/x86_64-linux-gnu/bits/sys_errlist.h 

The dots at the beginning of each line count how deeply nested the #include is.

Читайте также:  Самых популярных дистрибутивов linux

Источник

what is default path for header file included in c program?

Try running gcc -v -E — . When I do, part of the output is as follows:

#include search starts here: /usr/lib/gcc/i686-linux-gnu/4.6.1/include /usr/local/include /usr/lib/gcc/i686-linux-gnu/4.6.1/include-fixed /usr/include/i386-linux-gnu /usr/include 

It’s not an answer to the gstreamer question, but I hope this still helps!

/usr/local/include /usr/include 

If you use another path, you can add in your compile command with -I flag. In your case, assuming you have a /usr/local/gst/include directory, you may add -I/usr/local/gst/include and use #include

The path searched depends on the implementation (and current configuration). The correct way to find the include path is to use pkg-config

pkg-config --cflags gstreamer 

it shows this error —> Package gstreamer was not found in the pkg-config search path. Perhaps you should add the directory containing `gstreamer.pc’ to the PKG_CONFIG_PATH environment variable No package ‘gstreamer’ found

@Mr.32 Perhaps you need to specify a version. Or maybe gstreamer isn’t correctly installed. Look in /usr/lib/pkgconfig and /usr/share/pkgconfig .

@Mr.32: As cnicutar has pointed out you need to use pkg-config. For gstreamer it is not just gstreamer, it is gstreamer-. As you have installed gstreamer in /usr/local check the output of ls /usr/local/lib/pkgconfig/gstreamer* , you should find a bunch of .pc files. Now try this: export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig then pkg-config —cflags gstreamer-0.10 assuming you found gstreamer-0.10.pc in ls command. Does that show any output?

Источник

Where are package library and header files installed?

After downloading and installing a package in Ubuntu, how can I check where the library and header files were written to? I believe that this has something to do with the package’s .pc file, but I do not know how to find that file either. For example, I have downloaded the PCL (Point Cloud Library) package, and then in a sample CMakeLists.txt file, I have been given the following:

include_directories($) link_directories($) add_definitions($) 

Where are these environment variables defined, and how can I see them? If I compiled the libraries from source rather than through a package, will this be any different? Will a .pc file be created automatically?

Читайте также:  Dallas lock astra linux special edition

That just returns an empty line. However, compiling my project as above works fine so it must be using the PCL libraries. Is it searching anywhere else?

If you installed a debian package you can see the content via dpkg -L . If you install from source, it depends heavily on the source and you need to familiarise yourself with the build system it uses.

I had similar confusions. You can check to what values $ resolves to by using message command in your CMakeLists.txt i.e. add this line: message(«$) or message(«PCL_INCLUDE_DIRS = » $) . It will display the result when you run cmake .. Do the same for other macros/variables i.e. $ and $

2 Answers 2

If you install the package containing the libpcl development files

sudo apt-get install libpcl-dev 

You can list the installed files

an see the location of all headers.

. /usr/include/pcl-1.7/pcl/filters/fast_bilateral.h /usr/include/pcl-1.7/pcl/filters/voxel_grid_covariance.h /usr/include/pcl-1.7/pcl/filters/voxel_grid_occlusion_estimation.h /usr/include/pcl-1.7/pcl/filters/median_filter.h /usr/include/pcl-1.7/pcl/filters/crop_box.h /usr/include/pcl-1.7/pcl/filters/voxel_grid_label.h /usr/include/pcl-1.7/pcl/filters/covariance_sampling.h /usr/include/pcl-1.7/pcl/filters/random_sample.h /usr/include/pcl-1.7/pcl/filters/normal_refinement.h /usr/include/pcl-1.7/pcl/filters/project_inliers.h /usr/include/pcl-1.7/pcl/filters/fast_bilateral_omp.h /usr/include/pcl-1.7/pcl/filters/clipper3D.h /usr/include/pcl-1.7/pcl/filters/convolution.h /usr/include/pcl-1.7/pcl/filters/passthrough.h /usr/include/pcl-1.7/pcl/filters/conditional_removal.h /usr/include/pcl-1.7/pcl/filters/impl /usr/include/pcl-1.7/pcl/filters/impl/frustum_culling.hpp /usr/include/pcl-1.7/pcl/filters/impl/conditional_removal.hpp /usr/include/pcl-1.7/pcl/filters/impl/convolution_3d.hpp /usr/include/pcl-1.7/pcl/filters/impl/voxel_grid_covariance.hpp /usr/include/pcl-1.7/pcl/filters/impl/fast_bilateral_omp.hpp /usr/include/pcl-1.7/pcl/filters/impl/project_inliers.hpp /usr/include/pcl-1.7/pcl/filters/impl/morphological_filter.hpp /usr/include/pcl-1.7/pcl/filters/impl/crop_box.hpp /usr/include/pcl-1.7/pcl/filters/impl/covariance_sampling.hpp /usr/include/pcl-1.7/pcl/filters/impl/local_maximum.hpp /usr/include/pcl-1.7/pcl/filters/impl/plane_clipper3D.hpp /usr/include/pcl-1.7/pcl/filters/impl/bilateral.hpp /usr/include/pcl-1.7/pcl/filters/impl/voxel_grid_occlusion_estimation.hpp . 

Источник

Оцените статью
Adblock
detector