全新安装 Qt SDK 和 Visual C++ 时出现 LNK4099 链接器警告; 2008年
在新的 Windows 7 计算机上进行了全新安装:
- Visual Studio 2008 SP1
- Qt SDK 1.1.4
然后我在 Qt Creator 中创建了一个新项目。我在“Qt Widget Project”下选择了“Qt Gui Application”,并让它以 Visual C++ 2008 为目标桌面,进行调试和调试。释放(基本上是默认设置)。
然后我按下“Build”,然后得到......
qtmaind.lib(qtmain_win.obj):-1: warning: LNK4099: PDB 'vc90.pdb' was not
found with 'c:\QtSDK\Desktop\Qt\4.7.4\msvc2008\lib\qtmaind.lib' or at
'C:\Users\JamesJ\Desktop\QtTest-build-desktop-Qt_4_7_4_for_Desktop_-
_MSVC2008__Qt_SDK__Debug\debug\vc90.pdb'; linking object as if no debug info
我一定错过了一些明显的东西 - Qt 的开箱即用体验肯定不应该涉及编译器/链接器警告?!?!
如何解决此链接器警告?我更喜欢将警告视为错误,所以...我想解决这个问题。
Did a clean install on a new Windows 7 computer with:
- Visual Studio 2008 SP1
- Qt SDK 1.1.4
Then I created a new project in Qt Creator. I picked "Qt Gui Application" under "Qt Widget Project" and had it target desktops with Visual C++ 2008, both debug & release (basically default settings).
Then I pressed Build, and got....
qtmaind.lib(qtmain_win.obj):-1: warning: LNK4099: PDB 'vc90.pdb' was not
found with 'c:\QtSDK\Desktop\Qt\4.7.4\msvc2008\lib\qtmaind.lib' or at
'C:\Users\JamesJ\Desktop\QtTest-build-desktop-Qt_4_7_4_for_Desktop_-
_MSVC2008__Qt_SDK__Debug\debug\vc90.pdb'; linking object as if no debug info
I must be missing something obvious - surely the out-of-box experience with Qt isn't supposed to involve compiler/linker warnings?!?!
How do I resolve this linker warning? I prefer to treat warnings as errors, so... I'd like to get this fixed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
qtmain_win.obj
中嵌入的vc90.pdb
的路径与链接器设置中设置的路径不同。按照 中的说明本文:
在链接器设置中,
属性->链接器->调试->生成程序数据库文件
的值为$(TargetDir)$(TargetName).pdb
。在 C/C++ 设置中,
Properties->C/C++->Output Files->Program Database File
应也设置为$(TargetDir )$(TargetName).pdb
(其默认值为$(IntDir)\vc90.pdb
)。如果失败,您可以尝试清理并重建调试版本。
The path to
vc90.pdb
embedded inqtmain_win.obj
is not the same path that is set in your linker settings.Per the instructions in this article:
In the linker settings,
Properties->Linker->Debugging->Generate Program Database File
has the value$(TargetDir)$(TargetName).pdb
.In the C/C++ settings,
Properties->C/C++->Output Files->Program Database File
should also be set to$(TargetDir)$(TargetName).pdb
(its default value is$(IntDir)\vc90.pdb
).Failing that, you can try cleaning and rebuilding the Debug build.
单独安装 Qt Library (4.8.2) 和 Qt Creator (2.5.2) 在这里工作。我不再收到 LNK4099 警告。
确保删除 QtSDK 留下的设置:
KHCU\Software\Nokia
和%APPDATA%\Nokia
文件夹中的键。在 QtSDK 包管理器中手动升级 QT 库也可能有效。
Separately installing Qt Library (4.8.2) and Qt Creator (2.5.2) worked here. I no longer get the LNK4099 warning.
Make sure to remove the settings QtSDK leaves behind: the keys in
KHCU\Software\Nokia
and the%APPDATA%\Nokia
folder.Upgrading QT Library manually within QtSDK package manager might also work.
无法找到解决方案。我确信重新编译 Qt 可以解决该问题,但为了简单起见,我现在想坚持使用 SDK 中安装的内容。
Was unable to find a solution to this. I'm sure recompiling Qt would resolve the issue, but for simplicity I want to stick with what is installed with the SDK for now.
当您在编译后将 Qt 目录(即包含 libs/pdbs 的目录)移动到其他目录时,就会发生这种情况。 PDB 文件的路径嵌入在库中,因此当您移动它们时,链接器无法找到它。
在我看来,最安全/最干净的问题是在新位置重建 Qt。
This happens when you move Qt directories (i.e. the ones containing libs/pdbs) to a different directory after compilation. The path to the PDB file is embedded in the libraries, so when you move them the linker cannot find it.
Seems for me that the safest/cleanest issue is to rebuild Qt in the new location.
添加
将
QMAKE_LFLAGS += /ignore:4099
到您的 .pro 文件中。
如果您不想为可执行文件或库创建 .pdb 文件,请添加
QMAKE_CXXFLAGS += /Z7
,以便调试信息将放入 .obj 文件中。
您可能需要删除所有 Makefile* 才能更新构建规则。
在带有 MSVC 2008 SP1 的 Qt Creator 2.4.1 中测试
Add
QMAKE_LFLAGS += /ignore:4099
to your .pro file.
if you want to not create .pdb files for your executables or library add
QMAKE_CXXFLAGS += /Z7
so debug information will put in .obj files.
You maybe need to delete all Makefiles* to update the building rules.
Tested in Qt Creator 2.4.1 with MSVC 2008 SP1