6

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.

MinimalTech
  • 881
  • 3
  • 8
  • 23

4 Answers4

4

You can either use a library that can be statically linked (MFC, WTL) or use Win32 API directly.

Nemanja Trifunovic
  • 24,346
  • 3
  • 50
  • 88
  • How can i make this with Visual C++ '10 Express? When i create a new Project of Win32 Application there is no choice of _static linking_... Neither i can select MFC or WTL... – MinimalTech Feb 10 '14 at 14:11
  • MFC/ATL are not included in the Express versions – Alex K. Feb 10 '14 at 14:39
  • There is a way to use WTL with express versions of Visual Studio. For instance: http://www.codeproject.com/Articles/12705/Using-WTL-with-Visual-C-2005-Express-Edition – Nemanja Trifunovic Feb 10 '14 at 14:46
  • @NemanjaTrifunovic (or any other), let's say that i use the native Win32 API in my program. Please tell me **1)** How can i make/define a static linking of Win32 libraries in VC++ '10 Express for my executable? **2)** What type of project should i select from the wizard? **3)** Will I be able to use the Toolbox to add buttons/labels/menus and other controls to my Form (window)? The code will be written automatically in source view? – MinimalTech Feb 10 '14 at 21:35
  • @MinimalTech: you don't link the Win32 libraries statically. but you need to specify statically linked runtime. – Cheers and hth. - Alf Feb 10 '14 at 22:17
  • 1
    @MinimalTech: "Win32 libraries" are Windows. You don't statically link Windows to your program. However, as Cheers... mentions, you need to statically link C/C++ runtime; another option would be to not link to the C/C++ runtime at all. – Nemanja Trifunovic Feb 11 '14 at 13:22
  • @NemanjaTrifunovic yes I understand, I agree with you, but how can I do it? That's what I'm asking from the beginning... – MinimalTech Feb 11 '14 at 15:08
  • 1
    @MinimalTech: Under Project Settings, C/C++, Code Generation, there is an option "Runtime Library". Pick the versions without "DLL", i.e. /MT and /MTd for release and debug builds respectively. – Nemanja Trifunovic Feb 11 '14 at 15:15
1

WxWidgets have static linking capability, never tried it myself.

UldisK
  • 1,619
  • 1
  • 17
  • 25
  • UldisK, can i use this library with static linking without any legal issues? Also, will I be able to use the Toolbox to add buttons/labels menus and other controls to my Form (window)? The code will be written automatically in source view? – MinimalTech Feb 10 '14 at 21:38
  • The library is licensed under modified LGPL. If understand correctly, one of the modifications are, that it can be static linked. I think I have seen some form builders out there, but I haven't used WxWidgets for a long time and newer with them, so I don't know how good they are. – UldisK Feb 11 '14 at 06:37
1

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!

GreenScape
  • 7,191
  • 2
  • 34
  • 64
-2

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

Community
  • 1
  • 1
OneOfOne
  • 95,033
  • 20
  • 184
  • 185
  • 1
    I think there were some leagal concerns on static linking with qt if the application is closed source... question does not state anything about that, but should be mentioned .. – UldisK Feb 10 '14 at 15:03