Re: [Mingw-w64-public] Linking fails for GetSaveFileName when cross compiling with MinGW

2019-01-08 Thread Liu Hao
在 2019/1/9 上午5:01, Vincent Torri 写道:
> On Tue, Jan 8, 2019 at 9:40 PM Sailor Bob via Mingw-w64-public
>  wrote:
>>
>>  OK, figured out what the problem was - order of arguements on the command 
>> line:
>> i686-w64-mingw32-g++ -lcomdlg32 -municode -o unilogger.exe
>> gives the link error, however
>> i686-w64-mingw32-g++ -municode -o unilogger.exe -lcomdlg32
>>
>> Compiles just fine.  Go figure...
> 
> it's normal, this is the classic order of dependencies (from the right
> the libraries with the fewest deps to the left with the most deps)
> 

This looks correct intuitively, but it is not.

Let's say we have an object file `main.o` containing an undefined
reference to function `foo()` which is defined in 'libfoo.a', which
references another function `bar()` in 'libbar.a'. If we invoke the
linker (driver) like 'g++ main.o -lfoo -lbar', after the linker have
collected all object files: There is an undefined reference to `foo`, so
it looks for it in 'libfoo.a' and finds one, which introduces another
undefined reference to `bar`. Now the linker sees 'libbar.a' and finds
it. If the order of '-lfoo' and '-lbar' was swapped, things would go
like this: The linker first sees 'libbar.a' which doesn't contain `foo`
and is ignored. The linker then sees 'libfoo.a' and finds `foo` which
pulls in the undefined reference `bar`. Since the list of libraries is
only scanned in one pass, this progress results in an undefined
reference to `bar`.

When there are dependency cycles i.e. when multiple libraries reference
symbols from each other, some of them might have to be specified
multiple times on the linker command line, due to how the linker works.


-- 
Best regards,
LH_Mouse



signature.asc
Description: OpenPGP digital signature
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] Linking fails for GetSaveFileName when cross compiling with MinGW

2019-01-08 Thread Vincent Torri
On Tue, Jan 8, 2019 at 9:40 PM Sailor Bob via Mingw-w64-public
 wrote:
>
>  OK, figured out what the problem was - order of arguements on the command 
> line:
> i686-w64-mingw32-g++ -lcomdlg32 -municode -o unilogger.exe
> gives the link error, however
> i686-w64-mingw32-g++ -municode -o unilogger.exe -lcomdlg32
>
> Compiles just fine.  Go figure...

it's normal, this is the classic order of dependencies (from the right
the libraries with the fewest deps to the left with the most deps)

Vincent Torri


___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] Linking fails for GetSaveFileName when cross compiling with MinGW

2019-01-08 Thread Sailor Bob via Mingw-w64-public
 OK, figured out what the problem was - order of arguements on the command line:
i686-w64-mingw32-g++ -lcomdlg32 -municode -o unilogger.exe
gives the link error, however
i686-w64-mingw32-g++ -municode -o unilogger.exe -lcomdlg32 

Compiles just fine.  Go figure...
On Tuesday, January 8, 2019, 8:36:05 PM GMT+2, Mateusz 
 wrote:  
 
 W dniu 08.01.2019 o 18:29, Sailor Bob via Mingw-w64-public pisze:
> 
> I'm trying to compile a modified version of UniLogger on Ubuntu 18.04 using 
> mingw. I'm getting the following link error:
> 
> undefined reference to '_imp__GetSaveFileNameW@4'

I've tested GetSaveFileNameW sample with native mingw-w64 GCC:
$ cat t.c
#include 

WCHAR szFile[512];
OPENFILENAMEW Ofn;

int main()
{
  Ofn.lStructSize = sizeof(OPENFILENAMEW);
  Ofn.lpstrFile= szFile;
  Ofn.nMaxFile = sizeof(szFile)/ sizeof(*szFile);
  Ofn.Flags = OFN_SHOWHELP | OFN_OVERWRITEPROMPT;
  GetSaveFileNameW(&Ofn);
  return 0;
}
Mateusz@Mateusz-i7 /f/b/ma-gcc/c
$ gcc -Wall -o t.exe t.c
f:/msys/m32-741/bin/../lib/gcc/i686-w64-mingw32/7.4.1/../../../../i686-w64-mingw32/bin/ld.exe:
 C:\Users\Mateusz\AppData\Local\Temp\cc290RXt.o:t.c:(.text+0x46): undefined 
reference to `_imp__GetSaveFileNameW@4'
collect2.exe: error: ld returned 1 exit status

Mateusz@Mateusz-i7 /f/b/ma-gcc/c
$ gcc -Wall -o t.exe t.c -lcomdlg32

Now it is OK and t.exe works.

Regards,
Mateusz



___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
  
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] Linking fails for GetSaveFileName when cross compiling with MinGW

2019-01-08 Thread Mateusz
W dniu 08.01.2019 o 18:29, Sailor Bob via Mingw-w64-public pisze:
> 
> I'm trying to compile a modified version of UniLogger on Ubuntu 18.04 using 
> mingw. I'm getting the following link error:
> 
> undefined reference to '_imp__GetSaveFileNameW@4'

I've tested GetSaveFileNameW sample with native mingw-w64 GCC:
$ cat t.c
#include 

WCHAR szFile[512];
OPENFILENAMEW Ofn;

int main()
{
  Ofn.lStructSize = sizeof(OPENFILENAMEW);
  Ofn.lpstrFile= szFile;
  Ofn.nMaxFile = sizeof(szFile)/ sizeof(*szFile);
  Ofn.Flags = OFN_SHOWHELP | OFN_OVERWRITEPROMPT;
  GetSaveFileNameW(&Ofn);
  return 0;
}
Mateusz@Mateusz-i7 /f/b/ma-gcc/c
$ gcc -Wall -o t.exe t.c
f:/msys/m32-741/bin/../lib/gcc/i686-w64-mingw32/7.4.1/../../../../i686-w64-mingw32/bin/ld.exe:
 C:\Users\Mateusz\AppData\Local\Temp\cc290RXt.o:t.c:(.text+0x46): undefined 
reference to `_imp__GetSaveFileNameW@4'
collect2.exe: error: ld returned 1 exit status

