Author Topic: Noob compiler problem  (Read 8675 times)

Offline mcmillinisillin

  • Single posting newcomer
  • *
  • Posts: 5
Noob compiler problem
« on: January 10, 2011, 02:38:17 am »
I'm sure there is an explanation somewhere in this forum for my problem, but I just spent the last 2.5 hours looking here and the ret of the Internet and I just can't find a satisfactory answer.

I recently installed codeblocks and after finally figuring out that I apparently have to create a new project inside of a new project, which still makes no sense, I keep receiving an error message telling me that there is no such directory as iostream when I try to make the statement #include <iostream>. In addition, there is also an error message returned because of my next statement, using namespace std; which is according to codeblocks, is missing a series of characters between the words using and namespace. I am assuming that one of these problems is a direct result of the other but I just can't figure it out.

The code is as follows
#include <iostream >
using namespace std;

the error msgs read:
error: iostream : no such file or directory
error: expected '=', ',', ';', 'asm', or '__attribute__', before 'namespace'

I also have jcreator installed on my computer, any chance codeblocks could be searching the wrong library?

 

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Noob compiler problem
« Reply #1 on: January 10, 2011, 03:43:51 am »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline mcmillinisillin

  • Single posting newcomer
  • *
  • Posts: 5
Re: Noob compiler problem
« Reply #2 on: January 10, 2011, 06:40:24 pm »
Thank you for the reply. After carefully reading the link you posted, I made the suggested adjustment and attempted to compile. However, the exact same error messages were returned. I had already assumed that woul happen bc those instructions could only lead me to the what of the problem, which I already know. The compiler doesn't understand what I'm telling it bc it can't find the library that came with the program. I need to know why this is happening.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Noob compiler problem
« Reply #3 on: January 10, 2011, 07:24:02 pm »
Did you turn on full commandline logging, as mentioned in the link ollydbg has posted ?
If yes copy the content of the build log and paste it here.

By the way:please use code-tags to surround the code (and error messages) you post here (highlght the text and click on the hash-sign).

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
Re: Noob compiler problem
« Reply #4 on: January 10, 2011, 10:58:27 pm »
I think it is as simple as removing the whitespace after iostream.

You wrote

Code
#include <iostream >

but it should be

Code
#include <iostream>

Mark the little difference.

Regards

frithjofh
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline mcmillinisillin

  • Single posting newcomer
  • *
  • Posts: 5
Re: Noob compiler problem
« Reply #5 on: January 10, 2011, 11:04:41 pm »
I did change to full command line, however I do not have Internet access on my desktop, I am posting from my iPhone. the program is just a simple tip calculator I'm am doing as an excercise from my textbook, and as this is my first time using c++ I just copied the code directly from the book just to see if the compiler would work.
The code is exactly as I posted previously, the error msgs are:

<code>ming32-gcc.exe.      -c  "C:\Documents and Settings\My Name\My Documents\programs\CodeBlocks\ Untitled1.c" -o "C:\Documents and Settings\My Name\My Documents\programs\CodeBlocks\Untitled1.o"
//the following text is in red
C:\Documents and Settings\My Name\My Documents\programs\CodeBlocks\Untitled1.c:3:20: error: iostream: No such file or directory
C:\Documents and Settings\My Name\My Documents\programs\CodeBlocks\Untitled1.c:4: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'namespace'<code>

the following error messages seem a little irrelevant seeing as they have to be caused by the fact that iostream and namespace are not being recognized. And as I said before, I'm typing all of this on an iPhone and it's extremely tedious. I will post the following two error msgs just in case:

<code>C:\Documents an Settings\My Name\My Documents\programs\CodeBlocks\Untitled1.c: In function 'main':
C:\Documents and Settings\My Name\My Documents\programs\CodeBlocks\Untitled1.c:16: error: 'cout' undeclared (first use in function)<code>

Offline mcmillinisillin

  • Single posting newcomer
  • *
  • Posts: 5
Re: Noob compiler problem
« Reply #6 on: January 10, 2011, 11:07:14 pm »
The whitespace is a typo in the post, it is correct in the code, thank you though, I really wish It was that.
Also, sorry about the code tags I did it wrong

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Noob compiler problem
« Reply #7 on: January 10, 2011, 11:25:48 pm »
It's what I thought.

We have tons of posts about the same issue.

And it shows clearly, that you did not read the part of the wiki-article (link posted by olldbg) carefully.
There is an important hint in the last line of te chapter, that shows you the solution of your problem.

You should of course know that there is a difference between C and C++, but this is beyond the scope of our forum.

Offline mcmillinisillin

  • Single posting newcomer
  • *
  • Posts: 5
Re: Noob compiler problem
« Reply #8 on: January 11, 2011, 12:47:02 am »
Thank you.

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Noob compiler problem
« Reply #9 on: January 11, 2011, 05:57:26 pm »
I would like to take this opportunity to suggest separating the filters in the save dialog, so C and C++ do not get mixed. Have one filter for C files and another one for C++ files. C++ could be the default.

Another option would be doing something like in Microsoft's IDE, where it is clear what type of file your are saving (C, C++, header, ...).