pgbouncer 1.7.0 fails to cross-compile with mingw-w64 #100

Closed
tkren opened this Issue Jan 5, 2016 · 12 comments

Comments

Projects
None yet
4 participants
@tkren

tkren commented Jan 5, 2016

Cross-compiling pgbouncer 1.7.0 fails with the following setup:

  • Debian jessie installation of mingw-w64 3.2.0-2
  • libevent 2.0.22 cross-compiled to $HOME/mingw64
  • openssl 1.0.1g cross-compiled to $HOME/mingw64

After configuring pgbouncer with

./configure --host=x86_64-w64-mingw32 --enable-evdns --disable-debug --with-libevent=$HOME/mingw64 --with-openssl=$HOME/mingw64

make fails with

[...]
CC       lib/usual/tls/tls_server.c
In file included from lib/usual/tls/tls_server.c:27:0:
lib/usual/tls/tls_internal.h:22:23: fatal error: arpa/inet.h: No such file or directory
#include <arpa/inet.h>
                      ^
compilation terminated.
/tmp/pgbouncer-1.7/lib/mk/antimake.mk:1222: recipe for target '.objs/pgbouncer/lib/usual/tls/tls_server.o' failed
make: *** [.objs/pgbouncer/lib/usual/tls/tls_server.o] Error 1
@chenz

This comment has been minimized.

Show comment
Hide comment
@chenz

chenz Jan 19, 2016

The issue is with libusual. I hacked together a quick and dirty patch to get it to compile, seems to work ok so far. I also had to set LDFLAGS =-mwindows to avoid linker errors.

usual.patch.txt

chenz commented Jan 19, 2016

The issue is with libusual. I hacked together a quick and dirty patch to get it to compile, seems to work ok so far. I also had to set LDFLAGS =-mwindows to avoid linker errors.

usual.patch.txt

@tkren

This comment has been minimized.

Show comment
Hide comment
@tkren

tkren Jan 20, 2016

the patch fixes the arpa/inet.h problem, but it seems that there is still something missing:

[...]
     CC       lib/usual/tls/tls_client.c
lib/usual/tls/tls_client.c: In function ‘tls_connect_servername’:
lib/usual/tls/tls_client.c:110:21: error: ‘AI_ADDRCONFIG’ undeclared (first use in this function)
    hints.ai_flags = AI_ADDRCONFIG;
                     ^

tkren commented Jan 20, 2016

the patch fixes the arpa/inet.h problem, but it seems that there is still something missing:

[...]
     CC       lib/usual/tls/tls_client.c
lib/usual/tls/tls_client.c: In function ‘tls_connect_servername’:
lib/usual/tls/tls_client.c:110:21: error: ‘AI_ADDRCONFIG’ undeclared (first use in this function)
    hints.ai_flags = AI_ADDRCONFIG;
                     ^
@chenz

This comment has been minimized.

Show comment
Hide comment
@chenz

chenz Jan 20, 2016

Ah yes, I forgot - for AI_ADDRCONFIG to be defined, the Windows API version must be set to "Vista".

env LDFLAGS=-mwindows CPPFLAGS=-D_WIN32_WINNT=0x0600 ./configure --prefix=... --host=x86_64-w64-mingw32 --with-libevent=... --with-openssl=...

chenz commented Jan 20, 2016

Ah yes, I forgot - for AI_ADDRCONFIG to be defined, the Windows API version must be set to "Vista".

env LDFLAGS=-mwindows CPPFLAGS=-D_WIN32_WINNT=0x0600 ./configure --prefix=... --host=x86_64-w64-mingw32 --with-libevent=... --with-openssl=...
@tkren

This comment has been minimized.

Show comment
Hide comment
@tkren

tkren Jan 20, 2016

thank you for your help, this seems to work.

tkren commented Jan 20, 2016

thank you for your help, this seems to work.

@tkren tkren closed this Jan 20, 2016

@chenz chenz referenced this issue in libusual/libusual Jan 20, 2016

Merged

TLS mingw64 compile fixes #12

@murali05

This comment has been minimized.

Show comment
Hide comment
@murali05

murali05 Feb 5, 2016

Hi,
I'm trying to build pgbouncer-1.7 on Windows server 2012 R2 with MINGW 32. I have faced the same issue " fatal error: arpa/inet.h: No such file or directory " as like mentioned in before thread. After applied your patch "usual.patch.txt", this issue seems to resolved.

Later I got the below make error even though configure pgbounce as like below
LDFLAGS=-mwindows CPPFLAGS=-D_WIN32_WINNT=0x0600 ./configure --prefix=... --with-libevent=... --with-openssl=...set to

lib/usual/tls/tls_client.c: In function tls_connect_servername': lib/usual/tls/tls_client.c:110: error:AI_ADDRCONFIG' undeclared (first use in this function)
lib/usual/tls/tls_client.c:110: error: (Each undeclared identifier is reported only once
lib/usual/tls/tls_client.c:110: error: for each function it appears in.)
make: *** [.objs/pgbouncer/lib/usual/tls/tls_client.o] Error 1

Can you please advice , how we can resolve this issue.

murali05 commented Feb 5, 2016

Hi,
I'm trying to build pgbouncer-1.7 on Windows server 2012 R2 with MINGW 32. I have faced the same issue " fatal error: arpa/inet.h: No such file or directory " as like mentioned in before thread. After applied your patch "usual.patch.txt", this issue seems to resolved.

Later I got the below make error even though configure pgbounce as like below
LDFLAGS=-mwindows CPPFLAGS=-D_WIN32_WINNT=0x0600 ./configure --prefix=... --with-libevent=... --with-openssl=...set to

