On 12/19/2020 2:37 AM, Lee via Cygwin wrote:
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/

The maintainer has retired from Cygwin package maintenance, so it's not likely to be updated until someone volunteers to take over.

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

No, it's intentional. cygport itself supplies "--disable-static". See /usr/share/cygport/cygclass/autotools.cygclass:715:

  confargs+=" --enable-shared --disable-static"

The cygport user (i.e., the package maintainer) would have to add "--enable-static" to override this.

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

Reply via email to