New to programming, error message.

  • (2 Pages)
  • +
  • 1
  • 2

25 Replies - 547 Views - Last Post: 18 April 2013 - 02:32 PM Rate Topic: -----

#1 david joh  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 17-April 13

New to programming, error message.

Posted 17 April 2013 - 05:31 PM

I just started programming yesterday, and i ran into a problem i get this error message everytime i try and build.
fatal error: iostream: No such file or directory
compilation terminated.
Heres the code, straight from the book
#include <iostream>

using namespace std;

int main()
{
    int mynumber;
    mynumber = 10;
    cout << mynumber << endl;
    return 0;
}


Is This A Good Question/Topic? 0
  • +

Replies To: New to programming, error message.

#2 jimblumberg  Icon User is offline

  • member icon


Reputation: 4068
  • View blog
  • Posts: 12,549
  • Joined: 25-December 09

Re: New to programming, error message.

Posted 17 April 2013 - 05:50 PM

What compiler are you using?

Jim
Was This Post Helpful? 0
  • +
  • -

#3 david joh  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 17-April 13

Re: New to programming, error message.

Posted 17 April 2013 - 06:07 PM

GNU GCC Compiler
Was This Post Helpful? 0
  • +
  • -

#4 jimblumberg  Icon User is offline

  • member icon


Reputation: 4068
  • View blog
  • Posts: 12,549
  • Joined: 25-December 09

Re: New to programming, error message.

Posted 17 April 2013 - 06:15 PM

How are you trying to compile that code? What is the file extension?

Jim
Was This Post Helpful? 0
  • +
  • -

#5 david joh  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 17-April 13

Re: New to programming, error message.

Posted 17 April 2013 - 06:17 PM

this is gonna sound extremely sad, but what does that mean...
again second day programming :)
Was This Post Helpful? 0
  • +
  • -

#6 jimblumberg  Icon User is offline

  • member icon


Reputation: 4068
  • View blog
  • Posts: 12,549
  • Joined: 25-December 09

Re: New to programming, error message.

Posted 17 April 2013 - 06:29 PM

If you don't know what a file extension is, or what it means to compile your program then I suggest you re-read the first several chapters in your book. These are such basic things that you should already know?

Jim
Was This Post Helpful? 0
  • +
  • -

#7 david joh  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 17-April 13

Re: New to programming, error message.

Posted 17 April 2013 - 06:34 PM

I know what compile means, but the book has not mentioned anything about file extensions.
Was This Post Helpful? 0
  • +
  • -

#8 jimblumberg  Icon User is offline

  • member icon


Reputation: 4068
  • View blog
  • Posts: 12,549
  • Joined: 25-December 09

Re: New to programming, error message.

Posted 17 April 2013 - 06:36 PM

File extensions are part of your basic file system functionality. Maybe you need to find a book that explains your operating system and it's basic file system.


What exactly did you name your file?

Jim
Was This Post Helpful? 0
  • +
  • -

#9 david joh  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 17-April 13

Re: New to programming, error message.

Posted 17 April 2013 - 06:52 PM

I know what they are now, i was being stupid, i believe its untitled1.c or main.ccp

Sorry, i think its Hello World.cbp
Was This Post Helpful? 0
  • +
  • -

#10 jimblumberg  Icon User is offline

  • member icon


Reputation: 4068
  • View blog
  • Posts: 12,549
  • Joined: 25-December 09

Re: New to programming, error message.

Posted 17 April 2013 - 07:19 PM

Quote

Sorry, i think its Hello World.cbp

No that's your project name.

I need to know what you named your source file. It is important to know whether you named your source file with a .c or .cpp extension!

Jim

This post has been edited by jimblumberg: 17 April 2013 - 07:20 PM

Was This Post Helpful? 0
  • +
  • -

#11 david joh  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 17-April 13

Re: New to programming, error message.

Posted 17 April 2013 - 07:24 PM

untitled1.c
Was This Post Helpful? 0
  • +
  • -

#12 jimblumberg  Icon User is offline

  • member icon


Reputation: 4068
  • View blog
  • Posts: 12,549
  • Joined: 25-December 09

Re: New to programming, error message.

Posted 17 April 2013 - 07:49 PM

You need to rename this file so it ends with a .cpp file so your compiler recognizes it as a C++ program, not a C program.

The other option would be to create a new C++ project make sure you select a console application, and select a C++ program, and then type in a new title for your project. Make sure your project directory is in the correct place (Not under the Program Files directory), select next make sure both the check boxes are selected, and press finish.

You should then have a new project with a simple C++ source file you can compile to make sure your compiler is properly setup.


Jim
Was This Post Helpful? 0
  • +
  • -

#13 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1074
  • View blog
  • Posts: 4,533
  • Joined: 09-June 09

Re: New to programming, error message.

Posted 17 April 2013 - 10:00 PM

You can't use gcc to compile a c++ program. Try g++.

gcc stands for GNU c compiler (not c++)

This post has been edited by jjl: 17 April 2013 - 10:01 PM

Was This Post Helpful? 0
  • +
  • -

#14 david joh  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 17-April 13

Re: New to programming, error message.

Posted 18 April 2013 - 01:03 PM

I just changed the file type to .cpp, now it gives me this error message
mingw32-g++.exe: error: obj\Debug\Untitled1.o: No such file or directory
The same code as before, just with .cpp instead .c
Was This Post Helpful? 0
  • +
  • -

#15 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1074
  • View blog
  • Posts: 4,533
  • Joined: 09-June 09

Re: New to programming, error message.

Posted 18 April 2013 - 01:24 PM

Post the command that you use at the terminal to compile your C++ program.

It should look something like this

g++ -Wall Untitled.cpp -o

This post has been edited by jjl: 18 April 2013 - 01:24 PM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2