Skip to content

Latest version of zig request MSVC C++ Redistributable 2019 package and I don't see any docs #3423

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

Closed
marler8997 opened this issue Oct 10, 2019 · 6 comments

Comments

@marler8997
Copy link
Contributor

When I run the latest compiler 0.5.0 or after I now get a missing dll error.

The code execition cannot proceed because
VCRUNTIME140_1.dll was not round.  Reinstalling the program
may fix this problem.

This did not occur on the last version of zig I had installed to this machine which was zig-windows-x86_64-0.4.0+d23798a2. This version was around July 7th 2019.

I'm not sure if zig can statically link in the MSVC runtime libraries. I see a suspicious commit here where it may have been statically linked before but now it no longer is: 357fb4f

In the meantime I've googled and tried to find the MSVC C++ redistributable to install but haven't been able to fix it yet. On this machine I have the following installed:

Microsoft Visual C++ 2010 x64 Redistributable
Microsoft Visual C++ 2012 Redistributable (x64)
Microsoft Visual C++ 2012 Redistributable (x86)
Microsoft Visual C++ 2013 Redistributable (x64)
Microsoft Visual C++ 2013 Redistributable (x86)
Microsoft Visual C++ 2015 Redistributable (x64)
Microsoft Visual C++ 2015 Redistributable (x86)

Even if we can't compile the runtime libraries statically, I feel there should be documentation somewhere that explains where to get these runtime libraries, or the windows binaries should probably use an installer that installs the MSVC C++ Redistributables that it uses.

@marler8997 marler8997 changed the title Windows binaries require VCRUNTIME140_1.dll and I don't know where to get it Latest version of zig request MSVC C++ Redistributable 2019 package and I don't see any docs Oct 10, 2019
@marler8997
Copy link
Contributor Author

marler8997 commented Oct 10, 2019

Ok it looks like I needed the Microsoft Visual C++ 2019 Redistributable (x64). I manually downloaded it from this page:

https://www.itechtics.com/microsoft-visual-c-redistributable-versions-direct-download-links/

The direct download link was:

https://aka.ms/vs/16/release/VC_redist.x64.exe

This installer deployed the missing dlls and now I can run the zig compiler on this machine.

I see these action items:

  1. Can we link to these statically instead?
  2. If we can't compile statically, maybe we should include the libraries in the windows binary zip file?
  3. If this doesn't work, do we need to put the windows binaries in an installer? Or maybe the download link should just contain a note that says you need to install the MSVC package and provide a link to the installer?

@andrewrk
Copy link
Member

It's a really unfortunate regression, might even warrant releasing 5.0.1. thanks for finding that commit. Let's see if we can figure out why it was done in the first place and then see if reverting it makes sense. The exe is supposed to be fully static.

@mikdusan
Copy link
Member

mikdusan commented Oct 10, 2019

some experimentation notes:

ref: https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html#prop_tgt:MSVC_RUNTIME_LIBRARY

  • this feature depends on CMake 15.0 or higher, which for CI is probably not an issue when building with vs2019
  • it also can be set during configuration via -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
  • glaring problem is LLVM libraries, they have to be built in the same manner
  • the key difference is /MD vs /MT for DLL vs. static
  • also /MDd and /MTd exist for debug builds
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5d918f2b1..1efbcfd6c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,8 @@
 cmake_minimum_required(VERSION 2.8.5)
 
+cmake_policy(SET CMP0091 NEW)
+set(MSVC_RUNTIME_LIBRARY MultiThreaded)
+
 if(NOT CMAKE_BUILD_TYPE)
     set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
         "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)

@mikdusan
Copy link
Member

I'm not sure if zig can statically link in the MSVC runtime libraries. I see a suspicious commit here where it may have been statically linked before but now it no longer is: 357fb4f

CI uses vs2019 (MSVC) to build on windows... that commit looks unrelated to issue.

@mikdusan
Copy link
Member

tools that might be useful for examining exe:

  • dumpbin /dependents zig.exe docs
  • dumpbin /imports zig.exe (not really sure what this does)
  • ldd zig.exe (if running in a cygwin or msys64 env)

@andrewrk
Copy link
Member

duplicate of #3391 (the comments on this issue are really helpful and I will make note of that)

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

No branches or pull requests

3 participants