[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Why configure failed to search libws2_32.a in MinGW+MSYS ?
From: |
Guo Leaveye |
Subject: |
Why configure failed to search libws2_32.a in MinGW+MSYS ? |
Date: |
Fri, 27 Dec 2013 16:58:27 +0800 |
I am porting a library and some utils from linux to windows.
My build PC is a Windows 7, with MSYS+MinGW installed in both D:\MinGW (first
choice) and C:\MinGW (installer default).
Given a short WinSock program source _testlib.c_ here:
/* testlib.c */
#include <stdio.h>
#include <windows.h>
#include <winsock2.h>
int main( void ) {
printf( "%d\n", WSAGetLastError() );
return 0;
}
Directly compile of the testlib.c goes just fine. So I think the MSYS+MinGW
works well. To simulate the autotools' progress, I tried that compile to
testlib.o and then link the execution. It works too.
$ gcc -c -o testlib.o testlib.c && gcc -o out testlib.o -lws2_32 && ls -l
out*
-rwxr-xr-x 1 Administrator Administrators 48899 Dec 27 16:27 out.exe
After that, I turn it into autotools:
# configure.ac
AC_PREREQ([2.61])
AC_INIT([testlib], [0.0.0], [<address@hidden>])
AM_INIT_AUTOMAKE([-Wall foreign])
AC_PROG_CC
AC_CHECK_LIB([ws2_32], [WSAGetLastError])
AC_CHECK_LIB([libws2_32], [WSAGetLastError])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
# Makefile.am
noinst_PROGRAMS = out
out_SOURCES = testlib.c
Note that, in the configure.ac file, I check both ws2_32 and libws2_32 to
confirm the library file name rules.
After first `autoconf' failure, my `autoreconf -i' succeed, and the
`./configure' reports:
> checking for a BSD-compatible install... /bin/install -c
> checking whether build environment is sane... yes
> checking for a thread-safe mkdir -p... /bin/mkdir -p
> checking for gawk... gawk
> checking whether make sets $(MAKE)... yes
> checking for gcc... gcc
> checking whether the C compiler works... yes
> checking for C compiler default output file name... a.exe
> checking for suffix of executables... .exe
> checking whether we are cross compiling... no
> checking for suffix of object files... o
> checking whether we are using the GNU C compiler... yes
> checking whether gcc accepts -g... yes
> checking for gcc option to accept ISO C89... none needed
> checking for style of include used by make... GNU
> checking dependency style of gcc... gcc3
> checking for WSAGetLastError in -lws2_32... no
> checking for WSAGetLastError in -llibws2_32... no
> configure: creating ./config.status
> config.status: creating Makefile
> config.status: executing depfiles commands
Note that, (1) both library libws2_32.a check report `no', and (2) the compiler
is exactly my simulation target `gcc'.
I know that I can add a check into configure.ac to examine whether building in
mingw or cygwin, but is this checking supposed to be fully examination for the
real build environment ? If it works fine, LIB variable should be full filled
with all required library link options. If there a simple way by adjust my
MSYS+MinGW environment to make autoconf works, please tell me.
Regards.
Levi G.
Haskell is a beautiful language.
signature.asc
Description: Message signed with OpenPGP using GPGMail
- Why configure failed to search libws2_32.a in MinGW+MSYS ?,
Guo Leaveye <=