1

在 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)

我需要告诉 QTShell32.dll图书馆在哪里shlobj.h吗?

4

1 回答 1

2

您必须您的项目与实现该符号的shell32.lib )链接!

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

LIBS += -L"C:\\Path\\Microsoft SDK\\Windows\\v7.1\\Lib" -lshell32
于 2013-10-12T16:27:56.720 回答