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.
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.
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...
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.
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".
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?
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?
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
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".