Re: Why configure failed to search libws2_32.a in MinGW+MSYS ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have found the answer, and another question still here.

I have tried `gcc -E' (only preprocessed) on the #include version, and checked the output source to view the WSAGetLastError()'s declaration. Then I know this is a conflict between cdecl and stddecl.

As google says (http://lists.gnu.org/archive/html/autoconf/2006-01/msg00109.html), there is no standard macro to handle the stddecl checking.

So before a set of stddecl-checking macros creates, to check the build envionment may be the easiest way to check the libraries' existance.

And the question is that, is there any open sourced 3rd-party macros to handle this ?

Levi G.
Haskell is a beautiful language.

在 2013/12/28,下午12:15,Guo Leaveye <leaveye.guo@xxxxxxxxx> 写道:

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

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux