public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: J <progman3k@gmail.com>
To: cygwin@cygwin.com
Subject: Link error with static version of zlib?
Date: Wed, 19 Jul 2017 15:47:00 -0000	[thread overview]
Message-ID: <CAM9TqJ75_0nyEn-2bpGUP90rJCD3bUmZKEj_6+fRh77jtkDSxQ@mail.gmail.com> (raw)

Hello,

I am trying to produce an executable using mingw that uses all-static
linking, that is, that it does not rely on any DLLs except possibly
the Microsoft msvcrt.dll

Is it possible?

If I am not mistaken, when selecting the package mingw64-x86_64-zlib
with the installer, it installs the library, which has been compiled
as both a DLL and a static library.

But it appears that the minizip library included within the zlib
package is only present in DLL form.

When building, I get the following

make
x86_64-w64-mingw32-g++ -O2 -fno-strength-reduce -O2
-fno-strength-reduce -g
-I/usr/x86_64-w64-mingw32/sys-root/mingw/include/     -DDEBUG -D_WIN32
 -std=c++11   -c -o main.o main.cpp
x86_64-w64-mingw32-g++ -o app.exe -O2 -fno-strength-reduce -g -Wall
-Wpointer-arith -L/usr/lib main.o -mwindows -static -lws2_32 -lgdi32
-lcomctl32 -lcomdlg32 -lminizip -lz
-Wl,--enable-auto-import,--enable-runtime-pseudo-reloc
/usr/lib/gcc/x86_64-w64-mingw32/5.4.0/../../../../x86_64-w64-mingw32/bin/ld:
cannot find -lminizip
collect2: error: ld returned 1 exit status


But yet, when I build the with the exact same command on linux, I get
an executable and it depends only on msvcrt.dll (and comctl32.dll,
comdlg32.dll, kernel32.dll, user32.dll and ws2_32.dll, obviously).

If I modify the link line to instead link -lminizip.dll, I get the
following errors

/usr/lib/libpthread.a(t-d001060.o):fake:(.text+0x2): undefined
reference to `__imp_pthread_getspecific'
/usr/lib/libpthread.a(t-d001062.o):fake:(.text+0x2): undefined
reference to `__imp_pthread_key_create'
/usr/lib/libpthread.a(t-d001063.o):fake:(.text+0x2): undefined
reference to `__imp_pthread_key_delete'
/usr/lib/libpthread.a(t-d001065.o):fake:(.text+0x2): undefined
reference to `__imp_pthread_mutex_destroy'
/usr/lib/libpthread.a(t-d001067.o):fake:(.text+0x2): undefined
reference to `__imp_pthread_mutex_init'
/usr/lib/libpthread.a(t-d001068.o):fake:(.text+0x2): undefined
reference to `__imp_pthread_mutex_lock'
/usr/lib/libpthread.a(t-d001071.o):fake:(.text+0x2): undefined
reference to `__imp_pthread_mutex_unlock'
/usr/lib/libpthread.a(t-d001101.o):fake:(.text+0x2): undefined
reference to `__imp_pthread_setspecific'
collect2: error: ld returned 1 exit status

Is there a proper way of getting the minizip lib statically-compiled?

Thank you

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

             reply	other threads:[~2017-07-19 15:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-19 15:47 J [this message]
2017-07-20 14:07 ` Steven Penny
2017-07-20 14:16   ` J
2017-07-21  0:32     ` Hans-Bernhard Bröker
2017-07-21 10:11       ` Steven Penny
2017-07-24 23:55         ` J (Jean-Claude Gervais)
2017-07-25 14:42           ` cyg Simple

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAM9TqJ75_0nyEn-2bpGUP90rJCD3bUmZKEj_6+fRh77jtkDSxQ@mail.gmail.com \
    --to=progman3k@gmail.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).