Using the external library (libarchive) in Qt - No .lib file

advertisements

I've built libarchive on both Linux and Windows following the build instructions.

Basically I have some .a files and a dll, but no .lib file. I want to link my Qt project to this library, but all of the examples I have seen require a .lib file, but there doesn't seem to be one.

This is what my .pro contains:

LIBS += -L$$PWD/libarchive/lib/ -llibarchive

INCLUDEPATH += $$PWD/libarchive/include
DEPENDPATH += $$PWD/libarchive/include

and my code is:

#include <QtGui/QApplication>
#include <archive.h>
#include <archive_entry.h>

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    struct archive *a;
    a = archive_read_new();

    return app.exec();
}

The headers are found, the project builds, but dies as soon as I try to run it.


I found that the problem was that the executable was failing to find the associated .dll file. It can be fixed by putting the libarchive.dll file in the same directory as the executable file and it's as happy as can be :-)