Pages: 1
Author Topic: C++ questions!  (34,627 Views)
Offline (Unknown gender) Darkstar2

Member
Joined: Jan 2014
Posts: 1,238
View profile
Posted on: May 04, 2014, 07:10:14 PM
I am considering soon playing around with QT, VisualC++, ECLIPSE, etc.  I am looking to make experiment with console apps and GUI apps and goal eventually to code my own resource packer and handler in C++ for use in my ENIGMA project, for games where I would directly access individual external resources packed into single files.

But for now let's focus on stand-alone EXE compiled from C++.

Now please correct me if I am wrong.

I am to understand that if my source C++ is a console app and uses the standard libraries, my final EXE will run without any dependency .... meaning a person running my EXE will not require to install .NET or VC runtimes or any DLLs......Right ?

What if I wanted to do stuff in QT or Visual C that involves a GUI, (forms, windows, etc.)
I am to understand these are the ones to use dependencies by the final EXE......Right?

Now a lot of software require you to install .NET or the visual C runtime, obviously dynamic linking makes smaller files and static linking can be a pain or not recommended, etc.   I mean it's obvious most software out there requires dependencies, even commercial games, GUIs, tools, require user installed libraries, dependencies, runtime stuff, etc.  I have no problem with that.  But as opposed to having a user install them (some people fear installs :D) can I have the compiler automatically add all the dependencies required included in the same folder as my EXE ? this way when the EXE is run it would use the whatever it needs directly in the installed folder instead of having it installed by the user ? I hope this is not confusing :)

So question is this since I have never use said apps.   How do I know which dependencies my EXE will require installed.
I mean on my windows I already have .NET and all the runtime libs and DLL installed ,but if I give the EXE to someone else, what will they need ?  Is there a tool inside those apps that will automatically tell me what dependencies my EXE will require ?  What if they do have dependencies, is there a way to create an auto installer that will check system for dependencies and if they are not installed / install them ????

Also heard from people QTCreator makes big EXEs ...... and that you require a special license to distribute your EXE, is this true ? thousands of $????  IS this the same for Visual C++ or ECLIPSE or other tools ?

Thanks for the help.


Offline (Unknown gender) Rusky

Resident Troll
Joined: Feb 2008
Posts: 954
View profile WWW
Reply #1 Posted on: May 05, 2014, 12:00:11 AM
If you use Microsoft's C++ compiler to make a console app, or a GUI app with plain Win32 (or either of these with any statically linked libraries), you will have a dependency on Microsoft's C++ standard library, which may or may not be installed on the target machine. Microsoft provides "Visual C++ Redistributable" installers for each version of this library (yes, this is required even for console apps- "visual" is just the brand name).

If you use MinGW instead, you will depend on the GNU C++ standard library (and libgcc). You can statically link it (and libgcc) to have literally no dependencies, but that makes your exe bigger. IIRC this is what ENIGMA does.

If you use Qt or another library besides plain Win32 for a GUI, then you will depend on that library. You can statically link it, if you don't mind the large file size. You can also manually include the required DLL's with your exe when you distribute it, or you can have an installer for your app that puts them somewhere the exe will find them.

