Hello there! I will jump in straight to the problem. Take a look at the following scenario: I have a couple of files (.h and .cpp) and a main method in one of these files. All these files when built will give you an exe file with "hello world!" printing in the console window. The problem here is that I need to build the files through visual studio or some sort of compiler. I want to create a new program that will take in these couple of files and when I run this new program, it will create an executable file from those files that it took. Is there a library do this for me? PLEASE PLEASE HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Um, I'm not quite sure what you're asking. You don't need a "library" to put these files together - Visual Studio itself is the thing that will compile these files and link them together to make the executable (*).
Just create an empty project in VS, and add the files that you want to compile and link to make your executable. Then build the project.
As zapshe says, the executable will be built into a directory called either "Debug" or "Release", depending on what type of build you're doing.
(*) Strictly speaking, it's the compiler that builds and links the executable. VS runs the compiler, and tells it what files to build. But you don't need to worry about that.
I know everything you're saying but you are not getting my point. I know visual studio provides the creation of exe files. Here is what I want to do: I have a program. It asks me for some files: I give it some files (these files are .h and .cpp and one of them include a main method). Then I click "export" and it generates a .exe file. When I run the exe file it runs the code on the files that I gave it (.h and .cpp). Thanks for the reply. Please don't get angry with me!
Um, unfortunately it seems like this is getting a little too complicated. This may look like off topic but trust me it isn't. Can anyone just tell me how the Unity engine exports a game. When you make a game with unity, you can export it as an independent playable game. How does unity go about doing that? thanks.
Unity works with C# and .NET, so "all" the Unity SDK has to do is build a .NET executable that includes the game's resources inside the binary. To do this, it can either use Microsoft's compiler (I doubt it, but I've never used Unity, so I can't say it definitely doesn't do that), or the Mono Project's compiler.
One way or another, a program that takes source code and produces an executable must necessarily either be, or indirectly execute a compiler. There's no way around this.
I don't think Unity is open-source, and I'm not too familiar with Unity, much less its internals. But the basic idea is that when you publish a build as a standalone application, internally the Unity IDE will be calling some sort of compiler, which generates an EXE file, and any assets will be copied over and integrated as well.
Ultimately, by building a command line, and running it, whethr directly on an actual command line, or by calling some kind of createProcess function.
Either way, a command line is built. If it were calling the g++ compiler, it would effectively be typing (for example): g++ somefile.cpp someotherfile.cpp -o output.exe
on the command line and pressing enter.
If you want to do this youself, first you need to learn how to use a compiler so you know what command line to build.
you may want to redirect the output of g++ to a file and parse that before attempting to run first.exe; for your own sake, and throw an error or something if the compile failed.
you can redirect output of any program to a file via > file
so g++ ...stuff... >gout.txt for example
system is dumb as a stick. IT ALWAYS SUCCEEDS. Let me say that again: IT ALWAYS SUCCEEDS! What that means is that you try to compile, and system looks like it succeeded even if g++ failed. You try to run first.exe, and it looks like it succeeded, even if there is no such program. And so on. At some point you are going to have assumed you did something that did not actually happen, and bad things will happen. Some of the alternatives to system may be able to tap a return code to see if it was a success, or you can do your own babysitting, but you must check every step to ensure that what you think happened, actually did happen. System is also a security risk, but we have covered that to death... IMHO if they are far enough to hack via that, they already own your system anyway.