Hi everyone! Well, as you can tell by the title, I am an absolute beginner in C++. I'm currently enrolled in a data structures class at my university and will be using C++ to learn data structure concepts. I've just finished my first week of class and I'm definitely confused. It seems like everyone in my class knows what's going on, but I'm sitting there twiddling my thumbs.
First of all, I understand what a C++ compiler is..or at least I think I do..It converts the C++ code I write into a code that my computer can read, right?
My teacher says to use MinGW, but after several attemps at trying to install it onto my computer(Windows 7 machine), I can't seem to find the executable file. I tried using the command prompt, but I'm not even sure what to type in to get it started(as you can see, I am a total beginner)...I also tried to install Cygwin and got too frustrated with it..Now I'm thinking about installing Visual C++ Express, which seems to be free once you register it..
Sooo, my teacher will be assigning a project tomorrow and I'm really stressed out since I don't even know where to start writing the code. He says that the program will have to run on his Mac notebook..If I use Visual C++, will he be able to run the program on his Mac? Or, can someone tell me, in steps, how to install MinGW onto my Windows 7 machine so that I can create programs that my professor will be able to run? I am learning the language, but I just don't know where to type this language into in order to get a file that I can send to my teacher...He said that we should use MinGW but I'm so frustrated with trying to install it...Can someone please help me out here?
Maybe I installed it wrong...I tried following the How-To on the MinGW site. It said to download MinGW-get and then unzip it into C:/MinGW...I did that, and then I typed 'mingw-get install gcc g++ mingw32-make' into the command promp and things started downloading. When I went into C:/MinGW, there were more files than were unzipped from the original download, so I knew something downloaded. What do I do from there? There was nothing new in my start menu, and there are no executables in C:/MinGW...
After unzip it into c:/MinGw, open start menu--> run--> cmd, console will open. then write that in console.. cd C:/MinGW
After that you can compile a file writed with text editor before using "gcc file_name.c".
to run file compiled, write console "a".
Of course.... if you're not a masochist you can just get an IDE. Then just press a single button to bulid your exe without having to type some arcane, cryptic BS into the command prompt.
khris (7) Link to this post Aug 30, 2010 at 12:56am
hasanzan, I think I figured it out...
I compiled it by typing "g++ -o file_name file_name.cpp" and my executable was named "file_name.exe".
So for your example, I think you can type "gcc -o file_name file_name.c" and the executable file will be called file_name.exe.
going through the cmd way, you type gcc to start the compiling followed by anything you wish to be compiled in it followed by "-o filename"
e.g.
"gcc file_name.c my_library.h -o outputname"
which will generate an exe called: "outputname.exe" using the libraries compiled with your program "file_name.c" and "my_library.h"
Please note that if you compile the above code then "file_name.c" and "my_library.h" will need to be in your current working directory when you call the function