On 28 May 2007 14:42, Alain Nguyen wrote: > Hi, > > I am a new CYGWIN user. > > I actually tried to compile and link a C/C++ program using the 'w32api', > more exactly, the '/lib/w32api/libws2_32.a' library, with the following > command: > > $gcc -o myprogram -lws2_32 -c myprogram.c > > But, I always got the error messages from the 'ld' linker dynamic, such as:
No you don't, not with that command, because the -c tells gcc not to invoke the linker. You would in fact get the error message "gcc: -lws2_32: linker input file unused because linking not done". > > - "Undefined reference to '[EMAIL PROTECTED]'" > - "Undefined reference to '[EMAIL PROTECTED]'" > - "Undefined reference to '[EMAIL PROTECTED]'" > - "Undefined reference to '[EMAIL PROTECTED]'" > - "Undefined reference to '[EMAIL PROTECTED]'" > - etc... > > "collect2: ld returned 1 exit status" > > This means that the linker dynamic 'ld' is unable to find and open the > corresponding 'libws2_32.a' library file. Nope, it means it opens it, reads any functions out of it that are already required by earlier inputs, closes it, then opens your program file and fails to link. Ordering of linker inputs is significant, dependencies must come after the things that depend on them and generally this means that libs should always come last. Try gcc -o myprogram myprogram.c -lws2_32 cheers, DaveK -- Can't think of a witty .sigline today.... -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/