philr/bzip2-windows

any chance to build this dll's without MSVC dependency?

Closed this issue · 5 comments

subj

philr commented

The Microsoft C Runtime Library can be statically linked (and removed as a dependency) by changing the CFLAGS -MD compile option in makefile.msc to -MT.

I've added a patch in a new static_linking branch to make this change (as well as statically linking libbz2 into bzip2.exe).

This statically linked version of the build can be run by checking out the static_linking branch and running Build-Bzip2.ps1 (setting the GitPath and VisualStudioDir parameters appropriately).

I'm not going to publish statically linked binaries. As with any statically linked project, they would need to be re-released to keep up to date with security and bug fixes to the C runtime library.

Actually libbzip2 doesn't need C runtime. z_malloc -> VirtualAlloc etc, there are just 2-3 functions from runtime, all of them can be replaced by direct win32 api access...

philr commented

You're welcome to submit a pull request if you think that eliminating the C runtime altogether would be useful for others.

I'd suggest using HeapAlloc rather than VirtualAlloc as a replacement for malloc though - see https://stackoverflow.com/q/872072/5981 and https://msdn.microsoft.com/en-us/library/windows/desktop/aa366533.aspx.

I'm not going to publish statically linked binaries. As with any statically linked project, they would need to be re-released to keep up to date with security and bug fixes to the C runtime library.

What about just statically linking libbz2? (EXEs still depending on MSVC Runtime)

philr commented

@marcosfrm The unmodified makefile.msc file in the bzip2 source distribution will produce executables that statically link libbz2, but that still dynamically depend on the C runtime. The purpose of this project was to modify the build to produce the libbz2 DLL.

If you download the bzip2 sources (the current version is 1.0.8) and run nmake /f makefile.msc you should get the desired executables.