Suppose I have functions I wrote that are declared in lib.h
and defined in lib.c
.
Now lib.c
makes use of functions of an external library declared in extlib.h
and resolved by linking to extlib.lib
.
Now suppose I want to use functions from lib.h
in a program prog.c
.
What is the simplest (easiest to maintain) way to do this in Visual Studio?
Currently I:
- build
lib.h
andlib.c
into a static librarylib.lib
, and then - add the folder containing
lib.h
and the folder containingextlib.h
to the include folders for the project forprog.c
(Project->Properties->C/C++->General->Additional Include Directories), and then - add the folder containing
lib.lib
and then folder containingextlib.lib
to the link folders for theprog.c
project (Project->Properties->Linker>General->Additional Library Directories).
For instance, can step 1 be skipped, since I have lib.c
?
Also, it is becoming difficult to remember all the external libraries that all my custom libraries depend on, and to then add their header (.h) and library (.lib) files to the project properties for programs that only call functions declared in my custom libraries.
Is there a way to "import a project into another project" so that the search paths for including and linking are automatically updated?
Is there some basic philosophy of managing C libraries and programs in Visual Studio?
Is there a good reference for advice on this subject?
Source: Visual Studio Questions