NotepadNext icon indicating copy to clipboard operation
NotepadNext copied to clipboard

Can't start: MSVCP140.dll missing

Open BenjaminRi opened this issue 2 years ago • 18 comments

When I install Notepad Next v0.6.3 on a clean Windows 10 machine, I get the error:

Screenshot_20230716_221750

I guess it requires Microsoft Visual C++ Redistributable Packages for Visual Studio 2015? Ideally, the installer would either fetch the redistributable or throw an error to notify the user that this is a requirement (also, that seems like a pretty outdated dependency). Ideally, such shenanigans wouldn't even be needed (e.g. if you eliminate such dependencies and ship whatever is required with the installer).

BenjaminRi avatar Jul 16 '23 20:07 BenjaminRi

It's already being looked into. I already raised an issue on this.

ZachBacon avatar Jul 16 '23 20:07 ZachBacon

Ideally, such shenanigans wouldn't even be needed

I look forward to your pull request fixing such "shenanigans" without the need to bloat the installer.

dail8859 avatar Jul 16 '23 20:07 dail8859

I look forward to your pull request fixing such "shenanigans" without the need to bloat the installer.

I ship a similar piece of software in ~20MB. It uses GTK3 and the GNU toolchain and contains everything in the installer. I admit that I don't know Qt well but perhaps a similar thing is possible with NotepadNext? The dependency on the redistributable just seems like a blemish, for example it defeats the purpose of the per-user install that doesn't require admin rights because you need admin rights to install the redistributable. Anyway, I did not mean to diminish your work. A truly cross-platform Notepad++ is a thing the world needs.

BenjaminRi avatar Jul 16 '23 20:07 BenjaminRi

Hmm... How does Notepad++ avoid the dependency on the Visual C++ Redistributable with its tiny 4.2MB installer? Perhaps like this? They do seem to link statically.

BenjaminRi avatar Jul 16 '23 21:07 BenjaminRi

I admit that I don't know Qt well but perhaps a similar thing is possible with NotepadNext

I'm definitely not a Qt expert either. There may be other stuff the NSIS installer can do. I took a crack at this a bit ago to get it to download the installer and run it in the fly. I had mixed results and got too busy to put any more time into it.

I did not mean to diminish your work. A truly cross-platform Notepad++ is a thing the world needs.

Understood. This entire project is a huge learning experience for me...so I'm grateful for any help people are willing to contribute.

How does Notepad++ avoid the dependency on the Visual C++ Redistributable

I've wondered the same thing myself since I don't recall these kinds of issues being reported with Notepad++.

They do seem to link statically.

CMake isn't their official build system so that may not be the same when it is built with visual studio.

dail8859 avatar Jul 16 '23 22:07 dail8859

CMake isn't their official build system so that may not be the same when it is built with visual studio.

Seems to be the same in the Visual Studio solution. Perhaps the elimination of the redistributable dependency is just a few options/clicks away.

BenjaminRi avatar Jul 16 '23 22:07 BenjaminRi

Perhaps the elimination of the redistributable dependency is just a few options/clicks away.

Interesting...this may address the root issue then. The changes should be simple enough but haven't had time to even boot up my dev machine for a few weeks...so hopefully I can get around to this eventually or someone can submit a PR. I think it should be something like this in the qmake file:

msvc:QMAKE_CXXFLAGS_RELEASE += /MT
msvc:QMAKE_CXXFLAGS_DEBUG += /MTd

dail8859 avatar Jul 16 '23 22:07 dail8859

You can try a zip build of the application statically linked here:

https://github.com/dail8859/NotepadNext/suites/15858669490/artifacts/904907341

If someone could test this and verify it works, that would be great since I don't have access to a clean install of Windows anywhere.

dail8859 avatar Sep 06 '23 00:09 dail8859

Can anyone verify this fix?

I have no way to test this myself.

dail8859 avatar Sep 19 '23 22:09 dail8859

I can take a look within the next few days :+1:

BenjaminRi avatar Sep 20 '23 23:09 BenjaminRi

I can take a look within the next few days :+1:

Greatly appreciated!

dail8859 avatar Sep 20 '23 23:09 dail8859

I tried to access the link

https://github.com/dail8859/NotepadNext/suites/15858669490/artifacts/904907341

but I get a 404 error. Hence, I was unable to test it.

By the way: Anyone can test this with a clean Windows virtual machine.

BenjaminRi avatar Sep 24 '23 10:09 BenjaminRi

@BenjaminRi Weird...

Try this link: https://github.com/dail8859/NotepadNext/suites/15858669490/artifacts/916495554

dail8859 avatar Sep 25 '23 14:09 dail8859

Try this link: https://github.com/dail8859/NotepadNext/suites/15858669490/artifacts/916495554

Still the same thing, it doesn't find the libraries.

BenjaminRi avatar Sep 26 '23 00:09 BenjaminRi

Still the same thing, it doesn't find the libraries.

Thanks for trying it. Looking at the GitHub action and also my machine I can confirm that the PR doesn't change the /MD flag.

I tweaked it on my development machine and I'm getting the compiler to use the /MT flag as expected now. However, my concern now is this linker warning:

LIBCMT.lib(initializers.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library

My assumption is this is because the Qt DLLs are linked to the dynamic runtime, even if the exe itself is using the static runtime. Short of custom compiling the Qt DLLs to use the static runtime, I'm not sure if there is a way to solve this to not rely on the Visual C++ Redistributable.

Maybe I'm misunderstanding the exact nature of the error as this is all an educated guess. Even if this does run I'd be quite concerned to publish the app built this way.

If interested, another build to test:

https://github.com/dail8859/NotepadNext/suites/16556741509/artifacts/945757281

dail8859 avatar Sep 26 '23 02:09 dail8859

https://github.com/dail8859/NotepadNext/suites/16556741509/artifacts/945757281

Same issue again. I believe that the person who works on this needs to be able to test it themselves. This is easily done with a Windows VM (Microsoft distributes them free of charge) or a second PC.

BenjaminRi avatar Sep 30 '23 12:09 BenjaminRi

Same issue again.

Getting back to my prior point...this fix may not be possible due to the Qt DLLs

dail8859 avatar Sep 30 '23 12:09 dail8859

Same issue again.

Getting back to my prior point...this fix may not be possible due to the Qt DLLs

Then the installer needs to install MSVC++ redistributable. If NotepadNext just doesn't run after installation, people are not going to use it. Unfortunately, I'm involved in too many other projects to have time to fix this.

BenjaminRi avatar Sep 30 '23 12:09 BenjaminRi