I have been using libarchive in my project for some time now and it works fine, at the moment I am dynamically linking to it, so in Windows the libarchive.dll file must be present in the system. Now I would like to statically reference the library, so I donβt have to worry about the distribution of the DLL, but I am having real problems trying to achieve this!
In my make file, I have something like this: -Lpath / to // libarchive / -larchive
And it works, but it is a dynamic link. I do not know how to provide a static link.
I see two files in the libarchive directory: libarchive.dll.a and libarchive_static.a. I suppose I want to associate myself with libarchive_static.a, but I cannot say this, doing -larchive_static in the make file leads to linker errors.
I got the impression that the static libraries under the windows are lib files, but I don't get this type of file when creating libarchive.
How can I make a .lib file from libarchive. Also, as an additional question, what is the difference between a file and a lib file?
Update
To statically reference libarchive, your library command for make must contain:
-Lpath / to // libarchive / -larchive_static
This will be a link to the libarchive_static.a file. However, you also need to define LIBARCHIVE_STATIC in your code.
Now the problem is that libarchive depends on bzip2 libraries (as well as others), and if you do not have a static build, you will get linker errors, for example:
undefined link to `BZ2_bzCompressInit '
You need a static assembly of dependent libraries and a similar command for the linker after the libarchive command:
-Lpath / to / bzip2 / -lbzip2
You can either build bzip2 from the source, or do it in a simple way, and get the pre-built binary from the Gnu32Win project here: http://gnuwin32.sourceforge.net/packages.html