简体   繁体   中英

Using External Library (libarchive) in Qt - No .lib file

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.

实际上, LIBS += -L$$PWD/libarchive/lib/ -llibarchive应该是LIBS += -L$$PWD/libarchive/lib/ -larchive

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 :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM