Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statically link MSVC binaries #8

Open
BobVul opened this issue Dec 2, 2014 · 4 comments
Open

Statically link MSVC binaries #8

BobVul opened this issue Dec 2, 2014 · 4 comments
Assignees
Milestone

Comments

@BobVul
Copy link

BobVul commented Dec 2, 2014

Currently, building with MSVC creates a dependency on MSVCRT.DLL (specifically, MSVCP120.DLL when built with VS2013). This is not necessarily available on all systems.

Changing the /MD option to /MT will build statically-linked binaries, which are far more portable. The cost is an increase of file size from ~25 kB to ~400 kB (unpacked).

Reference:

http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
http://stackoverflow.com/a/37402

@alecmev alecmev added this to the 1.3.0 milestone Dec 2, 2014
@alecmev alecmev self-assigned this Dec 2, 2014
@alecmev
Copy link
Owner

alecmev commented Dec 2, 2014

I think I'll provide the static binary by default, but will give an option to download the shared one too.

@aplocher
Copy link

How much does this affect the size? I ran into this issue the other day when trying one of our internal bat files on a fresh VM. If it's significant in size, I think providing both would be great - as you already stated =)

@BobVul
Copy link
Author

BobVul commented Apr 17, 2015

@aplocher As mentioned in the original post, it's about 12x size difference, 25 kB vs 400 kB, though packing could reduce this somewhat. Since you can't really depend on the redist existing, using the dynamically-linked binary is quite risky if you ever plan to use it outside an environment you control, and potentially annoying even when you do have control.

You can actually get coloured output with PowerShell Write-Host too, and it comes default in Vista and newer. So you can call powershell -c Write-Host -F Green Hello World, for example. Or write the entire script in PS (I ended up transferring most of our scripts across, so we don't have to include an additional binary at all... and PS is much nicer to work with than cmd/batch).

@aplocher
Copy link

Sorry, duh lol, I must have skimmed (or skipped) the end of the original post.

I've been doing more of my complex scripts in powershell, but I find it a fun challenge to see how ridiculously complicated I can make a bat file. CmdColor.exe has been in my toolbag for a while now as far as colorization goes, I only just recently realized it had deps on MSVCRT. I wonder what it would take to remove that dependency completely? I'm sure cmdcolor is using a very small piece of that giant DLL.

I like your powershell approach, I do some hybrid powershell or sometimes VBS stuff in my bat files, so it wouldn't be adding any new dependencies that i don't already have - I'll look further into implementing that. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants