From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by sourceware.org (Postfix) with ESMTPS id 43A32393D03C for ; Sat, 19 Dec 2020 07:37:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 43A32393D03C Received: by mail-qt1-x82a.google.com with SMTP id z9so3110427qtn.4 for ; Fri, 18 Dec 2020 23:37:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=4qmV84kQLHAjIk9313AwGV4F51keyWHde84zsSyEEXs=; b=isyNS7XnyYjDGQ7fXrLZFexTb/3LXJzASaJ6OMVThP2icHI5JfgXu7+d/IICrt+paT 7PUJKFeP5E0wc5eN6mPP57NlNtFimmQ5twXJ4PruYEYxFJ00r01HMmuj58Xt/NUNUdtt yrWpOHayFvHrYgkWRoV/pN/cs2CeSN8bM+OSev4w5tbDRkg7kOygSk+o3etJOTXjY3Vj zRct5zPRWTKkDB0W0IQjV/KNxQYzQS6fzFpBd4qmOqK8H71/1hmpYVGrZCwQsYedYC4q S0gB4LJlTv2AN+rRPebbKcpgcfyqBBzHCHBrJrhse3BRvdYygJ8/EvABAmgIEiR3kRtk 42oQ== X-Gm-Message-State: AOAM530thcctyVQ/mTlhRJvVl5A13wVPNA8xYbjdTsVkeKBjw5n0nuKZ Bro9RkEv0+SZwGk6xTyJ8TB3I63TMYdogN3x55TLOl0gI90= X-Google-Smtp-Source: ABdhPJwQAsg40XCFOO8AOxnxOG3zP1vznuXBFc9ZpTIrSeVr9oUKyb8vY3FJ1AnLvoK8AEaLL5g8G0kSwbOrduBy/3c= X-Received: by 2002:ac8:71c6:: with SMTP id i6mr7668367qtp.209.1608363441735; Fri, 18 Dec 2020 23:37:21 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a0c:f40f:0:0:0:0:0 with HTTP; Fri, 18 Dec 2020 23:37:21 -0800 (PST) In-Reply-To: <73846a6f-a908-f135-69ec-bc1eeb5b145c@SystematicSw.ab.ca> References: <73846a6f-a908-f135-69ec-bc1eeb5b145c@SystematicSw.ab.ca> From: Lee Date: Sat, 19 Dec 2020 07:37:21 +0000 Message-ID: Subject: Re: why does i686-w64-mingw32-gcc -static fail? To: cygwin@cygwin.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Dec 2020 07:37:23 -0000 On 12/18/20, Brian Inglis wrote: > On 2020-12-17 20:45, Lee via Cygwin wrote: >> Would someone please explain why adding "-static" makes >> i686-w64-mingw32-gcc fail? >> >> This works (or at least the compiler doesn't complain) >> >> $ i686-w64-mingw32-gcc -o a.exe conftest-pcre.c -lpcreposix >> -lpcre >> >> This does not work >> >> $ i686-w64-mingw32-gcc -o a.exe -static conftest-pcre.c -lpcreposix >> -lpcre >> /usr/lib/gcc/i686-w64-mingw32/10/../../../../i686-w64-mingw32/bin/ld: >> cannot find -lpcreposix >> /usr/lib/gcc/i686-w64-mingw32/10/../../../../i686-w64-mingw32/bin/ld: >> cannot find -lpcre >> collect2: error: ld returned 1 exit status >> >> Why does adding "-static" make it fail? > > Because the mingw64-*86*-pcre/2 packages provide only dynamic libraries and > their linkage archives: <.. snip list of libpcre*.dll and .dll.a files ..> > where others provide both dynamic and static libraries e.g. > mingw64-i686-zstd: > > usr/i686-w64-mingw32/sys-root/mingw/bin/libzstd-1.dll > usr/i686-w64-mingw32/sys-root/mingw/lib/libzstd.a > usr/i686-w64-mingw32/sys-root/mingw/lib/libzstd.dll.a > > possibly where the size of useful library members are reasonably small > enough, > and unlikely to need significantly updated, to be statically linked into an > standalone executable or embedded system component, that itself may be > regularly > updated, rather than requiring large chunks of a framework to be linked that > may need regular updates. Thanks for the explanation :) I went looking to see how the mingw pcre package was built and ended up here: https://cygwin.com/git-cygwin-packages/?p=git/cygwin-packages/mingw64-i686-pcre.git;a=summary If that's correct and the latest then it looks to be a bit out of date; the current release is 8.44 https://ftp.pcre.org/pub/pcre/ Looking at the latest cygport info https://cygwin.com/git-cygwin-packages/?p=git/cygwin-packages/mingw64-i686-pcre.git;a=blob;f=mingw64-i686-pcre.cygport;h=7456c41e6c45aad8403303aee413144fcf5d1b58;hb=3200774765aabbdda5cf4e5e9934c3d25e6e7196 and going off the current pcre doc included with the 8.44 tarball: The Autotools PCRE building process uses libtool to build both shared and static libraries by default. You can suppress one of these by adding one of --disable-shared --disable-static to the configure command, as required. The cygport info doesn't have "--disable-static" so maybe not having static libraries wasn't an intentional omission?? Thanks Lee