>
>
>
>--
>
>Message: 3
>Date: Fri, 18 Mar 2016 04:37:25 +0100
>From: Vincent Torri
>Subject: Re: [Mingw-w64-public] Order of -ladvapi32 versus -lkernel32
>To: "mingw-w64-public@lists.sourceforge.net"
>
>Message-ID:
>
>Content-Type: text/plain; charset=UTF-8
>
>hello
>
>On Fri, Mar 18, 2016 at 2:48 AM, Vitaly Kruglikov
> wrote:
>>
>> Carl of mingwpy suggested that I re-post this question here (originally
>>posted on https://groups.google.com/forum/#!topic/mingwpy/kHhGl3mBNfo)
>>
>>
>> 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 (based on mingw-w64) 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? Is there a better way to
>>avoid this problem?
>
>advapi32.dll depends on kernel32.dll (you can see that with dependency
>walker for example), and the order of the -l flags is important : from
>right to left : the "less dependent" to the "more dependant". So pass
>to the linker "-ladvapi32 -lkernel32" because advapi32.dll depends on
>kernel32.dll
>
>Vincent Torri
Many thanks Vincent. I guess that the haphazard order that CMake used to
add libraries to CMAKE_CXX_STANDARD_LIBRARIES should not be relied upon,
and should be set explicitly instead!
Best,
Vitaly
--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public