Question:
Why can I compile my code in Dev-C++ but in gcc, it doesn't compile my code?
Marvin
2011-08-14 08:31:34 UTC
Why can I compile my code in Dev-C++ but in gcc, it doesn't compile my code.

Dev-C++ also uses gcc as the compiler, but when I use gcc using the command prompt, it doesn't compile, it says variables are undeclared, or for my friends, it tells gcc is not an internal command.

I already did Computer>System Settings>Environment Variables>Edit Path>Add - " C:/Dev-Cpp/bin " (without quotation)
Three answers:
Silent
2011-08-14 08:38:37 UTC
If gcc says that variables are undeclared, then there's something wrong with the code you're passing to it. Maybe you're not giving it all the required source files. Since you haven't shown me your code or the command you're using to run gcc, all I can really do is guess here.



Your friends presumably do not actually have gcc installed, or have not set up their path variables correctly.



Please post the code and the EXACT error message you're getting.



Edit:

If you want help, you're going to have to provide more information. Which variable or variables were undeclared? On which lines? The error message tells you these things. They're important. Please try it again and post the exact error message. Also, please post your code at http://www.pastebin.com and include the link here.
anonymous
2011-08-14 16:15:58 UTC
It's difficult to give a definitive answer without knowing the exact error message, but I can relay my personal experience with Dev-C++ to you.



I used Dev-C++ for a school assignment once a few years back. The program worked perfectly in Dev-C++, so I turned it in. I promptly got a 60/100 on it because the professor claimed it "failed to compile." What seemed to happen was Dev-C++ assumes certain libraries are included, and since my program worked in Dev-C++ without explicitly including them, I "forgot" to include them.



The fix is to go through your code and ensure you have all of the necessary libraries explicitly included. If I remember right, the include I "forgot" was iostream.



Another problem may be that you're forgetting some parameters when compiling from the command line.
Laurence I
2011-08-14 15:37:59 UTC
all C/C++ compilers have different levels of checking



when compiling within a GUI the level parameters are passed to the command line

if you are typing in the compile command then you must always use the same

additional parameters.



usually one would create a BATCH that would do the GCC for you but

add in all the same parameters as the GUI does.



there will be so many of them it s better you look them up.



most GUI's allow you to see what they are.



as a rule most C programmers would have a terribly hard time

getting their own C programs to compile without the aid

of the compiler switches to turn off in depth checks.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...