简体   繁体   English

包括QDebug时mingw32链接器错误

[英]mingw32 linker error when including QDebug

I have this minimal example: 我有这个最小的例子:

QT -= gui
CONFIG += qt console
SOURCES += main.cpp

#include <QDebug>

int main(int argc, char** argv)
{
    return 0;
}

which gives this link error when building the project: 在构建项目时会出现此链接错误

c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: final link failed: Invalid argument c:/ qtsdk / mingw / bin /../ lib / gcc / mingw32 / 4.4.0 /../../../../ mingw32 / bin / ld.exe:最终链接失败:参数无效

The link command looks like this: link命令如下所示:

g++ -Wl -Wl -Wl,-subsystem,console -mthreads -o debug\\test.exe debug/main.o -L"c:\\QtSDK\\Desktop\\Qt\\4.8.1\\mingw\\lib" -lQtCored4 g ++ -Wl -Wl -Wl,-子系统,控制台-mthreads -o debug \\ test.exe debug / main.o -L“ c:\\ QtSDK \\ Desktop \\ Qt \\ 4.8.1 \\ mingw \\ lib” -lQtCored4

My setup: 我的设置:

  • Windows XP SP3 Windows XP SP3
  • Qt SDK version 1.2.1 (QtCreator 2.4.1, Qt Desktop version 4.8.1) (fresh install at C:\\QtSDK\\ ) Qt SDK版本1.2.1(QtCreator 2.4.1,Qt Desktop版本4.8.1)(在C:\\QtSDK\\重新安装)
  • MinGW32 version 4.4.0 (included in Qt SDK at C:\\QtSDK\\mingw\\ ) MinGW32版本4.4.0(包含在C:\\QtSDK\\mingw\\ Qt SDK中)

If I remove the #include <QDebug> , it compiles fine. 如果删除#include <QDebug> ,它可以正常编译。 If I include some other Qt header file, like for example QCoreApplication, it compiles fine, too. 如果我包括其他一些Qt头文件,例如QCoreApplication,它也可以编译。

EDIT: Here is a very strange minimal example. 编辑:这是一个非常奇怪的最小示例。 Consider an empty main function like above. 考虑上面空的main函数。 Now if i put these includes, it fails to link: 现在,如果我放入这些包含项,它将无法链接:

#include <QWidget>
#include <QVariant>

But if I remove one of them , it links without an error. 但是,如果我删除其中一个 ,它会链接而不会出现错误。

What's the problem? 有什么问题? Why doesn't mingw tell me what the invalid argument is ? 为什么mingw不能告诉我无效的参数是什么?

Im wondering is the linker could not find the lQtCored4 lib? 我想知道链接器找不到lQtCored4库吗? Is it actually in the -L directory? 它实际上在-L目录中吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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