QT4 的基本编译问题

发布于 2024-08-31 06:55:27 字数 1035 浏览 4 评论 0原文

我一直在尝试从大学教科书中获取一个非常简单的列表,以便使用我昨晚下载的最新的 Windows 版 QT SDK 进行编译。在经历了常规的废话(没有 make.bat,需要手动添加环境变量等等)之后,我终于可以构建了。但这两个库似乎只有一个可以工作。

我使用的 .pro 文件非常简单:

SUBDIRS += utils \
           dataobjects

TEMPLATE = subdirs

在这两个子文件夹中的每一个中,我都有一个库的源代码。运行 QMAKE 会生成一个 makefile,运行 Make 会完成所有预备工作,然后在 g++ 调用上失败:

g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc --out-implib,libdataobjects.a -shared -mthreads -Wl -Wl,--out-implib,c:\Users\Cobus\workspace\lib\libdataobjects.a -o ..\..\lib\dataobjects.dll object_script.dataobjects.Debug  -L"c:\Users\Cobus\Portab~1\Qt\2010.02.1\qt\lib" -LC:\Users\Cobus\workspace\lib -lutils -lQtXmld4 -lQtGuid4 -lQtCored4
c:/users/cobus/portab~1/qt/2010.02.1/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lutils

问题似乎就在命令行末尾附近,其中添加了 -lutils,表明存在一个名为 的库实用程序。虽然我希望看到这一点,但您会注意到 --out 之后的库名称在名称中包含 lib,因此它们变成了 libutils 和 libdataobjects。我试图找出为什么会发生这种情况,但无济于事。

有人知道发生了什么事吗?

I've been trying to get a dead simple listing from a university textbook to compile with the newest QT SDK for Windows I downloaded last night. After struggling through the regular nonsense (no make.bat, need to manually add environment variables and so on) I am finally at the point where I can build. But only one of the two libraries seem to work.

The .pro file I use is dead simple:

SUBDIRS += utils \
           dataobjects

TEMPLATE = subdirs

In each of these two subfolders I have the source for a library. Running QMAKE generates a makefile and running Make runs through all the preliminaries and then fails on the g++ call:

g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc --out-implib,libdataobjects.a -shared -mthreads -Wl -Wl,--out-implib,c:\Users\Cobus\workspace\lib\libdataobjects.a -o ..\..\lib\dataobjects.dll object_script.dataobjects.Debug  -L"c:\Users\Cobus\Portab~1\Qt\2010.02.1\qt\lib" -LC:\Users\Cobus\workspace\lib -lutils -lQtXmld4 -lQtGuid4 -lQtCored4
c:/users/cobus/portab~1/qt/2010.02.1/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lutils

The problem seems to be right near the end of the command line, where -lutils is added, indicating that there is a library by the name of utils. While I would have expected to see that, you'll notice the library names after --out include lib in the name, so they become libutils and libdataobjects. I have tried to figure out why this is happening, to no avail.

Anyone have an idea what's going on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白色秋天 2024-09-07 06:55:27

您的 .pro 文件使用 SUBDIRS 模板,该模板需要一个与每个子目录的目录名称相匹配的 .pro 文件。您还应该有一个 utils\utils.prodataobjects\dataobject.pro 文件。

c:\Users\Cobus\workspace\lib\libdataobjects.a 构建正确吗?如果没有,请检查子目录.pro文件。

根据您发布的内容,我不希望编译任何内容。您需要子目录 .pro 文件中的目标来构建任何内容。

You .pro file uses the SUBDIRS template which requires a .pro file matching the directory name for each subdir. You should have a utils\utils.pro and dataobjects\dataobject.pro file as well.

Is c:\Users\Cobus\workspace\lib\libdataobjects.a built correctly? If not, check the sub directory .pro files.

With what you posted, I would not expect anything to compile. You need targets in the sub-directory .pro files to build anything.

神回复 2024-09-07 06:55:27

它们似乎是另一个 pro 文件,因为生成的 Makefile 正在拉取 QtXml,默认情况下它不会这样做。

请检查子目录中是否有任何 .pro 或 .pri 文件..其中之一将解答您的困惑

Their seems to be another pro file as the generated Makefile is pulling QtXml which it wont do by default.

Please check the subdirs for any .pro or .pri files .. one of them will have answer to your confusion

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文