C++ Qt中许多windows函数的未解决链接器错误

C++ Qt中许多windows函数的未解决链接器错误,c++,windows,qt,C++,Windows,Qt,在Qt中,许多windows函数(如SHGetKnownFolderPath #include "pip.h" #include "ui_pip.h" #include <QFileDialog> #include <QMessageBox> #include <Objbase.h> #include <iostream> #include <fstream> #include <string> #include <s

在Qt中,许多windows函数(如
SHGetKnownFolderPath

#include "pip.h"
#include "ui_pip.h"
#include <QFileDialog>
#include <QMessageBox>
#include <Objbase.h>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <algorithm>
#include <QtNetwork/QHostAddress>
#include <shlobj.h>
#include <windows.h>
#include <Shlwapi.h>
#include <Knownfolders.h>

我需要告诉QT Shell32.dll库在哪里,或者是shlobj.h的什么东西吗?

你必须将你的项目链接到实现该符号的库(Shell32.lib)

您应该向.PRO文件中添加如下内容:

LIBS += -L"C:\\Path\\Microsoft SDK\\Windows\\v7.1\\Lib" -lshell32

-L
之后的显式路径是不必要的,Qt必须链接到windows库,所以它就在那里<代码>-lshell32就足够了。
pip.obj : error LNK2019: unresolved external symbol _SHGetKnownFolderPath@16 
referenced in function "private: void __thiscall pip::on_submitButton_clicked(void)" 
(?on_submitButton_clicked@pip@@AAEXXZ)
LIBS += -L"C:\\Path\\Microsoft SDK\\Windows\\v7.1\\Lib" -lshell32