Mateusz@Mateusz-i7 /f/b/ma-gcc/c
$ gcc -Wall -o t.exe t.c -lcomdlg32

Now it is OK and t.exe works.

Regards,
Mateusz



___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] Linking fails for GetSaveFileName when cross compiling with MinGW

2019-01-08 Thread Maarten Verhage
Hi Bob,

I've little experience with helping other people on this forum. When I have 
a program in which I would need the Windows API. I do include windows.h in 
the source file and have the following list of Windows API libraries on the 
link command line.

-l:libkernel32.a -l:libuser32.a -l:libshell32.a -l:libadvapi32.a\
-l:libws2_32.a -l:liboleaut32.a -l:libimm32.a -l:libwinmm.a -l:libole32.a\
-l:libuuid.a -l:libopengl32.a -l:libole32.a -l:libgdi32.a -l:libcomdlg32.a

I do believe the function GetSaveFileNameW would need other Windows API 
libraries to be able to do it's job. Are you willing to try this?

Kind regards,
Maarten Verhage


- Original Message - 
From: "Sailor Bob via Mingw-w64-public" 

To: 
Cc: "Sailor Bob" 
Sent: Tuesday, January 08, 2019 18:29
Subject: [Mingw-w64-public] Linking fails for GetSaveFileName when cross 
compiling with MinGW


>
> I'm trying to compile a modified version of UniLogger on Ubuntu 18.04 
> using mingw. I'm getting the following link error:
>
> undefined reference to '_imp__GetSaveFileNameW@4'
>
> I found this post on the MinGW mailing list saying one needs to explicitly 
> link to comdlg32 so I tried that also:
>
> i686-w64-mingw32-g++ -municode -o unilogger.exe -lcomdlg32 Source.cpp
>
> But still got the same error, as did the person asking in the post.
>
> https://sourceforge.net/p/mingw-w64/mailman/message/34523082/
>
> He and I both verified the presence of the function in the lib file:
>
> nm /usr/i686-w64-mingw32/lib/libcomdlg32.a
>
> libcomdlg32s00012.o:
>  b .bss
>  d .data
>  T _GetSaveFileNameW@4
> U head_lib32_libcomdlg32_a
>  i .idata$4
>  i .idata$5
>  i .idata$6
>  i .idata$7
>  I imp__GetSaveFileNameW@4
>  t .text
>
> libcomdlg32s00011.o:
>  b .bss
>  d .data
>  T _GetSaveFileNameA@4
> U head_lib32_libcomdlg32_a
>  i .idata$4
>  i .idata$5
>  i .idata$6
>  i .idata$7
>  I imp__GetSaveFileNameA@4
>  t .text
> I'm at a bit of a loss at this point.
> ___
> Mingw-w64-public mailing list
> Mingw-w64-public@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public 



___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] Linking fails for GetSaveFileName when cross compiling with MinGW

2019-01-08 Thread Sailor Bob via Mingw-w64-public


I'm trying to compile a modified version of UniLogger on Ubuntu 18.04 using 
mingw. I'm getting the following link error:

undefined reference to '_imp__GetSaveFileNameW@4'

I found this post on the MinGW mailing list saying one needs to explicitly link 
to comdlg32 so I tried that also:

i686-w64-mingw32-g++ -municode -o unilogger.exe -lcomdlg32 Source.cpp

But still got the same error, as did the person asking in the post.

https://sourceforge.net/p/mingw-w64/mailman/message/34523082/

He and I both verified the presence of the function in the lib file:

nm /usr/i686-w64-mingw32/lib/libcomdlg32.a

libcomdlg32s00012.o:
 b .bss
 d .data
 T _GetSaveFileNameW@4
 U head_lib32_libcomdlg32_a
 i .idata$4
 i .idata$5
 i .idata$6
 i .idata$7
 I imp__GetSaveFileNameW@4
 t .text

libcomdlg32s00011.o:
 b .bss
 d .data
 T _GetSaveFileNameA@4
 U head_lib32_libcomdlg32_a
 i .idata$4
 i .idata$5
 i .idata$6
 i .idata$7
 I imp__GetSaveFileNameA@4
 t .text
I'm at a bit of a loss at this point.
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] Add __mingw_access() that works the same for all msvcr*/ucrt libs

2019-01-08 Thread Liu Hao
在 2019/1/8 15:52, Mateusz 写道:

> Thanks for pushing!
> 
> This patch changed mingw-w64-crt/Makefile.am -- can we regenerate makefiles 
> in mingw-w64-crt/ ?
> 

Of course - committed, d72c4fe62568a216d52dca47ca8bace4e220d84f.


-- 
Best regards,
LH_Mouse

___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public