How do I use a static library (in my case assimp) without the source files
<p>I have a libassimp.a file and the header files. How can I use the library?</p>

<p>I'm adding the header files to my project with <code>set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${ASSIMP_INCLUDE_DIR}")</code>. With ASSIMP_INCLUDE_DIR being ../contrib/assimp/include.</p>

<p>Now when I use some class in my main.cpp it gives me errors about undefined references to some funtions, because obviously I don't have the source files.</p>

<p>When I add the libassimp.a to my compile flags I get the following errors when using make:</p>

<pre><code>make[3]: *** No rule to make target `../contrib/assimp/lib/libassimp.a',
...
main.cpp:7:32: fatal error: assimp/Importer.hpp: No such file or directory
....
Linking CXX static library libassimp.a
</code></pre>

<p>I don't understand these messages. Maybe they are there because it's trying to access libassimp.a before it's actually there? Is this some kind of concurrency problem?</p>

<p>Anyways, if I call <code>make</code> again then I get different errors, namely a bunch of undefined references to things I am not using, e.g.</p>

<pre><code>../contrib/assimp/lib/libassimp.a(AssbinLoader.cpp.o): In function `Assimp::AssbinImporter::InternReadFile(std::string const&amp;, aiScene*, Assimp::IOSystem*)':
AssbinLoader.cpp:(.text+0x2a49): undefined reference to `uncompress'
</code></pre>

<p><strong>EDIT:</strong>  </p>

<p>I am compiling with CMake like this:</p>

<pre><code>target_link_libraries(monoRenderer [some other libraries] ${ASSIMP_STATIC_LIB})
</code></pre>

<p><code>ASSIMP_STATIC_LIB</code> is the path to libassimp.a.</p>

<p><strong>EDIT2:</strong></p>

<p>I reduced my CMake file to this:</p>

<pre><code>cmake_minimum_required(VERSION 2.8.12)
project(monoRenderer)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")

file(GLOB_RECURSE CXX_SRCS src/*.cpp)
file(GLOB_RECURSE C_SRCS src/*.c)
file(GLOB_RECURSE HPP_HDRS src/*.hpp)
file(GLOB_RECURSE H_HDRS src/*.h)
set(SRCS "${C_SRCS};${CXX_SRCS}")
set(HDRS "${H_HDRS};${HPP_HDRS}")

include_directories(${PROJECT_SOURCE_DIR}/contrib/assimp/include)

add_executable(monoRenderer ${SRCS} ${HDRS})
target_link_libraries(monoRenderer ${PROJECT_SOURCE_DIR}/contrib/assimp/lib/libassimp.a)
</code></pre>

<p>The header files are in <code>contrib/assimp/include</code> and the libassmip.a is in  <code>contrib/assimp/lib</code>. It still doesn't work, same errors as before.
My main.cpp looks like this:</p>

<pre><code>#include &lt;assimp/Importer.hpp&gt;
#include &lt;cstdlib&gt;

int main() {
    Assimp::Importer importer;
    return EXIT_SUCCESS;
}
</code></pre>

<p><strong>EDIT3:</strong>  </p>

<p>I think it has something to do with zlib, since all the errors seem to have that in common I think:</p>

<pre><code>undefined reference to `uncompress'
undefined reference to `inflateInit2_'
undefined reference to `inflate'
undefined reference to `inflateEnd'
undefined reference to `inflateReset'
undefined reference to `inflateSetDictionary'
undefined reference to `get_crc_table'
undefined reference to `crc32'
</code></pre>