Page MenuHome GnuPG

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

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

Revisions and Commits

Event Timeline

gniibe changed the task status from Open to Testing.Feb 18 2020, 8:17 AM
gniibe claimed this task.
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

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.