QT4 的基本编译问题
我一直在尝试从大学教科书中获取一个非常简单的列表,以便使用我昨晚下载的最新的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的 .pro 文件使用 SUBDIRS 模板,该模板需要一个与每个子目录的目录名称相匹配的 .pro 文件。您还应该有一个
utils\utils.pro
和dataobjects\dataobject.pro
文件。c:\Users\Cobus\workspace\lib\libdataobjects.a
构建正确吗?如果没有,请检查子目录.pro
文件。根据您发布的内容,我不希望编译任何内容。您需要子目录
.pro
文件中的目标来构建任何内容。You
.pro
file uses theSUBDIRS
template which requires a .pro file matching the directory name for each subdir. You should have autils\utils.pro
anddataobjects\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.它们似乎是另一个 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