Link a program to a static library, linking itself to another library
<p>I'm trying to create a program (C++) that can read multiple file formats, on Windows (VS2015).
In order to do that, I created a solution with a Project for MyProgram (which is the main program), and a project for MyLibrary (which contains several parser for different file formats).
In MyProgram I create some parser objects based on the program input.</p>

<p>Everything was working well.</p>

<p>However, I tried to create a new file format parser (NiftiParser) that uses an external library, nifticlib, that I downloaded and compiled (as static library).</p>

<p>So I created my NiftiParser class, that implement some methods, and internally, it calls nifticlib.
I added the include dir and library dir in the project properties, and it compiled without errors.
I then got a Parser.lib that has been created.</p>

<p>However, when I tried to compile MyProgram, I got an error about some functions of nifticlib library not being resolved:</p>

<pre><code>1&gt;------ Build started: Project: Parser, Configuration: Debug x64 ------
1&gt;  nifti_parser.cc
1&gt;  Parser.vcxproj -&gt; C:\Users\Laurent\Documents\C++-build\Projects\Parser\Debug\Parser.lib
2&gt;------ Build started: Project: MyProgram, Configuration: Debug x64 ------
2&gt;Parser.lib(nifti_parser.obj) : error LNK2019: unresolved external symbol nifti_image_read referenced in function "public: __cdecl NiftiParser::NiftiParser(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;)" (??0NiftiParser@@QEAA@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
2&gt;C:\Users\Laurent\Documents\C++-build\Projects\Debug\MyProgram.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 1 succeeded, 1 failed, 3 up-to-date, 0 skipped ========== 
</code></pre>

<p>I'm not sure to understand why this is happening. I tried to add the path of include and the library dir of nifticlib to MyProgram project, but I still have some issue.</p>

<p>I'm not sure to understand what is the compilation/linking process for Visual Studio (I used to work on Linux).</p>

<p>It appears to me that the projects are only compiled if it's a static library, and the linking part only happen when I try to compile the program itself.
Am I right ?</p>

<p>Also, I'm not sure where nifticlib should link. Should it be to the Parser.lib (where I use the functions of the library) or directly to the program ?</p>

<p>Thank you.</p>

<p>PS: Also my noticed that my install directory of nifticlib only contains headers and .lib. Do I need to have the .cpp in there too, or does the functions are already contained in the .lib ?</p>

<p><strong>Edit:</strong> Ok, apparently building something as a static library doesn't link it to anything, so that's probably why I didn't get any issue compiling Parser.lib, because it doesn't link to nifticlib, but MyProgram needs it.
So should I only include the include dir of nitficlib in my Parser projects, and put the Parser.lib and nifticlib in my MyProgram project ?</p>