Stand Alone C++

This may seem like a noob question, but I'm going to give it a shot anyway.

I've been playing around with C++ in Windows, making little command line programs and I'm starting to learn the Win32 API for GUIs, but I was wondering something.

Is it possible to write C++ applications that could (somehow) be put on a disc and ran straight off of a box? Like just pop the disc in and load it from the boot menu.

If it is, what would I need to look in to to do it?
this has less to do with C++ and more to do with autorun settings on a disc.

I don't know much about it myself, but CDs and stuff have an autorun file that gives a path of a program to run when the disc is inserted. Just make one of those and tell it to run your program.


EDIT: a quick google search found this: http://www.phdcc.com/shellrun/autorun.htm
Last edited on
You also need to make sure your executable comes with all the required DLLs. For example, the current version of GCC compiles your code to require one or more DLLs found in the ~MinGW\bin directory (plus any others your program requires, such as stuff from Boost or SDL).

For example:
D:\prog\foo> g++ --version
g++ (GCC) 4.4.0
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

D:\prog\foo> copy con a.cpp
#include <iostream>
using namespace std;

int main()
  {
  cout << "Hello world!\n";
  return 0;
  }

^Z
        1 file(s) copied.

D:\prog\foo> g++ -Wall -ansi -pedantic a.cpp

D:\prog\foo> pedump a.exe |grep "^.*\.dll"
  KERNEL32.dll
  msvcrt.dll
  msvcrt.dll
  libgcc_s_dw2-1.dll

D:\prog\foo> _

This shows that my program requires exactly three DLLs to function. The first two come with Windows systems. The third is part of the current MinGW compiler package. I'll need to include it with copies of my program.

(You can get pedump here: http://www.wheaty.net/downloads.htm )

The alternative method is to tell GCC to statically link the libgcc, which will result in a larger executable and (possibly) violate something horrible somewhere...

Alas. Hope this helps.
Both suggestions are great. I'm working on them now.

Another thing I want to know is if I can use C++ to do graphic work as well. I know it's going to be tough if it is possible, and I'm not expecting anything like a pre-written API for menus and whatnot.

Pretty much what I'm asking is if C++ can do anything graphic, because I want to see if I can build a simple program with some kind of graphics that can run on a system in a stand alone manner.

Edit: Also, upon trying to use pedump, I get an error that says:

1
2
'grep' is not recognized as an internal or external command,
operable program or batch file.


So... I don't know what to do about that xD
Last edited on
C++ does graphical stuff quite well. Games, media players, etc are commonly written in C++.

You just need a library. There are many libs availble, but in order to recommend one, you'll have to be more specific about what you mean by "do some kind of graphics".

Actually for right now, GUI things that you would see on common programs would be amazing. What types of libraries would I need?

Actually, upon thinking about it, if I figured out the DLLs a Win32 program used, would that be able to run outside of windows if I provided the DLLs?
So... I don't know what to do about that xD
http://gnuwin32.sourceforge.net/packages/grep.htm

What types of libraries would I need?
http://en.wikipedia.org/wiki/Widget_toolkit

... would that be able to run outside of windows if I provided the DLLs?
No. An PE32 requires Windows.

Hope this helps.
An PE32 requires Windows.
Or Wine.
Ok, grep works now, thanks =D

So, if I, say, used wxWidgets, I could make an exe and an autorun.inf file, provide the DLLs needed (as stated by pedump), and my wxWidgets application would run? Or any toolkit for that matter?
Yes.

Wine is Windows, emulated. But yes. (How did I write "an PE32..."?)
Ok, so I burned the files, DLLs, etc. to a disc and, surprise surprise, it didn't work as planned.

I have an autorun.inf file, and when I pop the disc into my computer while Windows is running, it works. But, if I try to get my computer just to load it from CD via boot menu, it doesn't do anything.

It's worth noting, the file in question was written and built in Visual Studio 2008 Express. Is there a certain way it needs to be built to load outside of Windows?
No. A Windows executable needs Windows.

If you want it to boot from CD, you have to write your own bootloader and basic OS. You might want to play around with something like Puppy Linux or Damn Small Linux or the like
http://bengross.com/smallunix.html

Good luck!
closed account (1yR4jE8b)
Wine stands for Wine Is Not An Emulator btw :P

It's a compatibility layer/translator for Windows to Linux/Unix system calls, not an OS emulator.
Wine stands for Wine Is Not An Emulator btw :P


But it's still clearly an emulator.


ALso, LAME stands for Lame Ain't an MP3 Encoder -- but it's still clearly an mp3 encoder.
It's an emulator. It emulates the Windows API.
It's too thick to be a compatibility layer, and unless you can give a different definition, "translator" is in this context a synonym of "emulator".
Topic archived. No new replies allowed.