【问题标题】:cross compiling qt (linux/mingw -> windows): various undefined references交叉编译 qt (linux/mingw -> windows):各种未定义的引用
【发布时间】:2012-10-23 18:31:01
【问题描述】:

(来自here的交叉帖子,因为似乎没有人知道)

大家好,

我正在尝试从我的 linux 为我的 windows 交叉编译 qt 4.8.3。最终目标是构建一个静态 qt,但独立于是否构建静态我总是得到相同的错误。玩弄各种旗帜也无济于事:

./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x18dc): undefined reference to `QGb18030Codec::QGb18030Codec()'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x18ef): undefined reference to `QGbkCodec::QGbkCodec()'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x1902): undefined reference to `QGb2312Codec::QGb2312Codec()'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x1915): undefined reference to `QEucJpCodec::QEucJpCodec()'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x1928): undefined reference to `QJisCodec::QJisCodec()'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x193b): undefined reference to `QSjisCodec::QSjisCodec()'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x1956): undefined reference to `vtable for QEucKrCodec'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x1971): undefined reference to `vtable for QCP949Codec'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x198c): undefined reference to `vtable for QBig5Codec'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x19a7): undefined reference to `vtable for QBig5hkscsCodec'

我正在使用默认的win32-g++配置文件和mingw。

我用谷歌搜索了很多,但我仍然不知道这是从哪里来的。也许你们中的某个人对我有正确的提示;-)

【问题讨论】:

  • 只是好奇,为什么要交叉编译而不是在 Windows 中构建?我在 linux 中进行所有开发,但在小型 Windows VM 上使用 QtCreator 保留整个 qt/mingw 工具链,以在那里构建可部署的二进制文件。 比交叉编译或尝试处理 VS 容易得多
  • 目前我这里只有linux+mingw,虽然在windows上设置mingw会是我的后备解决方案。
  • 您的问题应该可以通过我类似stackoverflow.com/questions/13075577/… 的hack 来解决。

标签: c++ qt mingw cross-compiling


【解决方案1】:

您可以使用 MXE 来构建它。这很容易。你只需这样做:

make qt

它几乎可以自动完成所有工作,包括下载源代码、应用所需的补丁以启用交叉编译(这可能是您自己手动交叉编译 Qt 失败的原因)以及构建所有依赖项。您可以从:http://mxe.cc 下载 MXE。当然,请阅读有关如何使用它交叉编译软件的文档。

它的要点是,您使用 i686-pc-mingw32-qmake 代替 qmake(根据文档,在您更改 PATH 以包含 MXE 目录之后。)

MXE 将所有内容构建为静态库,因此当您交叉编译程序时,您将获得一个不依赖任何 DLL 的单个 .exe 文件。

【讨论】:

    猜你喜欢
    • 2016-03-26
    • 2017-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-25
    • 2021-12-21
    • 2011-04-18
    相关资源
    最近更新 更多