Results 1 to 10 of 10
Hello, somebody here knows about gcc?
How can I compile this program in CentOS 5.3?
#include<cstdlib>
#include<iostream>
#define pi 3.141592
using namespace std;
int main(int argc, char *argv[])
{
float ...
- 07-22-2009 #1Just Joined!
- Join Date
- Jul 2009
- Posts
- 8
Compiling in CentOS
Hello, somebody here knows about gcc?
How can I compile this program in CentOS 5.3?
#include<cstdlib>
#include<iostream>
#define pi 3.141592
using namespace std;
int main(int argc, char *argv[])
{
float radio, longitud, area;
cin>> radio;
longitud = 2*radio*radio;
area = pi*radio*radio;
cout<<"radio ="<<radio<<endl;
cout<<"area ="<<area<<endl;
cout<<"Presione Enter para continuar"; //system("PAUSE");
cint.get(); //return EXIT_SUCCESS;
return 0;
}
If you are using DEV C++ you are suppose to use
system("PAUSE");
return EXIT_SUCCESS;
That is why I use cint.get()...
When I compile I use: gcc filename.cpp
so I can enter the value
or gcc -c filename.cpp but nothing happens...
Do you have any idea, what is wrong or what is the appropriate command to run it? .
Thank's
- 07-22-2009 #2
You're trying to compile C++ code using gcc. That is not going to work. Use g++ instead.
Registered Linux user #270181
TechieMoe's Tech Rants
- 07-22-2009 #3
Try something like
Code:g++ -o program program.cpp
- 07-24-2009 #4Just Joined!
- Join Date
- Jul 2009
- Posts
- 8
gcc
Look I tried this:
g++ program.cpp -o prog
Then it generates the prog output but the thing is to know how to execute the output?
I try emacs prog but it does not work since prog must be an .exe or something...
I try only prog too but it does not work either.
So how do you execute the output files?
See ya...
- 07-24-2009 #5Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Because it puts the executable in the current directory where you compiled it, you probably need to preface the command with a ./ - as in
The current directory is not part of your path by default unless you add it to your PATH environment variable in ~/.bash_profile (assuming you are running the bash shell).Code:./prog
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 07-24-2009 #6Just Joined!
- Join Date
- Jul 2009
- Posts
- 8
gcc output
Hello, yeap the output can not be executed.
It says bash: file: command not found.
I did what you suggest ~/.bash_profile and I added
PATH=usr/bin/ld
I think this is a file that I have just created by typing ~./bash_profile
So I guess that I open another file and give some inputs so I can see the output files from gcc...
Any idea bout it, I will be listening, thank you for your time...
- 07-24-2009 #7Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Actually, in ~/.bash_profile do this to set your PATH:
What you did was to look in the local directory for executables in usr/bin/ld, which likely doesn't exist, so as a result, most everything will not execute on a command line for you.Code:export PATH=.:${PATH}
Also, for this to take effect, you need to logout of the system and back in again.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 07-24-2009 #8Just Joined!
- Join Date
- Jul 2009
- Posts
- 8
- 07-24-2009 #9Registered Linux user #270181
TechieMoe's Tech Rants
- 07-27-2009 #10Just Joined!
- Join Date
- Jul 2009
- Posts
- 8
gcc output
Hello, the problem was that originally I could not execute the output file.
Now I can do with the ./ that I show you before.
I was looking how to execute the output file from the command line just by typing the file without (./) but nothing yet.
I am sure it is possiblly. In the same way I am looking how to give colors to the emac files written in verilog. I think I have to modify a couple of files so I can achieve this. If somebody knows about it, I will be around, thank you for your time.
Mario



Reply With Quote