-1

This has probably been asked/answered dozens of times, but even after going/reading through many of these questions, i still can't figure out what to do...

Anyhow: I'm trying to write a standalone X86/32-bit C++ Windows console application using Visual Studio 2017 Community Edition (under Windows 10 x64) that runs some CMD.exe commands.

The problem: When trying to run the application on Windows 7, a dialog box pops up with a message saying that a required runtime library couldn't be found.

As i happen to be fairly new to developing/coding, you can probably understand how overwhelmed i am/was when going through Visual Studio's (project) options.

The goal to reach: I would like to know if there's a way (and how) to make my C++ console application work on Windows 7 and onwards, while ONLY using the operating system's built-in/default shipped libraries (if possible without requiring the .NET framework to run the program).

The application's purpose is really simple and is meant for learning the basics of Visual Studio development.

Hopefully someone can help me out. I know i'm supposed to uncheck any recent SDK's in the Visual Studio Installer, but at the same time it appears that the .NET framework seems to be a required component for writing/compiling CLI applications :S

script'n'code
  • 345
  • 4
  • 17
  • 1
    If you have any CLI stuff going , you're stuck. You need .Net. For the rest, you want to link statically. The main option will not have moved far from what's discussed in this question: https://stackoverflow.com/questions/37398/how-do-i-make-a-fully-statically-linked-exe-with-visual-studio-express-2005 – user4581301 Jun 07 '17 at 03:47
  • Humm, unless i decide to opt for a different (or older) IDE solution where .NET wasn't yet introduced? There must be a solution in that regard =) Heck, you can even write stuff in batch and compile it into a windows .exe......... hey, wait a second! - Oh nvm (not to exaggerate), the resulting .exe is pretty big, something i don't really like for such a simple program (if only i knew assembly, heh > [Steve Gibson](https://www.google.com/#q=steve+gibson)). – script'n'code Jun 07 '17 at 04:30
  • There is nothing about size in your question. – KonstantinL Jun 07 '17 at 08:34
  • @KonstantinL The main point still stands though. – script'n'code Jun 07 '17 at 12:51
  • @copyitright, I meant you should correct the problem description to be complete. – KonstantinL Jun 07 '17 at 14:05
  • The size thing is just an additional something that can be ignored for now. I only need to know about which options i have to make the dialog window disappear. Is static linking the only way or is it also possible by using an older toolset/revision that's already supported by Windows 7+ by default/out of the box? – script'n'code Jun 07 '17 at 16:31
  • 1
    You have two sane options: Static linking of the runtime libraries or install the Visual Studio Redistributable package for Visual Studio 2017 on target PCs. Sounds like you are mostly interested in option 1. [Here's the most up to date page on this from Microsoft that I can pry out of Google.](https://learn.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library) – user4581301 Jun 07 '17 at 17:56
  • 1
    There is nothing mystic in CRT. Of course you could build a program that does not use CRT. Search for "minimal c program". And also look here: https://stackoverflow.com/questions/553029/what-is-the-smallest-possible-windows-pe-executable – KonstantinL Jun 07 '17 at 19:13
  • Hmm, perhaps that will come in handy. Thanks! – script'n'code Jun 10 '17 at 02:13

2 Answers2

1

I don't even know why you mention .net for C++. You only need the C++ runtime. That can be statically linked.

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • I would think the same, when i went from C# to C++ i could run the program without .NET installed. I'll try looking how to statically link the C++ runtime, i'm pretty noob to this. Thanks! ;-) – script'n'code Jun 07 '17 at 12:50
0

Well guys (i assume?), i've returned with some good news.

I'm also answering my own question since i have found a solution that gave me everything i asked/hoped for.

Code::Blocks IDE gave me both a very small program/exe of ~10kB, and it even worked without any additional/extra runtime libraries (i've tested this under a fresh/clean virtual OS @ VMware Player).

Thank you all for the given support, you've been really helpful :-)

script'n'code
  • 345
  • 4
  • 17