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;
}
Getting error while compiling
Page 1 of 16 Replies - 1222 Views - Last Post: 18 August 2007 - 11:16 PM
Replies To: Getting error while compiling
#2
Re: Getting error while compiling
Posted 18 August 2007 - 10:34 PM
amrit.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;
}
#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.
#3
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
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
#4
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.
Use
[code]
std::cout<<"Hello";
'NOT
cout<<"Hello";
[/cout]
You might have to modify your environment variables.
#5
Re: Getting error while compiling
Posted 18 August 2007 - 10:53 PM
There are many alternatives
or
or
.h headers are non-standard in C++. OP is using new C++ header and include rules are same for both C and C++.
#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;
}
no2pencil, 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
#6
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.
#7
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.
In XP.
Control Panel > Advanced >Environment Variables.
See if this works in Vista, otherwise Im not sure.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|