From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65962 invoked by alias); 20 Oct 2019 09:40:22 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 65950 invoked by uid 89); 20 Oct 2019 09:40:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=listing, Csaba, mix, Raduly X-HELO: mout.kundenserver.de Received: from mout.kundenserver.de (HELO mout.kundenserver.de) (212.227.17.13) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 20 Oct 2019 09:40:20 +0000 Received: from [192.168.178.45] ([95.91.209.166]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M6VNX-1iObbl2e2D-006sIa for ; Sun, 20 Oct 2019 11:40:16 +0200 Subject: Re: How does linker choose library with same function export? To: cygwin@cygwin.com References: From: Thomas Wolff Message-ID: <9ac21380-a1d0-901b-81ae-5336ba240518@towo.net> Date: Sun, 20 Oct 2019 09:40:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00115.txt.bz2 Am 20.10.2019 um 11:15 schrieb Csaba Raduly: > Hi, > > On Sat, Oct 19, 2019 at 2:57 PM Biswapriyo Nath wrote: >> I want to use socket() from ws2_32.dll file. But cygwin1.dll also has that >> export. When I use `-lws2_32` option, will gcc **always** choose >> ws2_32.lib? My query is somewhat similar with FAQ #5.11. > I think the FAQ is pretty clear: > > "5.11. > > I don't want Unix sockets, how do I use normal Win32 winsock? > > You don't. " I guess that should read "You don't, normally." There may be reasons to look for special, Windows-supplied functionality variations, e.g. when interfacing to Windows (likely WSL, in this case). Without the possibility to use a mix of POSIX and Windows APIs, the Cygwin Terminal (mintty) wouldn't exist. For dedicated linking, I think the order of listing the libraries in the link command is essential. If in doubt, you could also try to load the function dynamically from the desired library (using GetProcAddress for the Windows API or dlsym for POSIX). Thomas > You shouldn't look at Cygwin programs as if they were Windows programs. > Cygwin is a POSIX environment. > You either create a Cygwin program and use the POSIX functions, > or you create a Windows program (you can cross-compile Windows programs > under Cygwin). > Mixing the two is likely to run into problems, and you aren't going to > get much help > when you were told "don't do it" at the very beginning. > > Csaba -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple