Friday, July 31, 2009

Help compiling in Visual C++ Studio 2005?

This may sound like a stupid question, but when I try to compile code, the compile option is greyed out. I've never written a program before, and I'm trying to learn C++. It turns out the program I'm trying to use to compile it is more complicated than the coding itself. I've tried with both a "New Project", and with a "New File" alone. I've tried reading the help files, but they give very little help, as with most Microsoft products. I'm about to give up, so if anyone knows of another/better C++ compiler that is free, please point me to it.

Help compiling in Visual C++ Studio 2005?
// here's what I did with the VC 6 "intro edition":





1.) Open Visual C++ and click "file" and "new" from the main menu.


2.) Click "Win32 Application"


3.) Fill in the project name and location in the appropriate dialog boxes.


4.) Click "OK" , "finish" and "OK" to set up an empty project.


5.) Click "file", "new", "C++ source file" .


6.) Name the file, click "OK" and cut N' paste the following:





#include %26lt;windows.h%26gt;


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)


{MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);return 0;}





7.) press the %26lt;F5%26gt; key and "OK" to compile and execute.





Hope this works for you. What you ought to get is a little popup window that can be dragged around, minimized and closed. DOS stuff is in the realm of "Console Application" projects. This is probably where one would want to start if they are just learning C.





Don't feel bad if Visual C++ seems frustrating - because it is. I spent six years studying Windows API and MFC classes and still can't program much more than "combo boxes". These are easy if one lets Microsoft manage everything but really hard to do if one wants to code everything from scratch - and Micro$ isn't going to be much help assisting you if you try and figure out how their little black boxes work..





There are quite a few "open source" compilers and the best appears to be the DevC compiler by bloodshed. It has its own nice User interface, so just type and compile and be happy. Open Watcom is another popular (READ: "free") compiler. Boorland is the other major player as far as expensive, commercial compilers go. Microsoft has "bundeled" it's latest development suite to include BASIC and a strange C/BASIC hybrid known as "C#", which is what their "NET" framework is all about. Finally, LINUX comes with its own compiler known as "GCC" and there are DOS versions of this if one likes a nice black %26amp; white, totally command line driven environment. Do be aware that if one goes this route, they will need to know a few things about "makefiles" and "compiler switches" if one desires to write anything sophisticated.





BTW: I learned the fundamentals of "C" from something I found on some hard drive I dug out of a bargain bin. Besides a narritive of some guy's divorse, it contained the "learn C" compiler written in 1986. This was so primitive it didn't even have the ability to save executable files, it mearly compiled code .





hope this helps %26amp; good luck!
Reply:I would reccomend dev c++ as a c++ compiler. As a first language, I would not reccomend c++ largely for this reason. I have always recommended ruby as a good first language because it is so standardized and you get the compiler from like ruby.com and tuts will teach directly for that compiler. It allows you to get over the learning curve of programming without the learning to use the compiler hassle.





I personally use dev c++ most of the time, but msvc++ when working with directx.
Reply:You can't "Compile" (Ctrl/F7) unless you've selected a .cpp source file. In general, though, you usually do a Build Solution to compile and link evertyhing in the program. Compile compiles only that one source module..
Reply:Try reinstalling it.
Reply:When it comes to professional developer tools (any profession's tools for that matter), the expectation is that either you are knowledgeable enough to know how to use it or are a capable individual who can learn quickly. I say this because you think jumping compilers will magically solve your problem. It won't, as you do not have the requisite knowledge (or the experience of a developer) to suddenly start working on any compiler you get.





In Visual Studio, projects are stored in solutions. So here's how it works.





Solution


- multiple projects


- each project contains multiple files pertaining to that project.





You need:


- a solution


- a C++ console project within that solution


- your code files within that c++ project.





You should be able to accomplish the above by starting a new project. Make sure you allow it to create a solution (there should be a checkbox to that effect).


No comments:

Post a Comment