compiling a simple code into an exe

Started by
11 comments, last by Aardvajk 17 years ago
Ok ladies and gents I cracked open my sams teach yourself C++ in 24 steps for dumb n00bs and it came with borlands compiler known as C++BuilderX Personal V. 1.0.0.1786 and I did the first step ran it fine with no errors, now comming to compiling to an exe and it gets all weird and comes up with errors even though the code is fine. heres the code: #include <iostream> int main() { std::cout << "Hello World!\n"; return 0; } soooo im totaly lost, not sure whats going on also this IS the compiler that came with the book so Im wondering if maybe I should go get somthing else or what but also the begining of the book is very vague on setup and how to compile into an exe and so forth and then just jumps right into the first lesson....this is the same opinion my father had who was a fairly proficient C++ user in around 1994 anywho any help you can give would be most appreciated.
Advertisement
Yes, that code seems to be fine.
Perhaps if you gave us the error we could help in fixing it or you could just use a different compiler. I've never used borland but if you'd like a nice free compiler I would recommend dev-cpp which is nice and its free. However if you would like a more powerful compiler Microsoft's Visual studio is nice.
You have to specify what the error was. The compiler can spit out thousands of errors, each with their own different meaning. No on can guess to help you. There is also a linking phase after the compiling, and those errors are a whole other can of worms on their own.

Do you have anything else in that file besides the above code, and do you have all your PATHs set up correctly?

Don't bother switching compilers. Your corruent compiler will suit you fine to get through the end of your book, and anything else you are likely to do for awhile now. DevCPP isn't a compiler.
the error code does not seem to be isolated to a specific portion of this short code each time I try although it does seem to favor line 1 even though I know the code is not only identical to the lesson in the book but also 100% correct also the book asks me to make a revision before attempting to compile by addine

int main(); to make the complese code look like this:

#include <iostream>

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

Im not sure what the neccessity of having TWO mains in the begining of the code is for and also with the top one having the end symbol ; .....I dont see the purpose of that but that route seems to unveil a host of new errors so I will give that free one a try is there anyway I could get you to post me a step by step for compiling? sorry super n00b here > _ >

I appreciate all of your help tyvm
Quote:Original post by Vampyre_Dark
You have to specify what the error was. The compiler can spit out thousands of errors, each with their own different meaning. No on can guess to help you. There is also a linking phase after the compiling, and those errors are a whole other can of worms on their own.

Do you have anything else in that file besides the above code, and do you have all your PATHs set up correctly?

Don't bother switching compilers. Your corruent compiler will suit you fine to get through the end of your book, and anything else you are likely to do for awhile now. DevCPP isn't a compiler.


well at this point the compiler isnt even allowing me to run the script or debug it even if I start a new file witht he txt or anything sooo Im guessing there is somthing wrong with the compiler.


nothing in the script besides that no
The code is fine. What error do you get?

BTW, you'd better use a more recent compiler. C++ BuilderX is a dated product (not that old, but kind of old anyway). It is now discontinued.

You can download a free version of Visual C++ .Net 2005 (the free version is called Express Edition). It will allow you to create console programs quite easily - the only thing you have to do is to create a new console project, and you're given existing files to play with. At this step, it's certainly the best recommandation I can give. Exact steps to create a Visual C++ project are described here.

Regards,
Quote:Original post by Vampyre_Dark
You have to specify what the error was. The compiler can spit out thousands of errors, each with their own different meaning. No on can guess to help you. There is also a linking phase after the compiling, and those errors are a whole other can of worms on their own.

Do you have anything else in that file besides the above code, and do you have all your PATHs set up correctly?

Don't bother switching compilers. Your corruent compiler will suit you fine to get through the end of your book, and anything else you are likely to do for awhile now. DevCPP isn't a compiler.


Right, sorry, IDE. It's pretty nice but as Emmanuel Deloget said you can get the express edition for free for Visual Cpp which would probably be a better choice.
Quote:Original post by Azendai
well at this point the compiler isnt even allowing me to run the script or debug it even if I start a new file witht he txt or anything sooo Im guessing there is somthing wrong with the compiler.


What does it say?

You type BCC,... then?
well the compilier has a run and a debug and then run button and their hazed out now, wont let me do either when using their code or mine so Im guessing that the compiler needs to be nixed or reinstalled at the very least *think ill try another compiler*
Quote:Original post by Azendai
well the compilier has a run and a debug and then run button and their hazed out now, wont let me do either when using their code or mine so Im guessing that the compiler needs to be nixed or reinstalled at the very least *think ill try another compiler*


You have to compile before you can run.

This topic is closed to new replies.

Advertisement