Where should I place .h and .lib files so that I can just write #include <mylib.h> (or "mylib.h") and the compiler and linker will find them for all my c++ projects?
Where should I place .h and .lib files so that I can just write
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no one single place on the computer where you can put .h / .lib files and expect them to be included in all C++ projects. The directories which are searched for .h / .lib files is a completely configurable item. Hence there is no one true include directory.
A potential option is changing the global MSBuild files for the machine. C++ projects inherit a portion of their settings from this file and it could be used to force down a set of includes to the vast majority of projects. However it’s a bit of a sledge hammer option and won’t be 100% effective. Any individual project can still override these defaults (or simply not use MSBuild).
It is possible though to have a unified .h / .lib directory on your machine and then manually point every C++ project at that directory
/I c:\path\to\unified\include