0

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.

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.

2 Answers2

1

Credit to: Barmak Shemirani

Open your project properties, go to Linker->Input and add Shlwapi.lib to dependencies. Works like a charm.

1

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"

You can include the lib file in your project settings.