My project's CMAKE_CXX_STANDARD_LIBRARIES originally contained by default: "-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32" (without the quotes).
I used mingwpy running on Windows Server 2008 32-bit to build my python extension DLL. The apr (apache portable runtime) library that's linked as a static library into my extension DLL makes a call to "CreateProcessAsUserW". When testing, I would get this error: "The procedure entry point CreateProcessAsUserW could not be located in the dynamic link library KERNEL32.dll". I found this error surprising, because CreateProcessAsUserW is in advapi32, and "-ladvapi32" was listed at the end of CMAKE_CXX_STANDARD_LIBRARIES, so it should have been picked up by mingwpy's linker/loader. I was able to fix this failure by moving
"-ladvapi32" to the beginning so that it was in front of "-lkernel32" like so: "-ladvapi32 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32".
However, I don't understand why it was necessary to place -ladvapi32 in front of -lkernel32 to make the CreateProcessAsUserW problem go away. Does someone know why this would be necessary?
Many thanks,
Vitaly