【问题标题】:Undefined reference in Windows with QT, QTcreator and mingw32带有 QT、QTcreator 和 mingw32 的 Windows 中未定义的引用
【发布时间】:2012-04-06 20:50:54
【问题描述】:

当我在带有 mingw32 的 Windows 中构建应用程序时,我得到了未定义的引用(在 Linux 中不会发生)。该应用程序分为两部分:

1- 一组带有 PRO 的设计器插件,例如:

QT += 核心 gui sql

CONFIG += 设计器插件 debug_and_release

TARGET = $$qtLibraryTarget(impwidgetsplugin)

模板 = 库

这会在 c:\ilri\crossimpact\ 中生成文件:libimpwidgetsplugin.a 和 impwidgetsplugin.dll

2- 库中的一组插件,需要带有 PRO 的 impwidgetsplugin,例如:

QT += core gui sql svg

TARGET = $$qtLibraryTarget(impmainmodules) 模板 = lib CONFIG += 插件

win32:LIBS += -Lc:/ilri/crossimpact -limpwidgetsplugin

....

问题是我总是得到:

./release\plots.o:plots.cpp:(.text+0x13f5): undefined reference to `calcDialog::calcDialog(QWidget*)'

calcDialog 在 impwidgetsplugin 中定义。

我可以看到 make 参数具有所需的库 limpwidgetsplugin:

g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl -shared -Wl,--out-implib,..\..\..\libimpmainmodules.a -o ..\..\..\impmainmodules.dll object_script.impmainmodules.Release -L"c:\Qt\2010.03\qt\lib" -Lc:/ilri/crossimpact -limpwidgetsplugin -lQtSvg4 -lQtSql4 -lQtGui4 -lQtCore4

知道我需要如何配置 PRO 以便正确链接它吗?

非常感谢您的帮助。 卡洛斯。

【问题讨论】:

    标签: qt reference qt-creator undefined mingw32


    【解决方案1】:

    通过在插件 .pro 文件中使用 LIBS+=-Wl,-export-all-symbols,您可以获得与 linux 几乎相同的行为。

    但您似乎没有使用宏 Q_DECL_EXPORT and Q_DECL_IMPORT 正确导出类。

    【讨论】:

    • 是的!这就是问题所在!非常感谢。
    猜你喜欢
    • 2021-02-18
    • 2016-06-20
    • 1970-01-01
    • 2014-07-13
    • 2014-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-12
    相关资源
    最近更新 更多