[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why configure failed to search libws2_32.a in MinGW+MSYS ?
From: |
Guo Leaveye |
Subject: |
Re: Why configure failed to search libws2_32.a in MinGW+MSYS ? |
Date: |
Sat, 28 Dec 2013 12:15:26 +0800 |
Thanks a lot for your tip.
Acoording to the log file, it just compiles a source code like this, I only
keep the lines matters.
char WSAGetLastError ();
int
main ()
{
return WSAGetLastError ();
}
When compiling this simple source, GCC reports a error that "undefined
reference to `WSAGetLastError'", even though there is a linker option
"-lws2_32". I tried to replace the declaration of WSAGetLastError() with
includes of windows.h and winsock2.h, then it works. I have no idea on this
behaviour, that why linking the same library leads different result. Is there
any advice ?
BTW, here is the error output by GCC with option "-v".
> $ gcc -o out.exe -g -O2 testlib.c -lws2_32 -v
> specs
> COLLECT_GCC=D:\MinGW\bin\gcc.exe
> COLLECT_LTO_WRAPPER=d:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe
> mingw32
> ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++
> --disable-sjlj-exceptions -
> -with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry
> --enable-libstdcxx-debug --en
> able-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
> win32
> gcc 4.6.2 (GCC)
> COLLECT_GCC_OPTIONS='-o' 'out.exe' '-g' '-O2' '-v' '-mtune=i386' '-march=i386'
> d:/mingw/bin/../libexec/gcc/mingw32/4.6.2/cc1.exe -quiet -v -iprefix
> d:\mingw\bin\../lib/gcc/mingw3
> 2/4.6.2/ testlib.c -quiet -dumpbase testlib.c -mtune=i386 -march=i386
> -auxbase testlib -g -O2 -versi
> on -o C:\Users\ADMINI~1\AppData\Local\Temp\cc6Urmwg.s
> GNU C (GCC) 4.6.2 (mingw32)
> GNU C 4.6.2 GMP 5.0.1MPFR 2.4.1MPC 0.8.1
> GGC --param ggc-min-expand=100 --param ggc-min-heapsize=131072
> d:\mingw\bin\../lib/gcc/mingw32/4.6.2/../../../../mingw32/include
> d:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.2/include
> /mingw/lib/gcc/mingw32/4.6.2/../../../../include
> d:/mingw/lib/gcc/../../include
> d:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.2/include-fixed
> d:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.2/../../../../mingw32/include
> /mingw/include
> #include "..."
> #include <...>
> d:\mingw\bin\../lib/gcc/mingw32/4.6.2/include
> d:\mingw\bin\../lib/gcc/mingw32/4.6.2/../../../../include
> d:\mingw\bin\../lib/gcc/mingw32/4.6.2/include-fixed
>
> GNU C (GCC) 4.6.2 (mingw32)
> GNU C 4.6.2 GMP 5.0.1MPFR 2.4.1MPC 0.8.1
> GGC --param ggc-min-expand=100 --param ggc-min-heapsize=131072
> Compiler executable checksum: c20aed7c018482d7b62efcd5dcab2a9d
> COLLECT_GCC_OPTIONS='-o' 'out.exe' '-g' '-O2' '-v' '-mtune=i386' '-march=i386'
> d:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/as.exe -o
> C:\Users\ADMINI~1\AppData\L
> ocal\Temp\ccFvAZop.o C:\Users\ADMINI~1\AppData\Local\Temp\cc6Urmwg.s
> COMPILER_PATH=d:/mingw/bin/../libexec/gcc/mingw32/4.6.2/;d:/mingw/bin/../libexec/gcc/;d:/mingw/bin/.
> ./lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/
> LIBRARY_PATH=d:/mingw/bin/../lib/gcc/mingw32/4.6.2/;d:/mingw/bin/../lib/gcc/;d:/mingw/bin/../lib/gcc
> /mingw32/4.6.2/../../../../mingw32/lib/;d:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../;/mingw/lib/
> COLLECT_GCC_OPTIONS='-o' 'out.exe' '-g' '-O2' '-v' '-mtune=i386' '-march=i386'
> d:/mingw/bin/../libexec/gcc/mingw32/4.6.2/collect2.exe -Bdynamic -o out.exe
> d:/mingw/bin/../lib/gcc
> /mingw32/4.6.2/../../../crt2.o
> d:/mingw/bin/../lib/gcc/mingw32/4.6.2/crtbegin.o -Ld:/mingw/bin/../li
> b/gcc/mingw32/4.6.2 -Ld:/mingw/bin/../lib/gcc
> -Ld:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mi
> ngw32/lib -Ld:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../.. -L/mingw/lib
> C:\Users\ADMINI~1\AppData\Lo
> cal\Temp\ccFvAZop.o -lws2_32 -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex
> -lmsvcrt -ladvapi32 -lshe
> ll32 -luser32 -lkernel32 -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex
> -lmsvcrt d:/mingw/bin/../lib/
> gcc/mingw32/4.6.2/crtend.o
> C:\Users\ADMINI~1\AppData\Local\Temp\ccFvAZop.o: In function `main':
> d:\Projects\libisl\build/testlib.c:22: undefined reference to
> `WSAGetLastError'
> collect2: ld 1
Regards.
Levi G.
Haskell is a beautiful language.
在 2013/12/28,上午7:18,Bob Friesenhahn <address@hidden> 写道:
> Look in the generated config.log for the errors produced while testing for
> WSAGetLastError. The errors may provide a clue as to what has actually gone
> wrong and lead to fixing the problem. Autoconf tests for library functions
> by linking a small test program. Sometimes it is necessary to supply
> additional libraries in order to successfully link with a library.
>
> Bob
> --
> Bob Friesenhahn
> address@hidden, http://www.simplesystems.org/users/bfriesen/
> GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
signature.asc
Description: Message signed with OpenPGP using GPGMail