Where linux header files

Where to get all the C header files located in /usr/include?

Okay getting to the problem. I was using Clion for coding my C projects and everything was fair and well but suddenly I wanted to make GUI apps with C so I google and found GTK to be the best choice. Went to their websites downloaded all the required files installed them also installed the dependencies files everything went well. The strange thing was that the gtk header files were not directly included in the /usr/include instead there was a file «gtk-3.o» which contained the gtk and gdk header files. So curse my noobness i always tried to include the ‘gtk-3.o’ instead of doing it like this #include and whenever i did this i got error. Then I did the stupidest thing one could ever think of, I copied ALL the files in the gtk-3.0 folder and pasted them directly into the /usr/include. Now when i include the required files like including gtk.h and after that including gdk.h and after that one other file (forgot the name) i get an error saying only gtk.h can be included directly. I googled this error and found a guy saying that The GTK guys did not want the gtk files to be directly included in /usr/include due to unmet dependencies of some of their header files. A guy commented below that he included the gtk files like through subdirectory and worked fine but now i cannot do this because I have copied the contents of gtk-3.0 in /usr/include. I have completely removed Clion and am thinking of deleting the contents of /usr/include and maybe reinstalling Clion will get the header files back. If this is not going to happen please direct me how to get the header files or a better alternative to this solution if there is. Help would be highly appreciated because i have spent my entire day trying to solve this problem, I am exhausted and want some expert help. Thanks

Note: I have not yet deleted the /usr/include/

Читайте также:  Linux connect to windows desktop

You install development packages. They should contain the header files (among other things). For example say you want to make a program that uses library X, then you need to install the packages containing the actual library (usually named something like libX or similar). That will give you the library only. To get the header files needed to build a program using the library you install the development packages (usually names something like X-dev or libX-dev ). Exact names depend on your Linux distribution.

/usr/include is part of your operating system. You should not have touched it (I’m not the downvoter though).

Источник

Where are header files for GCC located?

I want to manually add some header files like math.h and graphic.h for gcc but don’t know where to put them.

2 Answers 2

First take a look in /usr/include or /usr/local/include .

If you find nothing there, try :

`gcc -print-prog-name=cc1plus` -v 

This command asks gcc which C++ preprocessor it is using, and then asks that preprocessor where it looks for includes.

You will get a reliable answer for your specific setup.

Likewise, for the C preprocessor:

To look for header locations just use the locate command:

locate -b '\math.h' locate -b '\graphics.h' 
locate \*/math.h locate \*/graphics.h 

If you are more familiar with regular expression use

To make sure the database is up-to-date start:

That’s the way I’m searching my headers location. It’s much faster than using the find command.

Finding headers in not installed packages

For sake of completeness I post a one liner script which is in my mind very useful in finding apt packages involving a special header file.

#!/usr/bin/env bash apt-file search $1 | cut -f 1 -d ":" | sort -u 

Save this one liner for instance in your ~/.local/bin directory as e.g. aptfilesearch and make it executable with chmod +x aptfilesearch . Now you get a list of all packages including the header file you are searching for. Here a simple demonstration:

Источник

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.

Читайте также:  Resetting root password linux mint

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.

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.

Читайте также:  Прокси на базе linux

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.

Источник

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?

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