6 Replies - 1345 Views - Last Post: 18 August 2007 - 11:16 PM Rate Topic: -----

#1 amrit.alok  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 18-August 07

Getting error while compiling

Post icon  Posted 18 August 2007 - 10:30 PM

First of all I am using Vista as my operating system. It is 32 bit OS. And I having hard time getting my c++ programs to be compiled. Even a basic program for showing any message is not being compiled. While compilation I get the error that cout is undeclared. I am using bloodshed C++ compiler. The code is :-

#include <iostream>

int main()
{
cout << "Hello";
return 0;

}

Is This A Good Question/Topic? 0
  • +

Replies To: Getting error while compiling

#2 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5365
  • View blog
  • Posts: 27,329
  • Joined: 10-May 07

Re: Getting error while compiling

Posted 18 August 2007 - 10:34 PM

View Postamrit.alok, on 18 Aug, 2007 - 10:30 PM, said:

First of all I am using Vista as my operating system. It is 32 bit OS. And I having hard time getting my c++ programs to be compiled. Even a basic program for showing any message is not being compiled. While compilation I get the error that cout is undeclared. I am using bloodshed C++ compiler. The code is :-

#include <iostream>

int main()
{
cout << "Hello";
return 0;

}

Try printf instead.

#include <stdio.h>
int main(void) {
  printf("Hello\n";
  return 0;
}



Could be you need to either drop the < & > or make iostream iostream.h. I'm not 100% familiar with the C++ include syntax, over C.
Was This Post Helpful? 0
  • +
  • -

#3 amrit.alok  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 18-August 07

Re: Getting error while compiling

Posted 18 August 2007 - 10:43 PM

#include <iostream.h>
int main(void) {
printf("Hello\n";
return 0;
}
I tried your code and still cannot find any solution. On the compile log I get this :

Compiler: Default compiler
Building Makefile: "C:\Users\Amrit\Makefile.win"
Executing make...
make.exe -f "C:\Users\Amrit\Makefile.win" all
g++.exe -c Hell.cpp -o Hell.o -I"C:/Dev-Cpp/include/c++/3.3.1" -I"C:/Dev-Cpp/include/c++/3.3.1/mingw32" -I"C:/Dev-Cpp/include/c++/3.3.1/backward" -I"C:/Dev-Cpp/lib/gcc-lib/mingw32/3.3.1/include" -I"C:/Dev-Cpp/include"

g++.exe Hell.o -o "Project1.exe" -L"C:/Dev-Cpp/lib"

ld: cannot open crt2.o: No such file or directory

make.exe: *** [Project1.exe] Error 1

Execution terminated


So the code cannot be compiled
Was This Post Helpful? 0
  • +
  • -

#4 Louisda16th  Icon User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Re: Getting error while compiling

Posted 18 August 2007 - 10:51 PM

In your C++ code,
Use
[code]
std::cout<<"Hello";
'NOT
cout<<"Hello";
[/cout]
You might have to modify your environment variables.
Was This Post Helpful? 0
  • +
  • -

#5 Xing  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Re: Getting error while compiling

Posted 18 August 2007 - 10:53 PM

There are many alternatives
#include <iostream>
using namespace std;
int main()
{
	cout << "Hello";
	return 0;
	
}



or

#include <iostream>

int main()
{
	std::cout << "Hello";
	return 0;
	
}



or

#include <iostream>
using std::cout;
int main()
{
	cout << "Hello";
	return 0;
	
}




View Postno2pencil, on 19 Aug, 2007 - 11:04 AM, said:

Could be you need to either drop the < & > or make iostream iostream.h. I'm not 100% familiar with the C++ include syntax, over C.

.h headers are non-standard in C++. OP is using new C++ header and include rules are same for both C and C++.

This post has been edited by Xing: 18 August 2007 - 10:53 PM

Was This Post Helpful? 0
  • +
  • -

#6 amrit.alok  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 18-August 07

Re: Getting error while compiling

Posted 18 August 2007 - 11:07 PM

I do not know how to modify the environment variables. Can you guide me through. Using the Dev - C++ compiler.
Was This Post Helpful? 0
  • +
  • -

#7 Louisda16th  Icon User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Re: Getting error while compiling

Posted 18 August 2007 - 11:16 PM

I've never used vista. But I don't think you can do it easily like in XP. Vista has a lot of blocks because of security.
In XP.
Control Panel > Advanced >Environment Variables.

See if this works in Vista, otherwise Im not sure.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1