libassuan-config and libassuan.pc both put -lws2_32 before -lgpg-error, which fails during static linking
Open, LowPublic

Description

(this is similar to T4623, but for libassuan, and just about library ordering instead of library omission)

I'm building a sample program (on debian unstable) for 64-bit windows with the following comand:

x86_64-w64-mingw32-gcc -pedantic -Wall -Werror -o test-run.exe -static simple-build.c $(pkg-config --static --cflags --libs libassuan)

the pkg-config invocation yields:

-I/usr/x86_64-w64-mingw32/include -L/usr/x86_64-w64-mingw32/lib -lassuan -lws2_32 -lgpg-error

However, when the compilation happens, i get this error:

/usr/bin/x86_64-w64-mingw32-ld: /usr/x86_64-w64-mingw32/lib/libgpg-error.a(libgpg_error_la-logging.o): in function `fun_writer':
./build-x86_64-w64-mingw32/src/../../src/logging.c:358: undefined reference to `__imp_inet_addr'
collect2: error: ld returned 1 exit status

I note that the error goes away if i reverse the order of -lws2_32 and -lgpg-error, that is:

-lgpg-error -lws2_32

is good, but this one:

-lws2_32 -lgpg-error

is not good.

I'm using linker and compiler from version 8.3-win32 of gcc.

Details

Version
2.5.3
dkg created this task.Jul 15 2019, 6:36 AM
werner triaged this task as Low priority.Jul 15 2019, 8:09 AM