lib/usual/tls/tls_client.c: In function tls_connect_servername': lib/usual/tls/tls_client.c:110: error:AI_ADDRCONFIG' undeclared (first use in this function)
lib/usual/tls/tls_client.c:110: error: (Each undeclared identifier is reported only once
lib/usual/tls/tls_client.c:110: error: for each function it appears in.)
make: *** [.objs/pgbouncer/lib/usual/tls/tls_client.o] Error 1

Can you please advice , how we can resolve this issue.

@chenz

This comment has been minimized.

Show comment
Hide comment
@chenz

chenz Feb 5, 2016

Maybe an issue with the shell? Maybe try setting the environment variables separately

set LDFLAGS=...
set CPPFLAGS=...
./configure ...

chenz commented Feb 5, 2016

Maybe an issue with the shell? Maybe try setting the environment variables separately

set LDFLAGS=...
set CPPFLAGS=...
./configure ...
@murali05

This comment has been minimized.

Show comment
Hide comment
@murali05

murali05 Feb 12, 2016

Hi,

Thanks for your response. To fix the above error , I had to define AI_ADDRCONFIG in my Mingw installation header file ( MinGW/include/ws2tcpip.h ). But after this I got again below build error.

objs/pgbouncer/lib/usual/string.o: In function usual_strpcat': pgbouncer/lib/usual/string.c:233: undefined reference tostrnlen'
.objs/pgbouncer/lib/usual/time.o: In function usual_timegm': pgbouncer/lib/usual/time.c:187: undefined reference to_mkgmtime'
collect2: ld returned 1 exit status
make: *** [pgbouncer.exe] Error 1

So here I tried to search for strnlen keyword in my Mingw header files but I didn't get any such keyword. At the same time I can found strlen but not strnlen. That means strnlen is not supported by MinGW version 3.14 .

Can you please suggest me how can I over come above issue.

Hi,

Thanks for your response. To fix the above error , I had to define AI_ADDRCONFIG in my Mingw installation header file ( MinGW/include/ws2tcpip.h ). But after this I got again below build error.

objs/pgbouncer/lib/usual/string.o: In function usual_strpcat': pgbouncer/lib/usual/string.c:233: undefined reference tostrnlen'
.objs/pgbouncer/lib/usual/time.o: In function usual_timegm': pgbouncer/lib/usual/time.c:187: undefined reference to_mkgmtime'
collect2: ld returned 1 exit status
make: *** [pgbouncer.exe] Error 1

So here I tried to search for strnlen keyword in my Mingw header files but I didn't get any such keyword. At the same time I can found strlen but not strnlen. That means strnlen is not supported by MinGW version 3.14 .

Can you please suggest me how can I over come above issue.

@markokr markokr reopened this Feb 12, 2016

@markokr

This comment has been minimized.

Show comment
Hide comment
@markokr

markokr Feb 12, 2016

Contributor

Current master seems to build for me with mingw-w64-dev 2.0.1-1 and configured with

LIBS="-lgdi32" \
./configure --host=x86_64-w64-mingw32 \
  --without-cares \
  --with-libevent=/opt/apps/win64 \
  --with-openssl=/opt/apps/win64 \
  --enable-evdns

-lgdi is because of static openssl.

So problems with _mkgmtime and strnlen are caused by something else.

Contributor

markokr commented Feb 12, 2016

Current master seems to build for me with mingw-w64-dev 2.0.1-1 and configured with

LIBS="-lgdi32" \
./configure --host=x86_64-w64-mingw32 \
  --without-cares \
  --with-libevent=/opt/apps/win64 \
  --with-openssl=/opt/apps/win64 \
  --enable-evdns

-lgdi is because of static openssl.

So problems with _mkgmtime and strnlen are caused by something else.

@murali05

This comment has been minimized.

Show comment
Hide comment
@murali05

murali05 Feb 15, 2016

Hi,
Can you please grep for stnlen() in your MInGW installation header files and let me know resulted files.I found the thread related to strnlen is not included in the official builds of MinGW. https://sourceforge.net/p/mingw/bugs/1912/

Hi,
Can you please grep for stnlen() in your MInGW installation header files and let me know resulted files.I found the thread related to strnlen is not included in the official builds of MinGW. https://sourceforge.net/p/mingw/bugs/1912/

@markokr

This comment has been minimized.

Show comment
Hide comment
@markokr

markokr Feb 15, 2016

Contributor

Actually, configure already checks for strnlen and libusual should replace it if not found. So it seems in your case configure did find it but linker does not...

Do you have HAVE_STRNLEN defined in your config.h?

Contributor

markokr commented Feb 15, 2016

Actually, configure already checks for strnlen and libusual should replace it if not found. So it seems in your case configure did find it but linker does not...

Do you have HAVE_STRNLEN defined in your config.h?

@chenz

This comment has been minimized.

Show comment
Hide comment
@chenz

chenz Feb 15, 2016

It seems this and the missing AI_ADDRCONFIG definition is due to murali05 using (obsolete?) mingw32, whereas everyone else here uses mingw-w64.

chenz commented Feb 15, 2016

It seems this and the missing AI_ADDRCONFIG definition is due to murali05 using (obsolete?) mingw32, whereas everyone else here uses mingw-w64.

@markokr

This comment has been minimized.

Show comment
Hide comment
@markokr

markokr Feb 17, 2016

Contributor

Closing. Compiles-for-me.

Contributor

markokr commented Feb 17, 2016

Closing. Compiles-for-me.

@markokr markokr closed this Feb 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment