在 mingw 下编译时出现路径查找文件名错误

error with PathFindFileName when compiling under mingw

本文关键字:路径 查找 文件名 错误 mingw 编译      更新时间:2023-10-16

code:

#include <shlwapi.h>
int main() {
  TCHAR buffer[MAX_PATH];
  DWORD bufSize;
  GetModuleFileName(NULL, buffer, bufSize);
  TCHAR* out = PathFindFileName(buffer);
}

错误信息:

ccQzTh4t.o:pathfind.cpp:(.text.startup+0x40): undefined reference to `_imp__PathFindFileNameA@4'
collect2: ld returned 1 exit status

也许我忘记了一些包含?

PathFindFileNameShlwapi.lib库的一部分,你需要链接到它。