未解决的链接器错误许多Windows功能在Qt [英] unresolved linker errors for many windows functions in Qt

查看:341
本文介绍了未解决的链接器错误许多Windows功能在Qt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Qt,我得到未解决的链接器错误许多Windows函数,如 SHGetKnownFolderPath

  #includepip.h
#includeui_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:未解析的外部符号_SHGetKnownFolderPath @ 16 
引用函数private:void __thiscall pip :: on_submitButton_clicked(void)
on_submitButton_clicked @ pip @@ AAEXXZ)



我需要告诉QT哪里 Shell32.dll 库是 shlobj.h 吗?

解决方案

您必须使用实现该符号的 shell32.lib 链接 >

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

  LIBS + = -LC:\\Path\\Microsoft SDK\\Windows\\v7.1\\Lib-lshell32 


In Qt, I am getting unresolved linker errors for many windows functions such as 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>

Function:

PWSTR appData = 0;

    if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Desktop,
                                   0,
                                   NULL,
                                   &appData)))
{
    wcout << appData << endl;
}

Linker Error:

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)

Do I need to tell QT where the Shell32.dll library is or something for shlobj.h?

解决方案

You have to link your project with the library (shell32.lib) that implements that symbol!

You should add something like the following to the .PRO file:

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

这篇关于未解决的链接器错误许多Windows功能在Qt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