From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.9]) by sourceware.org (Postfix) with ESMTPS id D514A383301D for ; Fri, 18 Dec 2020 05:29:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D514A383301D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=SystematicSw.ab.ca Authentication-Results: sourceware.org; spf=none smtp.mailfrom=brian.inglis@systematicsw.ab.ca Received: from [192.168.1.104] ([24.64.172.44]) by shaw.ca with ESMTP id q8KakWMOMtdldq8KbkV0Th; Thu, 17 Dec 2020 22:29:33 -0700 X-Authority-Analysis: v=2.4 cv=INe8tijG c=1 sm=1 tr=0 ts=5fdc3e3d a=kiZT5GMN3KAWqtYcXc+/4Q==:117 a=kiZT5GMN3KAWqtYcXc+/4Q==:17 a=IkcTkHD0fZMA:10 a=uYT-Tk0qkVT609LjNaIA:9 a=QEXdDO2ut3YA:10 Reply-To: cygwin@cygwin.com To: cygwin@cygwin.com References: From: Brian Inglis Organization: Systematic Software Subject: Re: why does i686-w64-mingw32-gcc -static fail? Message-ID: <73846a6f-a908-f135-69ec-bc1eeb5b145c@SystematicSw.ab.ca> Date: Thu, 17 Dec 2020 22:29:32 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-CA Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4xfL33g95ZEdhh+OU5SMUdxjW12uC+2Xj62zzY/6G3tfRjyRyG9oB0sdGTVcO05Xa9eKxiqMzSkfHMhy8td+HUksrCIdkGF7ASMLx2MzONdOIjDorGekXI 6M10x+pxhCJvzGzufG+aye/M9SUG8Q0BKZkM1LcPjaax2MfIYS4pJs+Cdv4FhdjRDXJ7MAEc335Sadh/8Y/OTXZjZ0IP+g7pl+k= X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no 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: Fri, 18 Dec 2020 05:29:56 -0000 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: usr/i686-w64-mingw32/sys-root/mingw/bin/libpcre-1.dll usr/i686-w64-mingw32/sys-root/mingw/bin/libpcre16-0.dll usr/i686-w64-mingw32/sys-root/mingw/bin/libpcre32-0.dll usr/i686-w64-mingw32/sys-root/mingw/bin/libpcrecpp-0.dll usr/i686-w64-mingw32/sys-root/mingw/bin/libpcreposix-0.dll usr/i686-w64-mingw32/sys-root/mingw/lib/libpcre.dll.a usr/i686-w64-mingw32/sys-root/mingw/lib/libpcre16.dll.a usr/i686-w64-mingw32/sys-root/mingw/lib/libpcre32.dll.a usr/i686-w64-mingw32/sys-root/mingw/lib/libpcrecpp.dll.a usr/i686-w64-mingw32/sys-root/mingw/lib/libpcreposix.dll.a 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. -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada This email may be disturbing to some readers as it contains too much technical detail. Reader discretion is advised. [Data in binary units and prefixes, physical quantities in SI.]