From: Johannes Thoma <johannes@johannesthoma.com>
To: cygwin@cygwin.com
Subject: Re: Question on statically linking with cygwin
Date: Fri, 3 Nov 2023 16:48:50 +0100 [thread overview]
Message-ID: <1a8eae1e-12ff-4a0f-a01a-259f9cdb77bc@johannesthoma.com> (raw)
In-Reply-To: <f4a133f8-2723-4fae-a1ef-f4b73b599ee9@johannesthoma.com>
Hi,
As I promised some updates below.
Am 02.11.23 um 18:33 schrieb Johannes Thoma via Cygwin:
>>>> [...]
>>>> Interesting.
>>>> But how (from a developers perspective) do you link cygwin1.dll
>>>> statically into a binary?
>>>>
>>> I would build my own cygwin1.lib or cygwin1.a and statically link
>>> against it.
>>
>> If you do work out how to do this, patches would be welcome...
>>
> You are right it is far from trivial. I am working on it, not
> sure now if it will be possible or how long it takes (my main
> project is WinDRBD, so unfortunately I cannot spend full time on
> getting static linking work). Right now, I can compile cygwin on my own
> and digged a little bit in the program startup code (lib subdir),
> I will keep you updated once I go along.
>
I can link a simple hello world program (which uses write(2) to
produce output to test the POSIX variant) with something like:
LDFLAGS=-L. -lcygwin-static -lcygserver -lntdll -lkernel32 -lc -lg -lm -lgcc -static -nodefaultlibs
and copiing the newlib libc, libm and other libraries from the
build. The ntdll and kernel32 libs are from a mingw-w64 installation.
the cygwin-static library contains every .o file in the winsup/cygwin
build directory except: lib/libcmain.o and ctype.o (for now had to
patch __set_ctype out of cygwin and take the newlib version, maybe
I can fix that somehow).
Right now it links and produces a (22 Megabytes) EXE binary, however
it crashes in the thread_allocator C++ class (most likely because the
matching constructor is not called before that) this will be the
next thing to fix.
Ok have a great weekend everybody and I will get back once I continue
on the static linking feature.
Best regards,
- Johannes
prev parent reply other threads:[~2023-11-03 15:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-19 15:24 Johannes Thoma
2023-09-22 5:54 ` Martin Wege
2023-09-22 11:12 ` Johannes Thoma
2023-10-16 15:28 ` Jon Turney
2023-11-02 17:33 ` Johannes Thoma
2023-11-03 15:48 ` Johannes Thoma [this message]
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=1a8eae1e-12ff-4a0f-a01a-259f9cdb77bc@johannesthoma.com \
--to=johannes@johannesthoma.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).