You can use Dependency Walker to find which DLLs your EXE requires, but you should generally know already by the documentation of the libraries you use. For example, if you use a .NET language (C# is the biggest one) you'll need the .NET Framework, if you use Qt you'll need those DLLs, etc.

Neither Visual Studio nor Eclipse require any kind of license to distribute your EXEs. Qt is LGPL, so statically linking requires you make your app LGPL as well, but otherwise there's no licensing requirements.

(this post all applies to Windows)
Offline (Unknown gender) Darkstar2

Member
Joined: Jan 2014
Posts: 1,238
View profile
Reply #2 Posted on: May 05, 2014, 02:22:33 AM
Quote from: Rusky on May 05, 2014, 12:00:11 AM
If you use Microsoft's C++ compiler to make a console app, or a GUI app with plain Win32 (or either of these with any statically linked libraries),

I thought it was the DYNAMIC ones that required dependencies on the user's system and static linked them but made files bigger. Interesting.  So if I use Microsoft's Visual C++, does it use the Microsoft compiler or can I tell it to use MinGW.  If not mistaken one could do that in ECLIPSE, I don't know if it can be done in QTCreator.

Quote
you will have a dependency on Microsoft's C++ standard library, which may or may not be installed on the target machine. Microsoft provides "Visual C++ Redistributable" installers for each version of this library (yes, this is required even for console apps- "visual" is just the brand name).

Hmm nice to know.  So Visual C++ redist does not get automatically installed in windows ?  I have the .NET and Visual C++ 2005, 2008, 2010 and x64 ones, I didn't bother looking if they were there with my W7, pretty sure they were installed by software I have :D

Quote
If you use MinGW instead, you will depend on the GNU C++ standard library (and libgcc). You can statically link it (and libgcc) to have literally no dependencies, but that makes your exe bigger. IIRC this is what ENIGMA does.

I'm ok with the file sizes ENIGMA produces, they are still far smaller the ones produced in GMS, even YYC, as ENIGMA also allows further optimization and removal of extensions and unused features.  Also the smallest I could get with ENIGMA is a 304K file compressed, so when releasing app I could use it with a SFX.  I can live with these file sizes anytime, if it means not forcing the user to install stuff.

Quote
If you use Qt or another library besides plain Win32 for a GUI, then you will depend on that library. You can statically link it, if you don't mind the large file size. You can also manually include the required DLL's with your exe when you distribute it, or you can have an installer for your app that puts them somewhere the exe will find them.

And that installer is a feature of QT Creator ? Is it also a feature of the MS VC++ ?
By installer i'm assuming it is putting them in the windows / system folders and registering them.  Could I just avoid installers and just have an EXE of my app created along with all their dependencies and zip them, so that the user unzips all these files in one folder including the dependencies ?

You can use Dependency Walker to find which DLLs your EXE requires, but you should generally know already by the documentation of the libraries you use. For example, if you use a .NET language (C# is the biggest one) you'll need the .NET Framework, if you use Qt you'll need those DLLs, etc.

Quote
Neither Visual Studio nor Eclipse require any kind of license to distribute your EXEs. Qt is LGPL, so statically linking requires you make your app LGPL as well, but otherwise there's no licensing requirements.

(this post all applies to Windows)

Ok, so I am better off using Visual Studio right ?  I never really understood all the jargon and LGPL and licensing, it gives me a headache :)

And yes, I will only focus on Windows and have no plans for anything else for quite some time, other than maybe some android app/games and take on TKG's offer for that.

So having a user install runtime libs etc should not be a problem as most software out there have some dependencies that need installing, people who use Microsoft and Adobe software to name a few know that all too well LOL.  Just as long as I am aware of what my EXE will require so that I can properly document it, as I am really very new to the whole dependencies thingy. :D

Thanks.
Offline (Unknown gender) Rusky

Resident Troll
Joined: Feb 2008
Posts: 954
View profile WWW
Reply #3 Posted on: May 05, 2014, 02:53:13 AM
Dynamic linking does require dependencies while static libraries include them in the EXE, making it bigger. Both Visual C++ and MinGW dynamically link the standard library by default, so that fixes to the standard library will still apply to old applications. You can also statically link the standard library with either compiler.

Visual Studio has some kind of support for installers, but they're a little odd and I haven't really investigated exactly why. As far as I know Qt Creator does not. You can make an installer with something like NSIS, but it's purely optional- you can just put the DLLs in the same folder as the EXE.

Qt's IDE is fine, license wise. It's only when you statically link the Qt libraries that you have to LGPL-license your app. Use Visual Studio or QtCreator or whatever else depending on what works best for you.
Offline (Unknown gender) TheExDeus

Developer
Joined: Apr 2008
Posts: 1,860
View profile
Reply #4 Posted on: May 05, 2014, 11:21:44 AM
The only thing I have ever used for C++ is MinGW. I just take any IDE (Code::Blocks being my favorite, but you can also use Notepad++ or just plain freaking notepad) and I compile everything with makefiles and cmd. So i'm pretty old school with all that. But I know even IDE's like MS Visual Studio support MinGW in one respect or another. At least it supports compiling on Linux machines remotely (I used VisualGDB plugin to do that for RaspberryPi from Windows). I think there is a plugin or something like that to interface with MinGW as well. This would give you access to Intellisense and maybe even makefile generation, while still using plain C++ and MinGW compiler.
Offline (Unknown gender) The 11th plague of Egypt

Member
Joined: Dec 2009
Posts: 274
View profile
Reply #5 Posted on: May 05, 2014, 04:22:58 PM
If you use Qt, you are more or less invited to use their version of the standard library.
That is, qString instead of string, for example. If you read a qTextField, you get a qString instead of a string.
It's just that it gives you some more functionalities and checks.

You can use the Qt IDE to design the GUI, and it's quite good, so there's no need to fire up Visual Studio at all.
Unlike Java, which adopts the same GUI to rule them all, Qt provides a native look for each platform.
Truth is, sometimes it's not perfectly native, but you won't need any native calls and it will spare you any #ifdef.

License wise, it's the same as using the std library, you can release as closed source unless you mod the Qt library itself.
And even then you would just need to release the changes you made to the library and not your whole program.

LGPL was originally made for libraries.
You can use the library in your program without releasing the code of your program.
If you want to modify the code of the library itself, then you have to release the mod to the library under the same license (LGPL).

What's all the fuss about the dynamic / static linking?
Some people consider static linking as merging the code of your program with the code of the library.
And so they say that you should release the code of your program under the same license of the library.
It's not exactly like that, but use dynamic linking and everything will be fine.
In case you do want to investigate further, here you go
http://stackoverflow.com/questions/10130143/gpl-lgpl-and-static-linking
http://www.gnu.org/licenses/gpl-faq.html#LGPLStaticVsDynamic

That said, Qt is a HUGE framework, far bigger than Java standard library.
Fortunately, it's truly modular and it's written with a more consistent style.
Make sure you understand the style they are "suggesting" you to use, or you'll be swimming against the tide.
Pages: 1