mega compile errors for small program
Hi guys, there is something really strange going on with an assignment due by midnight!!
I have read archives, advice etc and can't relate it to what I am doing.
I have to write a library and implementation file and then a program that includes these.
The library is ok I think, and so is the implementation file which I have compiled to .o (prob wrong terminology but not much of a clue for this stuff.)
My driver file is called quadraticDriver.cpp yet when I attempt to compile it (g++ -c quadraticDriver.cpp) there are some really strange errors.
So here are some of them, I will be watching for the postings and any ideas would really be appreciated!!
QuadraticDriver.cpp:1: error: syntax error before `/' token
In file included from /usr/include/c++/3.3.2/i386-redhat-linux/bits/c++locale.h
/usr/include/langinfo.h:48: error: `__LC_TIME' was not declared in this scope
/usr/include/langinfo.h:48: error: enumerator value for `ABDAY_1' not integer
/usr/include/langinfo.h:241: error: `__LC_COLLATE' was not declared in this
/usr/include/langinfo.h:241: error: enumerator value for `_NL_COLLATE_NRULES'
not integer constant
/usr/include/langinfo.h:265: error: `__LC_CTYPE' was not declared in this scope
/usr/include/langinfo.h:265: error: enumerator value for `_NL_CTYPE_CLASS' not
/usr/include/langinfo.h:356: error: `__LC_MONETARY' was not declared in this
/usr/include/langinfo.h:356: error: enumerator value for `__INT_CURR_SYMBOL'
not integer constant
/usr/include/langinfo.h:470: error: `__LC_NUMERIC' was not declared in this
/usr/include/langinfo.h:470: error: enumerator value for `__DECIMAL_POINT' not
/usr/include/langinfo.h:491: error: `__LC_MESSAGES' was not declared in this
/usr/include/langinfo.h:491: error: enumerator value for `__YESEXPR' not
/usr/include/langinfo.h:506: error: `__LC_PAPER' was not declared in this scope
/usr/include/langinfo.h:506: error: enumerator value for `_NL_PAPER_HEIGHT' not
/usr/include/langinfo.h:511: error: `__LC_NAME' was not declared in this scope
/usr/include/langinfo.h:511: error: enumerator value for `_NL_NAME_NAME_FMT'
not integer constant
/usr/include/langinfo.h:520: error: `__LC_ADDRESS' was not declared in this
/usr/include/langinfo.h:520: error: enumerator value for `
_NL_ADDRESS_POSTAL_FMT' not integer constant
/usr/include/langinfo.h:535: error: `__LC_TELEPHONE' was not declared in this
/usr/include/langinfo.h:535: error: enumerator value for `
_NL_TELEPHONE_TEL_INT_FMT' not integer constant
/usr/include/langinfo.h:542: error: `__LC_MEASUREMENT' was not declared in this
/usr/include/langinfo.h:542: error: enumerator value for `
_NL_MEASUREMENT_MEASUREMENT' not integer constant
/usr/include/langinfo.h:546: error: `__LC_IDENTIFICATION' was not declared in
/usr/include/langinfo.h:546: error: enumerator value for `
_NL_IDENTIFICATION_TITLE' not integer constant
QuadraticDriver.cpp: In function `int main()':
QuadraticDriver.cpp:13: error: `cout' undeclared (first use this function)
QuadraticDriver.cpp:13: error: (Each undeclared identifier is reported only
once for each function it appears in.)
QuadraticDriver.cpp:27: error: `cin' undeclared (first use this function)
QuadraticDriver.cpp:31: error: syntax error before `,' token
My general advice for beginners:
Well it's too late now (after midnight) but maybe this will help with your next assignment.
Here's the big secret to sucessful programming:
Don't write the whole freekin' program before compiling and running! It is very difficult to debug a program with multiple errors.
- Start-out with a "Hello World" type of program.
- Add a one or two lines of code.
- Test-compile and test-run.
- Debug as required.
- Add one or two more lines of code, etc.
Note that you can't just type-in your program in line-number sequence, test-compiling as you go. You have to figure-out the best development sequence for test-compiling and test-running as you go along... This is part of the fun of programming!
It is also helpful to add some extra cout statements so you can "see" what's going on before the program is completed. You can remove them or comment them out once your program is debugged.
This may seem silly, but it will greatly reduce your frustration-level! And, experienced programmers do the same thing (with larger chunks of code, of course).
Compilers are easily confused. They know there is an error, but they don't know what you are trying to do. Sometimes one real error can cause the compiler to report hundreds of errors! If you test-compile every few lines, at least you know where to look for the error.
When the compiler reports errors, the first actual error is usually near the reported line-number. After that, the reported errors may just be effects of the first error.
Linker errors (you had lots of 'em) are harder to track down. Mainly, because there are no line numbers.