Question

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

It fails with the error:

undefined reference to ``_imp__PathAppendA@8'`

Surely this is some stupidity on my part, but can someone tell me what I'm missing here?

Was it helpful?

Solution

You need to add the shlwapi library for linking:

gcc -o test test.c -lshlwapi

Works for me

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top