gpt4 book ai didi

windows - Qt链接静态构建库

转载 作者:可可西里 更新时间:2023-11-01 10:26:28 26 4
gpt4 key购买 nike

我有一个目标为 lib 的项目,另一个目标为 app

第一个项目成功构建为静态动态(共享)库。

第二个项目成功链接了一个dynamic lib,但是它不能链接一个static lib。出现许多错误消息,例如 LNK2001: unresolved external symbol

应用程序专业版:

TEMPLATE = app
CONFIG += static link_prl ordered
DEFINES += QT_NODLL
QT += core gui network xml

...

# --- LINK QUAZIP LIB SHARED ---

#LIBS += -L$$quote(C:/Qt/quazip/build-quazip-0.5.1-Qt_4_8_3_shared-Debug/quazip/debug) -lquazip
#PRE_TARGETDEPS += $$quote(C:/Qt/quazip/build-quazip-0.5.1-Qt_4_8_3_shared-Debug/quazip/debug/quazip.lib)

# --- LINK QUAZIP LIB STATIC ---

LIBS += -L$$quote(C:/Qt/quazip/build-quazip-0.5.1-Qt_4_8_3_static-Release/quazip/release) -lquazip
PRE_TARGETDEPS += $$quote(C:/Qt/quazip/build-quazip-0.5.1-Qt_4_8_3_static-Release/quazip/release/quazip.lib)

目录内容:

 Directory of C:\Qt\quazip\build-quazip-0.5.1-Qt_4_8_3_shared-Debug\quazip\debug

04.04.2013 11:01 <DIR> .
04.04.2013 11:01 <DIR> ..
04.04.2013 11:01 188 498 JlCompress.obj
04.04.2013 11:01 2 484 moc_quagzipfile.cpp
04.04.2013 11:01 43 994 moc_quagzipfile.obj
04.04.2013 11:01 2 501 moc_quaziodevice.cpp
04.04.2013 11:01 44 026 moc_quaziodevice.obj
04.04.2013 11:01 2 467 moc_quazipfile.cpp
04.04.2013 11:01 62 441 moc_quazipfile.obj
04.04.2013 11:01 40 936 qioapi.obj
04.04.2013 11:01 24 586 quaadler32.obj
04.04.2013 11:01 24 554 quacrc32.obj
04.04.2013 11:01 73 276 quagzipfile.obj
04.04.2013 11:01 69 745 quaziodevice.obj
04.04.2013 11:01 188 928 quazip.dll
04.04.2013 11:01 40 067 quazip.exp
04.04.2013 11:01 999 808 quazip.ilk
04.04.2013 11:01 381 quazip.intermediate.manifest
04.04.2013 11:01 65 678 quazip.lib
04.04.2013 11:01 156 746 quazip.obj
04.04.2013 11:01 1 166 336 quazip.pdb
04.04.2013 11:01 259 653 quazipdir.obj
04.04.2013 11:01 117 317 quazipfile.obj
04.04.2013 11:01 47 039 quazipfileinfo.obj
04.04.2013 11:01 57 489 quazipnewinfo.obj
04.04.2013 11:01 35 483 unzip.obj
04.04.2013 11:01 34 526 zip.obj
25 File(s) 3 748 959 bytes
2 Dir(s) 17 125 515 264 bytes free

Directory of C:\Qt\quazip\build-quazip-0.5.1-Qt_4_8_3_static-Release\quazip\release

04.04.2013 12:46 <DIR> .
04.04.2013 12:46 <DIR> ..
04.04.2013 12:46 1 457 363 JlCompress.obj
04.04.2013 12:46 2 484 moc_quagzipfile.cpp
04.04.2013 12:46 1 084 653 moc_quagzipfile.obj
04.04.2013 12:46 2 501 moc_quaziodevice.cpp
04.04.2013 12:46 1 084 461 moc_quaziodevice.obj
04.04.2013 12:46 2 467 moc_quazipfile.cpp
04.04.2013 12:46 1 199 125 moc_quazipfile.obj
04.04.2013 12:46 1 084 170 qioapi.obj
04.04.2013 12:46 279 307 quaadler32.obj
04.04.2013 12:46 279 270 quacrc32.obj
04.04.2013 12:46 1 115 174 quagzipfile.obj
04.04.2013 12:46 1 108 222 quaziodevice.obj
04.04.2013 12:46 14 977 872 quazip.lib
04.04.2013 12:46 1 246 009 quazip.obj
04.04.2013 12:46 801 quazip.prl
04.04.2013 12:46 1 357 090 quazipdir.obj
04.04.2013 12:46 1 246 159 quazipfile.obj
04.04.2013 12:46 1 121 490 quazipfileinfo.obj
04.04.2013 12:46 1 134 685 quazipnewinfo.obj
04.04.2013 12:46 56 712 unzip.obj
04.04.2013 12:46 59 090 zip.obj
21 File(s) 29 899 105 bytes
2 Dir(s) 17 123 479 552 bytes free

据我了解,qmake 需要一个 dll 链接到它。我如何告诉它我想构建一个静态应用程序并让它在静态构建的库中查找外部?

最佳答案

要静态链接 QuaZip 需要配置 += 静态库在你的 qmake 文件中。

或者确保在您实际从应用程序中包含任何 QuaZip header 之前定义了 QUAZIP_STATIC

关于windows - Qt链接静态构建库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15807605/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com