当我尝试编译以下内容时:

#include <windows.h>
#include <shlwapi.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
  char firstPart[MAX_PATH] = "c:\\windows";
  char secondPart[MAX_PATH] = "system32";
  PathAppend(firstPart, secondPart);

  return 0;
}

使用命令:

c:\mingw\bin\gcc -mwindows -mno-cygwin -o test test.c

失败并显示错误:

  

未定义引用``_imp__PathAppendA @ 8'`

这肯定是我的愚蠢,但有人可以告诉我我在这里缺少什么吗?

有帮助吗?

解决方案

您需要添加用于链接的shlwapi库:

gcc -o test test.c -lshlwapi

为我工作

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top