delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/05/28/10:00:32

X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: "Alain Nguyen" <alain DOT nguyen1 AT club-internet DOT fr>
Subject: Problem of compiling and linking the C/C++ program using WIN32API with GCC
Date: Mon, 28 May 2007 15:41:46 +0200
Lines: 43
Message-ID: <f3elpi$hlg$1@sea.gmane.org>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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:

    -         "Undefined reference to 'WSAcleanup AT 0'"
    -         "Undefined reference to 'WSAstartup AT 8'"
    -         "Undefined reference to '_inet_addr AT 4'"
    -         "Undefined reference to '_socket AT 12'"
    -         "Undefined reference to '_connect AT 12'"
    -         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.

I've also tried several other solutions, such as:

            $ gcc  -o myprogram   -L  /usr/lib   -lws2_32   -c myprogram.c

            or

            $ gcc  -o myprogram    -l /usr/lib/w32api/libws2_32.a   -c
myprogram.c

With these solutions, I've got the error message from 'ld' like this:

    "Cannot find the -l/usr/lib/w32api/libws2_32.a"
    "collect2: ld returned 1 exit status"

Someone can help me to resolve this problem

Thanks,




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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019