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


(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.

dkg created this task.Jul 15 2019, 6:36 AM
werner triaged this task as Low priority.Jul 15 2019, 8:09 AM
gniibe claimed this task.Feb 18 2020, 8:17 AM
gniibe changed the task status from Open to Testing.
gniibe added a subscriber: gniibe.

With the fix of T4623, this bug is now fixed.

Now, the invocation of pkg-config yields:

-I/usr/x86_64-w64-mingw32/include -L/usr/x86_64-w64-mingw32/lib -lassuan -lws2_32 -lgpg-error -lws2_32
gniibe added a comment.EditedJul 16 2020, 3:11 AM

This fix reveals the problem of: T4994: Windows: assuan_sock_init or WSAStartup by main/_init_common_subsystem

So, until T4994 will be fixed, you need to edit your Makefiles of GnuPG manually adding -lws2_32.