在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>
功能:
PWSTR appData = 0;
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Desktop,
0,
NULL,
&appData)))
{
wcout << appData << endl;
}
链接器错误:
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)
我是否需要告诉QT Shell32.dll
库的位置或shlobj.h
的内容?
答案 0 :(得分:2)
您必须链接您的项目与实现该符号的库( shell32.lib )!
您应该在.PRO文件中添加以下内容:
LIBS += -L"C:\\Path\\Microsoft SDK\\Windows\\v7.1\\Lib" -lshell32