X-Recipient: archive-cygwin AT delorie DOT com X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com 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 DOT inglis AT systematicsw DOT ab DOT ca 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 To: cygwin AT cygwin DOT 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-Language: en-CA 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 AT cygwin DOT 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: , Reply-To: cygwin AT cygwin DOT com Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: cygwin-bounces AT cygwin DOT com Sender: "Cygwin" 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.] -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple