How to make new header files available universally?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
4
down vote

favorite












I just downloaded some new header files and have a folder of them that I wish to make available. First, I would like to make them available to any file wishing to use them. So, I would like to be able to include the new header file (call it newheader.h) where I want, just like math.h, for example. Where should I put it?



Second, I wish to make these files available to all users. I have root permissions. Is there a special directory I need to put it in? Thanks so much!










share|improve this question



























    up vote
    4
    down vote

    favorite












    I just downloaded some new header files and have a folder of them that I wish to make available. First, I would like to make them available to any file wishing to use them. So, I would like to be able to include the new header file (call it newheader.h) where I want, just like math.h, for example. Where should I put it?



    Second, I wish to make these files available to all users. I have root permissions. Is there a special directory I need to put it in? Thanks so much!










    share|improve this question

























      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite











      I just downloaded some new header files and have a folder of them that I wish to make available. First, I would like to make them available to any file wishing to use them. So, I would like to be able to include the new header file (call it newheader.h) where I want, just like math.h, for example. Where should I put it?



      Second, I wish to make these files available to all users. I have root permissions. Is there a special directory I need to put it in? Thanks so much!










      share|improve this question















      I just downloaded some new header files and have a folder of them that I wish to make available. First, I would like to make them available to any file wishing to use them. So, I would like to be able to include the new header file (call it newheader.h) where I want, just like math.h, for example. Where should I put it?



      Second, I wish to make these files available to all users. I have root permissions. Is there a special directory I need to put it in? Thanks so much!







      permissions files compiling






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 19 at 1:28









      muru

      130k19273466




      130k19273466










      asked Mar 18 at 23:36









      paulinho

      1213




      1213




















          4 Answers
          4






          active

          oldest

          votes

















          up vote
          9
          down vote













          Store them in /usr/local/include. From http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/usr.html, items in this directory are "... safe from being overwritten when the system software is updated", which is important since you do not want the headers files you have downloaded to get clobbered by system updates, which might happen if you put them in /usr/include.






          share|improve this answer




















          • Do I have to include the entire pathname? Is it possible to make it so that I just have to write #include "cuba.h" or #include <cuba.h> at the top of a C file?
            – paulinho
            Mar 19 at 1:04






          • 1




            @paulinho If you but cuba.h in in /usr/local/include, use #include <cuba.h>. If you put foo/cuba.h in /usr/local/include, use #include <foo/cuba.h>.
            – muru
            Mar 19 at 1:27











          • You can verify that /usr/local/include itself is in the default GCC include path using (for example) gcc -v -xc -E /dev/null 2>&1 | awk '/#include/,/End/'
            – steeldriver
            Mar 19 at 2:00

















          up vote
          6
          down vote













          On MY system, the /usr/local/include/ directory exists, and is empty. The Filsystem Hierarchy Standard says (FHS 3.0) the directory to use is /usr/local/include. Files should be world-readable (0444) and directories should be searchable (0555).






          share|improve this answer
















          • 1




            It's perfectly reasonable for the directory to exist and be empty - YOU simply haven't added files yet. The whole point of that directory is that its contents vary between systems.
            – MSalters
            Mar 19 at 14:47

















          up vote
          1
          down vote













          The question is, what do you want to achieve?



          Usually you have three scenarios:



          • development

          • local installation (in your $HOME)

          • global installation

          For the first 2, you should probably use the -I switch to give a path to the headers. The first would likely be -I../mylib/include, the second may be -I/home/user/local_libs/somelib/include.



          The third one is a global installation, which should place them in /usr/local/include, but managed by a tool like automake or cmake. When packaging, the maintainer should adapt the installpath and/or the include path to install the headers to /usr/include.



          When using automake you may have notices than the --prefix parameter defaults to /usr/local for a safe installation which does not interfere with system packages, while i.e. debian maintainers run ./configure --prefix=/usr in their package scripts. The include path is built from this prefix, so it follows the package installation.






          share|improve this answer




















          • The question implies global availability, so I think only your third option is relevant here.
            – Luke Salamone
            Mar 19 at 15:28










          • I am just not sure, if your own headers for something which is in development and not deployed as library to be used should be there or i.e. in /opt/our-dev-code/include or a copy per user. So I still have a bit the feeling if it is a X Y problem and the proper -I option is a better answer then deploying in /usr/local/include, so I elaborated a bit on the other options.
            – allo
            Mar 19 at 15:45











          • Its good to point out the development phase versus production libraries. There might also be a testing library post production.
            – WinEunuuchs2Unix
            Mar 19 at 21:50

















          up vote
          -2
          down vote













          Mimicking (but not duplicating) directory names



          Generally we don't code in a vacuum and what we write is based upon what others have written before us. Assuming your C programs and associated header (.h) files are built upon another software system then you should model your directory structure after theirs.



          Since I have no idea about your environment, lets take a common program and see what directory structure they used for their header files:



          $ `gcc -print-prog-name=cc1plus` -v
          ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include"
          #include "..." search starts here:
          #include <...> search starts here:
          /usr/include/c++/5
          /usr/include/x86_64-linux-gnu/c++/5
          /usr/include/c++/5/backward
          /usr/lib/gcc/x86_64-linux-gnu/5/include
          /usr/local/include
          /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
          /usr/include
          End of search list.


          I have no special C or header libraries installed on my system so everyone should be able to replicate this search "out of the box".



          When you drill down into: /usr/include/x86_64-linux-gnu/c++/5 you notice header files are included with C programs. So there is not hard and fast rule that headers have to be in their own directory.



          When it comes to programming you can put files anywhere you want and call them anything you want. Of course whatever you decide, it should make sense to you and your co-workers.



          Where header files are stored now



          Check where header files are stored now:



          $ locate *version.h*
          /lib/firmware/carl9170fw/include/shared/version.h
          /usr/include/linux/version.h
          /usr/include/linux/dvb/version.h
          /usr/include/x86_64-linux-gnu/gnu/libc-version.h
          /usr/lib/python3/dist-packages/lxml/includes/lxml-version.h
          /usr/lib/x86_64-linux-gnu/perl/5.22.1/CORE/git_version.h
          /usr/src/linux-headers-3.16.53-031653/include/uapi/linux/dvb/version.h
          /usr/src/linux-headers-3.16.53-031653/include/xen/interface/version.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/config/localversion.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/config/arch/want/compat/ipc/parse/version.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/config/isdn/diversion.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/generated/uapi/linux/version.h
          /usr/src/linux-headers-4.10.0-28/include/uapi/linux/dvb/version.h
          /usr/src/linux-headers-4.10.0-28/include/xen/interface/version.h
          /usr/src/linux-headers-4.10.0-28-generic/include/config/localversion.h
          /usr/src/linux-headers-4.10.0-28-generic/include/config/arch/want/compat/ipc/parse/version.h
          /usr/src/linux-headers-4.10.0-28-generic/include/config/isdn/diversion.h
          /usr/src/linux-headers-4.10.0-28-generic/include/generated/uapi/linux/version.h


          This is just the top of my listing. It goes on extensively.



          Based on existing header file locations, I would be inclined to create the directory:



          /usr/include/ourcompany/


          to store all the header (.h) files.



          Consider the default search path



          However as others have pointed out a popular location is:



          /usr/local/include/


          In this article written by Richard Stallman and others, they write:



          By default, gcc searches the following directories for header files:



          /usr/local/include/
          /usr/include/


          and the following directories for libraries:



          /usr/local/lib/
          /usr/lib/





          share|improve this answer


















          • 1




            /usr/include is not the place for manually-added header files, it should be reserved for managed files. You never know when a package you install might have a header file with the same name/directory structure.
            – JAB
            Mar 19 at 0:34










          • @JAB Yes every package under the sun will create a subdirectory there. Which is why I chose "ourcompany" as the subdirectory name to avoid duplicates. Your point is well taken and I may end up deleting this answer upon second-sober thought.
            – WinEunuuchs2Unix
            Mar 19 at 0:40










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1017131%2fhow-to-make-new-header-files-available-universally%23new-answer', 'question_page');

          );

          Post as a guest






























          4 Answers
          4






          active

          oldest

          votes








          4 Answers
          4






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          9
          down vote













          Store them in /usr/local/include. From http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/usr.html, items in this directory are "... safe from being overwritten when the system software is updated", which is important since you do not want the headers files you have downloaded to get clobbered by system updates, which might happen if you put them in /usr/include.






          share|improve this answer




















          • Do I have to include the entire pathname? Is it possible to make it so that I just have to write #include "cuba.h" or #include <cuba.h> at the top of a C file?
            – paulinho
            Mar 19 at 1:04






          • 1




            @paulinho If you but cuba.h in in /usr/local/include, use #include <cuba.h>. If you put foo/cuba.h in /usr/local/include, use #include <foo/cuba.h>.
            – muru
            Mar 19 at 1:27











          • You can verify that /usr/local/include itself is in the default GCC include path using (for example) gcc -v -xc -E /dev/null 2>&1 | awk '/#include/,/End/'
            – steeldriver
            Mar 19 at 2:00














          up vote
          9
          down vote













          Store them in /usr/local/include. From http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/usr.html, items in this directory are "... safe from being overwritten when the system software is updated", which is important since you do not want the headers files you have downloaded to get clobbered by system updates, which might happen if you put them in /usr/include.






          share|improve this answer




















          • Do I have to include the entire pathname? Is it possible to make it so that I just have to write #include "cuba.h" or #include <cuba.h> at the top of a C file?
            – paulinho
            Mar 19 at 1:04






          • 1




            @paulinho If you but cuba.h in in /usr/local/include, use #include <cuba.h>. If you put foo/cuba.h in /usr/local/include, use #include <foo/cuba.h>.
            – muru
            Mar 19 at 1:27











          • You can verify that /usr/local/include itself is in the default GCC include path using (for example) gcc -v -xc -E /dev/null 2>&1 | awk '/#include/,/End/'
            – steeldriver
            Mar 19 at 2:00












          up vote
          9
          down vote










          up vote
          9
          down vote









          Store them in /usr/local/include. From http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/usr.html, items in this directory are "... safe from being overwritten when the system software is updated", which is important since you do not want the headers files you have downloaded to get clobbered by system updates, which might happen if you put them in /usr/include.






          share|improve this answer












          Store them in /usr/local/include. From http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/usr.html, items in this directory are "... safe from being overwritten when the system software is updated", which is important since you do not want the headers files you have downloaded to get clobbered by system updates, which might happen if you put them in /usr/include.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 18 at 23:47









          dsstorefile1

          1,312111




          1,312111











          • Do I have to include the entire pathname? Is it possible to make it so that I just have to write #include "cuba.h" or #include <cuba.h> at the top of a C file?
            – paulinho
            Mar 19 at 1:04






          • 1




            @paulinho If you but cuba.h in in /usr/local/include, use #include <cuba.h>. If you put foo/cuba.h in /usr/local/include, use #include <foo/cuba.h>.
            – muru
            Mar 19 at 1:27











          • You can verify that /usr/local/include itself is in the default GCC include path using (for example) gcc -v -xc -E /dev/null 2>&1 | awk '/#include/,/End/'
            – steeldriver
            Mar 19 at 2:00
















          • Do I have to include the entire pathname? Is it possible to make it so that I just have to write #include "cuba.h" or #include <cuba.h> at the top of a C file?
            – paulinho
            Mar 19 at 1:04






          • 1




            @paulinho If you but cuba.h in in /usr/local/include, use #include <cuba.h>. If you put foo/cuba.h in /usr/local/include, use #include <foo/cuba.h>.
            – muru
            Mar 19 at 1:27











          • You can verify that /usr/local/include itself is in the default GCC include path using (for example) gcc -v -xc -E /dev/null 2>&1 | awk '/#include/,/End/'
            – steeldriver
            Mar 19 at 2:00















          Do I have to include the entire pathname? Is it possible to make it so that I just have to write #include "cuba.h" or #include <cuba.h> at the top of a C file?
          – paulinho
          Mar 19 at 1:04




          Do I have to include the entire pathname? Is it possible to make it so that I just have to write #include "cuba.h" or #include <cuba.h> at the top of a C file?
          – paulinho
          Mar 19 at 1:04




          1




          1




          @paulinho If you but cuba.h in in /usr/local/include, use #include <cuba.h>. If you put foo/cuba.h in /usr/local/include, use #include <foo/cuba.h>.
          – muru
          Mar 19 at 1:27





          @paulinho If you but cuba.h in in /usr/local/include, use #include <cuba.h>. If you put foo/cuba.h in /usr/local/include, use #include <foo/cuba.h>.
          – muru
          Mar 19 at 1:27













          You can verify that /usr/local/include itself is in the default GCC include path using (for example) gcc -v -xc -E /dev/null 2>&1 | awk '/#include/,/End/'
          – steeldriver
          Mar 19 at 2:00




          You can verify that /usr/local/include itself is in the default GCC include path using (for example) gcc -v -xc -E /dev/null 2>&1 | awk '/#include/,/End/'
          – steeldriver
          Mar 19 at 2:00












          up vote
          6
          down vote













          On MY system, the /usr/local/include/ directory exists, and is empty. The Filsystem Hierarchy Standard says (FHS 3.0) the directory to use is /usr/local/include. Files should be world-readable (0444) and directories should be searchable (0555).






          share|improve this answer
















          • 1




            It's perfectly reasonable for the directory to exist and be empty - YOU simply haven't added files yet. The whole point of that directory is that its contents vary between systems.
            – MSalters
            Mar 19 at 14:47














          up vote
          6
          down vote













          On MY system, the /usr/local/include/ directory exists, and is empty. The Filsystem Hierarchy Standard says (FHS 3.0) the directory to use is /usr/local/include. Files should be world-readable (0444) and directories should be searchable (0555).






          share|improve this answer
















          • 1




            It's perfectly reasonable for the directory to exist and be empty - YOU simply haven't added files yet. The whole point of that directory is that its contents vary between systems.
            – MSalters
            Mar 19 at 14:47












          up vote
          6
          down vote










          up vote
          6
          down vote









          On MY system, the /usr/local/include/ directory exists, and is empty. The Filsystem Hierarchy Standard says (FHS 3.0) the directory to use is /usr/local/include. Files should be world-readable (0444) and directories should be searchable (0555).






          share|improve this answer












          On MY system, the /usr/local/include/ directory exists, and is empty. The Filsystem Hierarchy Standard says (FHS 3.0) the directory to use is /usr/local/include. Files should be world-readable (0444) and directories should be searchable (0555).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 18 at 23:49









          waltinator

          20.7k74068




          20.7k74068







          • 1




            It's perfectly reasonable for the directory to exist and be empty - YOU simply haven't added files yet. The whole point of that directory is that its contents vary between systems.
            – MSalters
            Mar 19 at 14:47












          • 1




            It's perfectly reasonable for the directory to exist and be empty - YOU simply haven't added files yet. The whole point of that directory is that its contents vary between systems.
            – MSalters
            Mar 19 at 14:47







          1




          1




          It's perfectly reasonable for the directory to exist and be empty - YOU simply haven't added files yet. The whole point of that directory is that its contents vary between systems.
          – MSalters
          Mar 19 at 14:47




          It's perfectly reasonable for the directory to exist and be empty - YOU simply haven't added files yet. The whole point of that directory is that its contents vary between systems.
          – MSalters
          Mar 19 at 14:47










          up vote
          1
          down vote













          The question is, what do you want to achieve?



          Usually you have three scenarios:



          • development

          • local installation (in your $HOME)

          • global installation

          For the first 2, you should probably use the -I switch to give a path to the headers. The first would likely be -I../mylib/include, the second may be -I/home/user/local_libs/somelib/include.



          The third one is a global installation, which should place them in /usr/local/include, but managed by a tool like automake or cmake. When packaging, the maintainer should adapt the installpath and/or the include path to install the headers to /usr/include.



          When using automake you may have notices than the --prefix parameter defaults to /usr/local for a safe installation which does not interfere with system packages, while i.e. debian maintainers run ./configure --prefix=/usr in their package scripts. The include path is built from this prefix, so it follows the package installation.






          share|improve this answer




















          • The question implies global availability, so I think only your third option is relevant here.
            – Luke Salamone
            Mar 19 at 15:28










          • I am just not sure, if your own headers for something which is in development and not deployed as library to be used should be there or i.e. in /opt/our-dev-code/include or a copy per user. So I still have a bit the feeling if it is a X Y problem and the proper -I option is a better answer then deploying in /usr/local/include, so I elaborated a bit on the other options.
            – allo
            Mar 19 at 15:45











          • Its good to point out the development phase versus production libraries. There might also be a testing library post production.
            – WinEunuuchs2Unix
            Mar 19 at 21:50














          up vote
          1
          down vote













          The question is, what do you want to achieve?



          Usually you have three scenarios:



          • development

          • local installation (in your $HOME)

          • global installation

          For the first 2, you should probably use the -I switch to give a path to the headers. The first would likely be -I../mylib/include, the second may be -I/home/user/local_libs/somelib/include.



          The third one is a global installation, which should place them in /usr/local/include, but managed by a tool like automake or cmake. When packaging, the maintainer should adapt the installpath and/or the include path to install the headers to /usr/include.



          When using automake you may have notices than the --prefix parameter defaults to /usr/local for a safe installation which does not interfere with system packages, while i.e. debian maintainers run ./configure --prefix=/usr in their package scripts. The include path is built from this prefix, so it follows the package installation.






          share|improve this answer




















          • The question implies global availability, so I think only your third option is relevant here.
            – Luke Salamone
            Mar 19 at 15:28










          • I am just not sure, if your own headers for something which is in development and not deployed as library to be used should be there or i.e. in /opt/our-dev-code/include or a copy per user. So I still have a bit the feeling if it is a X Y problem and the proper -I option is a better answer then deploying in /usr/local/include, so I elaborated a bit on the other options.
            – allo
            Mar 19 at 15:45











          • Its good to point out the development phase versus production libraries. There might also be a testing library post production.
            – WinEunuuchs2Unix
            Mar 19 at 21:50












          up vote
          1
          down vote










          up vote
          1
          down vote









          The question is, what do you want to achieve?



          Usually you have three scenarios:



          • development

          • local installation (in your $HOME)

          • global installation

          For the first 2, you should probably use the -I switch to give a path to the headers. The first would likely be -I../mylib/include, the second may be -I/home/user/local_libs/somelib/include.



          The third one is a global installation, which should place them in /usr/local/include, but managed by a tool like automake or cmake. When packaging, the maintainer should adapt the installpath and/or the include path to install the headers to /usr/include.



          When using automake you may have notices than the --prefix parameter defaults to /usr/local for a safe installation which does not interfere with system packages, while i.e. debian maintainers run ./configure --prefix=/usr in their package scripts. The include path is built from this prefix, so it follows the package installation.






          share|improve this answer












          The question is, what do you want to achieve?



          Usually you have three scenarios:



          • development

          • local installation (in your $HOME)

          • global installation

          For the first 2, you should probably use the -I switch to give a path to the headers. The first would likely be -I../mylib/include, the second may be -I/home/user/local_libs/somelib/include.



          The third one is a global installation, which should place them in /usr/local/include, but managed by a tool like automake or cmake. When packaging, the maintainer should adapt the installpath and/or the include path to install the headers to /usr/include.



          When using automake you may have notices than the --prefix parameter defaults to /usr/local for a safe installation which does not interfere with system packages, while i.e. debian maintainers run ./configure --prefix=/usr in their package scripts. The include path is built from this prefix, so it follows the package installation.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 19 at 13:13









          allo

          4207




          4207











          • The question implies global availability, so I think only your third option is relevant here.
            – Luke Salamone
            Mar 19 at 15:28










          • I am just not sure, if your own headers for something which is in development and not deployed as library to be used should be there or i.e. in /opt/our-dev-code/include or a copy per user. So I still have a bit the feeling if it is a X Y problem and the proper -I option is a better answer then deploying in /usr/local/include, so I elaborated a bit on the other options.
            – allo
            Mar 19 at 15:45











          • Its good to point out the development phase versus production libraries. There might also be a testing library post production.
            – WinEunuuchs2Unix
            Mar 19 at 21:50
















          • The question implies global availability, so I think only your third option is relevant here.
            – Luke Salamone
            Mar 19 at 15:28










          • I am just not sure, if your own headers for something which is in development and not deployed as library to be used should be there or i.e. in /opt/our-dev-code/include or a copy per user. So I still have a bit the feeling if it is a X Y problem and the proper -I option is a better answer then deploying in /usr/local/include, so I elaborated a bit on the other options.
            – allo
            Mar 19 at 15:45











          • Its good to point out the development phase versus production libraries. There might also be a testing library post production.
            – WinEunuuchs2Unix
            Mar 19 at 21:50















          The question implies global availability, so I think only your third option is relevant here.
          – Luke Salamone
          Mar 19 at 15:28




          The question implies global availability, so I think only your third option is relevant here.
          – Luke Salamone
          Mar 19 at 15:28












          I am just not sure, if your own headers for something which is in development and not deployed as library to be used should be there or i.e. in /opt/our-dev-code/include or a copy per user. So I still have a bit the feeling if it is a X Y problem and the proper -I option is a better answer then deploying in /usr/local/include, so I elaborated a bit on the other options.
          – allo
          Mar 19 at 15:45





          I am just not sure, if your own headers for something which is in development and not deployed as library to be used should be there or i.e. in /opt/our-dev-code/include or a copy per user. So I still have a bit the feeling if it is a X Y problem and the proper -I option is a better answer then deploying in /usr/local/include, so I elaborated a bit on the other options.
          – allo
          Mar 19 at 15:45













          Its good to point out the development phase versus production libraries. There might also be a testing library post production.
          – WinEunuuchs2Unix
          Mar 19 at 21:50




          Its good to point out the development phase versus production libraries. There might also be a testing library post production.
          – WinEunuuchs2Unix
          Mar 19 at 21:50










          up vote
          -2
          down vote













          Mimicking (but not duplicating) directory names



          Generally we don't code in a vacuum and what we write is based upon what others have written before us. Assuming your C programs and associated header (.h) files are built upon another software system then you should model your directory structure after theirs.



          Since I have no idea about your environment, lets take a common program and see what directory structure they used for their header files:



          $ `gcc -print-prog-name=cc1plus` -v
          ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include"
          #include "..." search starts here:
          #include <...> search starts here:
          /usr/include/c++/5
          /usr/include/x86_64-linux-gnu/c++/5
          /usr/include/c++/5/backward
          /usr/lib/gcc/x86_64-linux-gnu/5/include
          /usr/local/include
          /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
          /usr/include
          End of search list.


          I have no special C or header libraries installed on my system so everyone should be able to replicate this search "out of the box".



          When you drill down into: /usr/include/x86_64-linux-gnu/c++/5 you notice header files are included with C programs. So there is not hard and fast rule that headers have to be in their own directory.



          When it comes to programming you can put files anywhere you want and call them anything you want. Of course whatever you decide, it should make sense to you and your co-workers.



          Where header files are stored now



          Check where header files are stored now:



          $ locate *version.h*
          /lib/firmware/carl9170fw/include/shared/version.h
          /usr/include/linux/version.h
          /usr/include/linux/dvb/version.h
          /usr/include/x86_64-linux-gnu/gnu/libc-version.h
          /usr/lib/python3/dist-packages/lxml/includes/lxml-version.h
          /usr/lib/x86_64-linux-gnu/perl/5.22.1/CORE/git_version.h
          /usr/src/linux-headers-3.16.53-031653/include/uapi/linux/dvb/version.h
          /usr/src/linux-headers-3.16.53-031653/include/xen/interface/version.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/config/localversion.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/config/arch/want/compat/ipc/parse/version.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/config/isdn/diversion.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/generated/uapi/linux/version.h
          /usr/src/linux-headers-4.10.0-28/include/uapi/linux/dvb/version.h
          /usr/src/linux-headers-4.10.0-28/include/xen/interface/version.h
          /usr/src/linux-headers-4.10.0-28-generic/include/config/localversion.h
          /usr/src/linux-headers-4.10.0-28-generic/include/config/arch/want/compat/ipc/parse/version.h
          /usr/src/linux-headers-4.10.0-28-generic/include/config/isdn/diversion.h
          /usr/src/linux-headers-4.10.0-28-generic/include/generated/uapi/linux/version.h


          This is just the top of my listing. It goes on extensively.



          Based on existing header file locations, I would be inclined to create the directory:



          /usr/include/ourcompany/


          to store all the header (.h) files.



          Consider the default search path



          However as others have pointed out a popular location is:



          /usr/local/include/


          In this article written by Richard Stallman and others, they write:



          By default, gcc searches the following directories for header files:



          /usr/local/include/
          /usr/include/


          and the following directories for libraries:



          /usr/local/lib/
          /usr/lib/





          share|improve this answer


















          • 1




            /usr/include is not the place for manually-added header files, it should be reserved for managed files. You never know when a package you install might have a header file with the same name/directory structure.
            – JAB
            Mar 19 at 0:34










          • @JAB Yes every package under the sun will create a subdirectory there. Which is why I chose "ourcompany" as the subdirectory name to avoid duplicates. Your point is well taken and I may end up deleting this answer upon second-sober thought.
            – WinEunuuchs2Unix
            Mar 19 at 0:40














          up vote
          -2
          down vote













          Mimicking (but not duplicating) directory names



          Generally we don't code in a vacuum and what we write is based upon what others have written before us. Assuming your C programs and associated header (.h) files are built upon another software system then you should model your directory structure after theirs.



          Since I have no idea about your environment, lets take a common program and see what directory structure they used for their header files:



          $ `gcc -print-prog-name=cc1plus` -v
          ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include"
          #include "..." search starts here:
          #include <...> search starts here:
          /usr/include/c++/5
          /usr/include/x86_64-linux-gnu/c++/5
          /usr/include/c++/5/backward
          /usr/lib/gcc/x86_64-linux-gnu/5/include
          /usr/local/include
          /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
          /usr/include
          End of search list.


          I have no special C or header libraries installed on my system so everyone should be able to replicate this search "out of the box".



          When you drill down into: /usr/include/x86_64-linux-gnu/c++/5 you notice header files are included with C programs. So there is not hard and fast rule that headers have to be in their own directory.



          When it comes to programming you can put files anywhere you want and call them anything you want. Of course whatever you decide, it should make sense to you and your co-workers.



          Where header files are stored now



          Check where header files are stored now:



          $ locate *version.h*
          /lib/firmware/carl9170fw/include/shared/version.h
          /usr/include/linux/version.h
          /usr/include/linux/dvb/version.h
          /usr/include/x86_64-linux-gnu/gnu/libc-version.h
          /usr/lib/python3/dist-packages/lxml/includes/lxml-version.h
          /usr/lib/x86_64-linux-gnu/perl/5.22.1/CORE/git_version.h
          /usr/src/linux-headers-3.16.53-031653/include/uapi/linux/dvb/version.h
          /usr/src/linux-headers-3.16.53-031653/include/xen/interface/version.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/config/localversion.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/config/arch/want/compat/ipc/parse/version.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/config/isdn/diversion.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/generated/uapi/linux/version.h
          /usr/src/linux-headers-4.10.0-28/include/uapi/linux/dvb/version.h
          /usr/src/linux-headers-4.10.0-28/include/xen/interface/version.h
          /usr/src/linux-headers-4.10.0-28-generic/include/config/localversion.h
          /usr/src/linux-headers-4.10.0-28-generic/include/config/arch/want/compat/ipc/parse/version.h
          /usr/src/linux-headers-4.10.0-28-generic/include/config/isdn/diversion.h
          /usr/src/linux-headers-4.10.0-28-generic/include/generated/uapi/linux/version.h


          This is just the top of my listing. It goes on extensively.



          Based on existing header file locations, I would be inclined to create the directory:



          /usr/include/ourcompany/


          to store all the header (.h) files.



          Consider the default search path



          However as others have pointed out a popular location is:



          /usr/local/include/


          In this article written by Richard Stallman and others, they write:



          By default, gcc searches the following directories for header files:



          /usr/local/include/
          /usr/include/


          and the following directories for libraries:



          /usr/local/lib/
          /usr/lib/





          share|improve this answer


















          • 1




            /usr/include is not the place for manually-added header files, it should be reserved for managed files. You never know when a package you install might have a header file with the same name/directory structure.
            – JAB
            Mar 19 at 0:34










          • @JAB Yes every package under the sun will create a subdirectory there. Which is why I chose "ourcompany" as the subdirectory name to avoid duplicates. Your point is well taken and I may end up deleting this answer upon second-sober thought.
            – WinEunuuchs2Unix
            Mar 19 at 0:40












          up vote
          -2
          down vote










          up vote
          -2
          down vote









          Mimicking (but not duplicating) directory names



          Generally we don't code in a vacuum and what we write is based upon what others have written before us. Assuming your C programs and associated header (.h) files are built upon another software system then you should model your directory structure after theirs.



          Since I have no idea about your environment, lets take a common program and see what directory structure they used for their header files:



          $ `gcc -print-prog-name=cc1plus` -v
          ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include"
          #include "..." search starts here:
          #include <...> search starts here:
          /usr/include/c++/5
          /usr/include/x86_64-linux-gnu/c++/5
          /usr/include/c++/5/backward
          /usr/lib/gcc/x86_64-linux-gnu/5/include
          /usr/local/include
          /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
          /usr/include
          End of search list.


          I have no special C or header libraries installed on my system so everyone should be able to replicate this search "out of the box".



          When you drill down into: /usr/include/x86_64-linux-gnu/c++/5 you notice header files are included with C programs. So there is not hard and fast rule that headers have to be in their own directory.



          When it comes to programming you can put files anywhere you want and call them anything you want. Of course whatever you decide, it should make sense to you and your co-workers.



          Where header files are stored now



          Check where header files are stored now:



          $ locate *version.h*
          /lib/firmware/carl9170fw/include/shared/version.h
          /usr/include/linux/version.h
          /usr/include/linux/dvb/version.h
          /usr/include/x86_64-linux-gnu/gnu/libc-version.h
          /usr/lib/python3/dist-packages/lxml/includes/lxml-version.h
          /usr/lib/x86_64-linux-gnu/perl/5.22.1/CORE/git_version.h
          /usr/src/linux-headers-3.16.53-031653/include/uapi/linux/dvb/version.h
          /usr/src/linux-headers-3.16.53-031653/include/xen/interface/version.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/config/localversion.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/config/arch/want/compat/ipc/parse/version.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/config/isdn/diversion.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/generated/uapi/linux/version.h
          /usr/src/linux-headers-4.10.0-28/include/uapi/linux/dvb/version.h
          /usr/src/linux-headers-4.10.0-28/include/xen/interface/version.h
          /usr/src/linux-headers-4.10.0-28-generic/include/config/localversion.h
          /usr/src/linux-headers-4.10.0-28-generic/include/config/arch/want/compat/ipc/parse/version.h
          /usr/src/linux-headers-4.10.0-28-generic/include/config/isdn/diversion.h
          /usr/src/linux-headers-4.10.0-28-generic/include/generated/uapi/linux/version.h


          This is just the top of my listing. It goes on extensively.



          Based on existing header file locations, I would be inclined to create the directory:



          /usr/include/ourcompany/


          to store all the header (.h) files.



          Consider the default search path



          However as others have pointed out a popular location is:



          /usr/local/include/


          In this article written by Richard Stallman and others, they write:



          By default, gcc searches the following directories for header files:



          /usr/local/include/
          /usr/include/


          and the following directories for libraries:



          /usr/local/lib/
          /usr/lib/





          share|improve this answer














          Mimicking (but not duplicating) directory names



          Generally we don't code in a vacuum and what we write is based upon what others have written before us. Assuming your C programs and associated header (.h) files are built upon another software system then you should model your directory structure after theirs.



          Since I have no idea about your environment, lets take a common program and see what directory structure they used for their header files:



          $ `gcc -print-prog-name=cc1plus` -v
          ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include"
          #include "..." search starts here:
          #include <...> search starts here:
          /usr/include/c++/5
          /usr/include/x86_64-linux-gnu/c++/5
          /usr/include/c++/5/backward
          /usr/lib/gcc/x86_64-linux-gnu/5/include
          /usr/local/include
          /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
          /usr/include
          End of search list.


          I have no special C or header libraries installed on my system so everyone should be able to replicate this search "out of the box".



          When you drill down into: /usr/include/x86_64-linux-gnu/c++/5 you notice header files are included with C programs. So there is not hard and fast rule that headers have to be in their own directory.



          When it comes to programming you can put files anywhere you want and call them anything you want. Of course whatever you decide, it should make sense to you and your co-workers.



          Where header files are stored now



          Check where header files are stored now:



          $ locate *version.h*
          /lib/firmware/carl9170fw/include/shared/version.h
          /usr/include/linux/version.h
          /usr/include/linux/dvb/version.h
          /usr/include/x86_64-linux-gnu/gnu/libc-version.h
          /usr/lib/python3/dist-packages/lxml/includes/lxml-version.h
          /usr/lib/x86_64-linux-gnu/perl/5.22.1/CORE/git_version.h
          /usr/src/linux-headers-3.16.53-031653/include/uapi/linux/dvb/version.h
          /usr/src/linux-headers-3.16.53-031653/include/xen/interface/version.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/config/localversion.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/config/arch/want/compat/ipc/parse/version.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/config/isdn/diversion.h
          /usr/src/linux-headers-3.16.53-031653-generic/include/generated/uapi/linux/version.h
          /usr/src/linux-headers-4.10.0-28/include/uapi/linux/dvb/version.h
          /usr/src/linux-headers-4.10.0-28/include/xen/interface/version.h
          /usr/src/linux-headers-4.10.0-28-generic/include/config/localversion.h
          /usr/src/linux-headers-4.10.0-28-generic/include/config/arch/want/compat/ipc/parse/version.h
          /usr/src/linux-headers-4.10.0-28-generic/include/config/isdn/diversion.h
          /usr/src/linux-headers-4.10.0-28-generic/include/generated/uapi/linux/version.h


          This is just the top of my listing. It goes on extensively.



          Based on existing header file locations, I would be inclined to create the directory:



          /usr/include/ourcompany/


          to store all the header (.h) files.



          Consider the default search path



          However as others have pointed out a popular location is:



          /usr/local/include/


          In this article written by Richard Stallman and others, they write:



          By default, gcc searches the following directories for header files:



          /usr/local/include/
          /usr/include/


          and the following directories for libraries:



          /usr/local/lib/
          /usr/lib/






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 20 at 2:58

























          answered Mar 18 at 23:45









          WinEunuuchs2Unix

          35.9k759134




          35.9k759134







          • 1




            /usr/include is not the place for manually-added header files, it should be reserved for managed files. You never know when a package you install might have a header file with the same name/directory structure.
            – JAB
            Mar 19 at 0:34










          • @JAB Yes every package under the sun will create a subdirectory there. Which is why I chose "ourcompany" as the subdirectory name to avoid duplicates. Your point is well taken and I may end up deleting this answer upon second-sober thought.
            – WinEunuuchs2Unix
            Mar 19 at 0:40












          • 1




            /usr/include is not the place for manually-added header files, it should be reserved for managed files. You never know when a package you install might have a header file with the same name/directory structure.
            – JAB
            Mar 19 at 0:34










          • @JAB Yes every package under the sun will create a subdirectory there. Which is why I chose "ourcompany" as the subdirectory name to avoid duplicates. Your point is well taken and I may end up deleting this answer upon second-sober thought.
            – WinEunuuchs2Unix
            Mar 19 at 0:40







          1




          1




          /usr/include is not the place for manually-added header files, it should be reserved for managed files. You never know when a package you install might have a header file with the same name/directory structure.
          – JAB
          Mar 19 at 0:34




          /usr/include is not the place for manually-added header files, it should be reserved for managed files. You never know when a package you install might have a header file with the same name/directory structure.
          – JAB
          Mar 19 at 0:34












          @JAB Yes every package under the sun will create a subdirectory there. Which is why I chose "ourcompany" as the subdirectory name to avoid duplicates. Your point is well taken and I may end up deleting this answer upon second-sober thought.
          – WinEunuuchs2Unix
          Mar 19 at 0:40




          @JAB Yes every package under the sun will create a subdirectory there. Which is why I chose "ourcompany" as the subdirectory name to avoid duplicates. Your point is well taken and I may end up deleting this answer upon second-sober thought.
          – WinEunuuchs2Unix
          Mar 19 at 0:40

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1017131%2fhow-to-make-new-header-files-available-universally%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

          Trouble downloading packages list due to a “Hash sum mismatch” error

          How do I move numbers in filenames, in a batch renaming operation?