简体   繁体   English

函数路径上未解决的外部符号错误

[英]Unresolved External Symbol Error on Function PathAppend

I'm trying to create a new directory for save files in my game, and I'm getting an unresolved external symbol error when I use PathAppend . 我正在尝试为游戏中的保存文件创建一个新目录,并且在使用PathAppend时遇到未解决的外部符号错误。

if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_DOCUMENTS, NULL, 0, path))) {
            PathAppend(path, "AotDK\\saves");
            if (SHCreateDirectoryEx(NULL, path, NULL) != ERROR_SUCCESS) {
                std::cout << "Error: " << GetLastError();
            }
        } else {
        std::cout << "Error: " << GetLastError();
        }

I know that this usually means I haven't included a header file, but from what I can gather I've included all that I need. 我知道这通常意味着我没有包括头文件,但是据我所知,我已经包括了所有我需要的东西。 Am I missing one? 我想念一个吗?

#include "main.hpp"
#include <iostream>
#include <Windows.h>
#include <ShlObj.h>
#include <Shlwapi.h>

If not, did I structure the code wrong? 如果不是,我的代码结构是否错误? I based it off of a previously asked question's answer, so I would assume not. 我基于先前提出的问题的答案,所以我认为不会。

Credit to: Barmak Shemirani 致谢:Barmak Shemirani

Open your project properties, go to Linker->Input and add Shlwapi.lib to dependencies. 打开项目属性,转到Linker-> Input并将Shlwapi.lib添加到依赖项。 Works like a charm. 奇迹般有效。

The error doesn't mean that you havn't included the header file. 该错误并不表示您没有包含头文件。 This error means that you are not linking against the corresponding library. 此错误意味着您没有链接到相应的库。

The error is linker error and the solution is to include in your project the lib file "Shlwapi.lib" 该错误是链接器错误,解决方案是在您的项目中包含lib文件“ Shlwapi.lib”

You can include the lib file in your project settings. 您可以在项目设置中包含lib文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM