C++ Qt executable compatible with all windows computers? - c++

I have had problems in the past using visual C++, when I ran the executable on other computers it required a .NET framework. I have now started looking at c++ Qt GUI builder and from what I have read C++ doesnt require any additional downloads apart from the executable file to be able to run on other computers, is this true? If I use Qt to build my GUI and send it to other users they will need no other external downloads?

I have now started looking at c++ Qt GUI builder and from what I have read C++ doesnt require any additional downloads apart from the executable file to be able to run on other computers, is this true?
Not necessarily; see below.
If I use Qt to build my GUI and send it to other users they will need no other external downloads?
You will potentially need to get redistributables installed on each user machine where this is needed, but this is not a Qt issue, just a generic principle how VS/MSVC and Windows work. However, there is no gentle way around to it in my understanding.

I'm not 100% sure, but I can tell you that some of my users need to download the Visual C++ Redistributable package. They would sometimes get a missing "msvcr.dll" error. Very frustrating. I tried including the file with the install, but it was picked up as a virus by some antivirus programs.

Related

Windows7+: How to build a C++ Windows Console application that doesn't require any additional/external runtime libraries?

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
I don't even know why you mention .net for C++. You only need the C++ runtime. That can be statically linked.
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 :-)

Qt - C++ Graphical application in visual studio

I want to create graphical application (drawing and moving squares and so) using C++. I was suggested to use Qt library for this. I am windows user and I use Visual Studio 2013 for developing C++ (console) apps. So I typed Qt download into google hoping to find some package of DLLs, libs, headers or something like that so I could include headers and link libraries with my code. But all I found was IDE Qt Creator (which I do not want) and Qt Visual Studio plugin (which I downloaded, but it still requires whole IDE to work). So my question is - How can I develop graphical application (no forms, just "canvas" to draw on with some mouse/keyboard support) using Qt library, C++ language and Visual Studio IDE, without requirement of downloading tons of GBs for IDE or plugins I do not want, with insurance that application would be easily deployable on most common operating systems.
The reason I do not want Qt creator IDE is simple -- There is a chance for this to be semester project and will be reviewed by teacher without any extra IDEs. (I'll send him just VS project/generated Makefile and Qt libraries with headers)
Thanks for clarification.
The short answer is: you cannot. You need Qt SDK, which comes with Qt Creator.
Qt comes with qmake build system and it does not require any IDE to compile and run the application. You can write in any IDE you want and compile anywhere, where Qt SDK and compiler is available.
If you want to provide the application to your teacher, he must have Qt SDK too to compile it. There is no way around this. And better test the application in the target environment. Writing portable applications is not a trivial task - if you hardcode paths like C:\QtSDK\path\to\something, there is little chance to run it under Linux without any changes.
If you cannot expect any SDK on a teacher's computer, you have few options:
convince her to install necessary tools
ask her what tools are permitted and stick with them
bring your own computer for final evaluation

How can i make a portable C++ program for Windows with GUI, independent from .NET or other Libs?

I want to make a C++ program with Graphical User Interface, to be running on Windows platforms.
I want it to be independent from any libraries like .NET.
The reason I want this is because I want this program to be able to run everywhere, in every version of Windows (XP, VISTA, 7 - 32 & 64bit) without the user to be bound to have already installed a library like .NET.
Also, I want it to be portable: the whole program to consist from only one exe file.
So to summarize:
How can I make an one-exe-file GUI C++ program, able to run on all versions of Windows, without the need of pre-installed libraries on Windows from the user that uses it?
I have already MS Visual C++ 2010 Express and Eclipse with Cygwin's G++ compiler installed on my system.
Notice: I don't mind to use any libraries for windows GUI design if there is a way to embed them inside the executable file of the program.
You can either use a library that can be statically linked (MFC, WTL) or use Win32 API directly.
WxWidgets have static linking capability, never tried it myself.
If you want portabiliy, and yet don't want to depend on 3rd party libraries... well you'll have to provide portability yourself! Don't do it! As adviced by OneOfOne, use Qt and be impressed how simple yet powerful it is. Good luck!
You can also use Qt5, works great on windows and when you figure out that windows isn't the only OS out there, you can easily port it to everything else.
License issues : Proprietary Source code + LGPL Source code

How to run C++ executable in Windows PE?

I have an executable I made using a CLI console application with Visual Basic 2010. I can run the program completely fine from my developer machine.
However, when I copy the executable over to another machine, re-boot to a pre-installation environment and run the executable again, nothing happens at all. There are no errors shown or anything.
My guess is the executable can't run without certain dependencies that aren't loaded at this environment, but I need it to work in a PE.
Any ideas on whats going on?
First of all, since the question is tagged "c++" and you mention C++/CLI several times, I assume that "Visual Basic 2010" is a typo for "Visual Studio 2010". But either way, whether you've written the application in Visual Basic (VB.NET) or C++/CLI, the problem is exactly the same.
My guess is the executable can't run without certain dependencies that aren't loaded at this environment, but I need it to work in a PE.
That's exactly correct. You've written an application that targets the .NET Framework. Somewhat like Java applications requiring a JVM, .NET applications require that the .NET Framework be installed in order to run (or a compatible alternative implementation, like Mono). Unfortunately, Windows PE does not support the .NET Framework.
Note that it is irrelevant whether you've written a WinForms, WPF, or Console application. Although they present their UI in very different ways, they all depend on the .NET Framework being installed.
You will need to (re-)write the application in a different programming language, one that generates native code without any dependencies on the .NET Framework. C and C++ are popular choices. If you choose to use C++, make sure that you create what Visual Studio calls a "Win32" project. This is one that targets the underlying operating system APIs directly (i.e. a native application) and does not have a dependency on the .NET Framework. Stay away from anything that has ".NET" or "CLR" in its description.
I don't really have a full comprehension of when an application is using .NET or not... I am just used to Linux C/C++ development. I hate Microsoft shit
It uses .NET whenever you use the .NET Framework libraries/classes in your code. I'm not really sure why this is so difficult to understand. The same problem could easily exist on Linux if you were using a third-party library that was not available in certain environments for whatever reason. This is not Microsoft's problem, it's an issue of using the wrong tools for the job. The .NET Framework is an object-oriented wrapper around the native APIs that makes it much easier for people to get up and running writing programs for Windows. But if you're "used to Linux C/C++ development", you should have little trouble writing a simple console application that targets the native APIs directly without using .NET.
If your hatred for "Microsoft shit" has turned into an allergy, you can avoid Visual Studio entirely and download MinGW, which is a Windows port of the GCC compiler you're probably used to. Combined with your favorite Windows port of Vi, you're working in an environment very similar to the one you're used to. And since GCC doesn't support C++/CLI or the .NET Framework, you won't have to worry about getting stuck picking the wrong option.
The .Net framework has been supported as an optional package install during your PE build process for the past couple versions of WinPE. I write code in C# that I run in WinPE everyday. I have yet to find a good way to debug in a manner where I can walk through break points, etc... though. My best option has just been a lot of logging and a global Exception catch around my main entry point that will write out a full stack dump. You can attach to your app as a remote process in a VM running WinPE, but if you need to catch something early in the execution you'll have a difficult time.

creating C++ program that runs on most of PCs

I have a project that requires writing a code for small executable file. I used visual C++ express 2010 IDE to create this file. After I finished writing the code, I tried to copy it to a couple of different PCs. It gives me an error message every time I clicking on this file to execute it. The message states that I have to install (.NET framework). I watched a couple videos on YouTube explaining how overcome this problem by changing the runtime library from multi-threaded Debug DLL (/MDd) to multi-threaded Debug (/Mtd). However; the IDE can’t debug the C++ code because when I create my project by using CLR template!
Is there any way to solve this problem? Can I create a similar program that not requires any further downloading once I using on different PC?
Is learning a different language like JAVA or C# will help creating small programs (like my program) that run on most Window platform machine?
Just use Qt - it runs on Windows, Linux, MacOS, support for Android and iOS is scheduled for this year, plus it supports embedded platforms and some of the more obscure mobile platforms. Also, support for Windows RT was just kickstarted. A complete library with tons of functionality, good documentation and lots of educational resources. It provides tons of tools, from implicitly shared containers through threading, signals and slots, 2D and 3D graphics, widgets, multimedia, sensors... and whatnot...
You can even develop commercial applications under the LGPL license.
Also comes with a pretty good IDE - Qt Creator.
You can develop standard C++ applications or use QML, which is a JavaScript like language for markup and scripting, which is used to build applications from C++ implemented components. You can also extend QML. It is much faster to develop with QML and you still get the advantages of platform native binary under the hood.
Note that you will still need to either ship a few DLLs with your application. Unless of course you use a static build, which requires you to either have your application open source, or purchase a commercial license... which doesn't come cheap...
But still, a few MB of DLLs are far better than the entire .NET framework. A static build will produce executables about 8-9 MB with no external dependencies.
Stick with the C++ standard, avoid Microsoft extensions (managed code), and call only POSIX functions of your OS, then you should be able to write portable programs.
You seem to have created a Managed C++ Project. Instead create an empty Win32 C++ project and then add in your .cpp/.h files. This will limit you to the default libraries available on all PCs with the C++ runtime. If you want to remove that dependency too then statically compile in the runtime using the /MT option. Details # http://msdn.microsoft.com/en-us/library/2kzt1wy3(v=vs.71).aspx
As you move ahead you would need to be conscious of what libraries you take dependencies on and what versions of the OS are those libraries available on or if you need to package them with your bits.
Both Java and C# will help making portable programs. Usually, people will have to install runtime environments for executables written in these two languages, however. These days, C++ is more portable than ever. You can easily run C++ executables in your browser:
https://github.com/kripken/emscripten
http://code.google.com/p/nativeclient/
This makes many of the reasons why Java and C# came about irrelevant.
Open standards like OpenGL also make portable GUI programming easier than ever. Try Qt, if you want to write a simple GUI in C++.
Note: It is possible to run C++ program in any computer without installing anything if you haven't use .NET framework. In your case, there can be two reasons to trigger error in target computer.
New computer doesn't have required run-time assembles.
New computer doesn't have required .NET framework installed.
..........................................
So what to do:
Before start your program you have to design weather are you going to use .NET framework support or not. If you use .NET framework when you develop your program, then you much install same or higher .NET framework in target computer.
If you no need to use .NET component then your target computer should only containing run-time assemblies.
How to get rid of .net framework
right click on the project in solution -> properties -> General -> Common language run time support -> select "No common language run time support".
..........................................
Then what you need is only relevant run-time assemblies be in target computer.
How can run-time assemblies be in new computer:
There are two ways:
Install suitable C++ disputable environment in target computer(if you use VS2008 SP1, C++ RD package should be this. Please consider the solution build architecture also (32 bit/64 bit) before download ).
Deploy run-time assemblies with your solution package. (I like this because user no need to install any third party components)
..........................................
How Deploy assemblies with my project:
for this your all DLL, LIB, EXE should use same run time version.(if not, you face troubling to redirect assemblies by 'manifest' files ).
How to check the run-time version.
open DLL,EXE by visual studio (open->file) -> expand RT_MANIFEST-> double click the file under it ->then assembly dependency details will open. -> copy the data in right column and paste to note pad.
You will see this kind of line there. and ther is the version run-time assemblies your specific DLL or EXE use.
assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86".....
After identifying the version of run-time assemblies follow this tutorial and try to run in fresh installed computer.
At last: If you think this bla.. bla.. is so complex and your program is very simple, then you can consider about "run time assemblies statically linking" (try Google). But personally I don't like this method.
good luck!