Hello everyone,
As I know C++ is a native language which means it has no dependencies as long as it runs on a windows machine, but whenever I try to run a little code I wrote on different machines than the one I created it on I get a missing DLL error for msvcp140.dll and vcruntime140.dll.
How can I assure my EXE will run on every windows machine without needing to add anything?
Thanks in advance ✌
It's because you don't embed it in the program when you generate the code, C/C++ -> Code Generation -> Runtime Library -> Multithreaded in Release version will solve your problem
you using Visual C++ 2015 every version have differnent runtime
the other os dont have Microsoft Visual C++ 2015 Redistributable installed
Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
Nov 28, 2018 08:41 AM
(This post was last modified: Nov 28, 2018 08:42 AM by ApexLead.)
(Nov 28, 2018 08:26 AM)TCP Wrote: It's because you don't embed it in the program when you generate the code, C/C++ -> Code Generation -> Runtime Library -> Multithreaded in Release version will solve your problem
Thanks :)
Is this the only way tho? It pumped my EXE from 12kb to 209kb :/
(Nov 28, 2018 08:35 AM)HFDone Wrote: you using Visual C++ 2015 every version have differnent runtime
the other os dont have Microsoft Visual C++ 2015 Redistributable installed
So how can I make my executable compatible with every windows OS like tool programmers do?
(Nov 28, 2018 08:41 AM)ApexLead Wrote: Thanks :)
Is this the only way tho? It pumped my EXE from 12kb to 209kb :/ Either you embed it or load it from an external source
(Nov 28, 2018 08:47 AM)TCP Wrote: Either you embed it or load it from an external source
What do you mean by external source? Its either I embed it or go back to the old position where I need it available on the PC?
(Nov 28, 2018 08:49 AM)ApexLead Wrote: What do you mean by external source? Its either I embed it or go back to the old position where I need it available on the PC?
It's a runtime module, you need to have it in the application or installed
(Nov 28, 2018 08:58 AM)TCP Wrote: It's a runtime module, you need to have it in the application or installed
Got you, thanks :)
Those are MSVC dependencies, because of Visual Studio's default configuration. But if you want to then you're free to install and use another compiler such as GCC.
(Nov 28, 2018 09:41 AM)Vuln Wrote: Those are MSVC dependencies, because of Visual Studio's default configuration. But if you want to then you're free to install and use another compiler such as GCC.
So if ill use GCC the exe will remain like 12kb but without dependencies?
(Nov 29, 2018 12:48 AM)ApexLead Wrote: So if ill use GCC the exe will remain like 12kb but without dependencies?
No.
GCC bloats more than msvc.
Anyway, you are using too many other libraries and shit, to get small stub remove all other libraries and even CRT, use only winapi.
Because like other people said, you are linking with the CRT:
1: you can load it dynamically (What your 12kb exe does)
2: You link it statically (Larger size exe)
3: You design your code to work without the CRT and remove it.
If low size and no dependencies are important, remove the CRT
(Nov 29, 2018 12:31 PM)3DES Wrote: No.
GCC bloats more than msvc.
Anyway, you are using too many other libraries and shit, to get small stub remove all other libraries and even CRT, use only winapi.
(Nov 30, 2018 08:24 AM)LanMan Wrote: Because like other people said, you are linking with the CRT:
1: you can load it dynamically (What your 12kb exe does)
2: You link it statically (Larger size exe)
3: You design your code to work without the CRT and remove it.
If low size and no dependencies are important, remove the CRT
What do you mean by CRT? And how to I remove the urlib and other libs if they are needed for my exe to work?
(Dec 2, 2018 03:20 AM)ApexLead Wrote: What do you mean by CRT? And how to I remove the urlib and other libs if they are needed for my exe to work?
https://docs.microsoft.com/en-us/cpp/c-r...ew=vs-2017
They are needed if you are using runtime feature otherwise aren't, and with msvc you compile with /NODEFAULTLIB to remove it and all default library
Dec 2, 2018 04:42 PM
(This post was last modified: Dec 2, 2018 04:50 PM by 0xDEAD10CC.)
(Nov 28, 2018 08:11 AM)ApexLead Wrote: Hello everyone,
As I know C++ is a native language which means it has no dependencies as long as it runs on a windows machine, but whenever I try to run a little code I wrote on different machines than the one I created it on I get a missing DLL error for msvcp140.dll and vcruntime140.dll.
How can I assure my EXE will run on every windows machine without needing to add anything?
Thanks in advance ✌
Lol, you're heavily misinformed. That first sentence is nowhere near true by itself, but additionally those missing dll issues you're having means you're depending on the C++ redistributables from your project settings. A native language doesn't mean no dependencies... Nevermind how inaccurate the "as long as it runs on a windows machine" statement is.
(Nov 28, 2018 08:41 AM)ApexLead Wrote: Thanks :)
Is this the only way tho? It pumped my EXE from 12kb to 209kb :/
So how can I make my executable compatible with every windows OS like tool programmers do?
OS compatibility is not a guarantee, which is why some people provide different installers depending on whether you're running Win7 or Win10. The code internally uses the preprocessor so you can write platform or OS specific code for other people to compile in their own environments, otherwise runtime checks are invovled since the preprocessor will only solve these issues pre-compile time.
(Nov 28, 2018 08:47 AM)TCP Wrote: Either you embed it or load it from an external source
Or better yet, don't use it if you care about filesize. You'll have to change the entrypoint and mod a few other things in the way you write your code though because /NODEFAULTLIB means you're excluding access to use a bunch of stuff. There's also a lot of other things you can do such as merge sections of the file to get a smaller size to the point where even UPX creates a larger binary. In most cases, making sure to compile using the default RELEASE build will shrink the output enough for most.
|