LNK4099 linker warning with clean install of Qt SD

2019-06-23 16:46发布

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.

5条回答
不美不萌又怎样
2楼-- · 2019-06-23 17:21

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

查看更多
成全新的幸福
3楼-- · 2019-06-23 17:22

The path to vc90.pdb embedded in qtmain_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.

查看更多
淡お忘
4楼-- · 2019-06-23 17:24

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.

查看更多
戒情不戒烟
5楼-- · 2019-06-23 17:37

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.

查看更多
戒情不戒烟
6楼-- · 2019-06-23 17:38

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.

查看更多
登录 后发表回答