organizing C libraries in Visual Studio

  Uncategorised

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:

  1. build lib.h and lib.c into a static library lib.lib, and then
  2. add the folder containing lib.h and the folder containing extlib.h to the include folders for the project for prog.c (Project->Properties->C/C++->General->Additional Include Directories), and then
  3. add the folder containing lib.lib and then folder containing extlib.lib to the link folders for the prog.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

LEAVE A COMMENT