Mingw linker cannot find PathAppend

When I try to compile the following:

#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;
}

Using the command:

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

Error with error:

undefined link to `` _imp__PathAppendA @ 8``

Of course, this is some kind of stupidity on my part, but can someone tell me what I am missing here?

+3
source share
1 answer

You need to add the shlwapi library for the link:

gcc -o test test.c -lshlwapi

Works for me

+4
source

Source: https://habr.com/ru/post/1704402/


All Articles