LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   What are the commands to use to check whether the gcc compiler is working? (https://www.linuxquestions.org/questions/linux-software-2/what-are-the-commands-to-use-to-check-whether-the-gcc-compiler-is-working-570543/)

babyswan 07-18-2007 08:23 PM

What are the commands to use to check whether the gcc compiler is working?
 
Hi there. I am doing a project on firmware and Linksys router. A intrusion detection device.
I was asked to use the gcc compiler to compiler codes.
However I am lost. I do not know how to use the gcc compiler at all. The internet research is not efficient enough.

Does anyone know what are the commands to test and check whether the gcc compiler is working?
How do I know whether the compiler is working? What are the commands to test that it works?
Do i also type the commands at the command shell prompt?
I hope someone replies me fast as no one is able to help me with this. I am feeling so stressed up right now because the project module points is a lot and I think i am failing this module.


Very much appreciated if some1 is able to help me! *sobz*

babyswan 07-18-2007 08:31 PM

when i type gcc at the command shell prompt, it says no gcc....what does this mean?
I have already installed the gcc.4.1.2.tar.bz and i have already extracted it...isnt this the compiler??? I am so losttt as i do not have any knowlege of this.
helpppp !

babyswan 07-18-2007 09:02 PM

sorry there is a typo error above, what i mean is when i typed gcc at the command shell prompt, it says bash command not found, something like this.
I head that there is a need to install a package but where am i able to find this package and how does it work with the gcc.2.1.4.tar.bz?

I really hope someone will be able to help me with this because i am very worried right now..my project deadline is in less than a mths time for now.

chadl 07-18-2007 09:18 PM

The best way to test GCC is to compile a simple C program. If the program compiled, then you know that GCC is working.

If you really want to install from a source tarball, the documentation for GCC is really well written... http://gcc.gnu.org/install/

Note that if you don't have any C++ compiler installed, then you will need to get a binary version of GCC, as you can't compile the source version of GCC without a compiler of some type. This is why I recommend using your distributions package manager. Binary versions for assorted platforms can be found at http://gcc.gnu.org/install/binaries.html if you can't use your package manager for whatever reason.

If you want more detailed help, you will need to put your distribution in your profile. I use Gentoo, so I don't frequently deal with systems that don't have GCC installed.

YouWillNverWalkAlone 07-18-2007 10:21 PM

how m i going to know the distro?because i m using a linux machine from the school.

babyswan 07-19-2007 02:07 AM

hiii there thank you so much for respondinggg!!!!!

my distribution is redhat 9...
i am still unable to find the gcc package...
where am i be able to find this gcc compiler package and install it?
After that is there a need for further configuration?

lazlow 07-19-2007 08:43 AM

Support for Redhat9 was dropped more than four years ago. There are not updates available for it(of any kind). Your admin should update to a supported modern OS.

chadl 07-19-2007 07:35 PM

Do you have root on the box? If you don't, then you will not be able to install GCC (you can most likely run it, but it will be more complicated, esp if you are not sure about what you are doing in Linux). Because it is your schools system, chances are you will want to ask the System Administrator to install GCC.

If you do have root (and your system admin says its OK to install GCC), then you can install the RPM from the Red Hat 9 installation CD.

lazlow does have a point about RH9 being out of date; however. I would have said use the Red Hat FTP to get the latest version of GCC, but Red Hat has long since taken down the RH9 RPM FTP.

babyswan 07-19-2007 08:14 PM

Yes I do have root in the system.
But I do not have the redhat 9 cd.
So that means there is no way I can install gcc now?
What will you advice me to do?

jschiwal 07-19-2007 09:05 PM

You might try finding packages and their dependencies at rpm.pbone.net. If you can find one package, look at the link for that package. That will most likely be a repository that you can add and then use your package manager to download and install files.
ftp://ftp.pbone.net/mirror/archive.d...2.2-5.i386.rpm

ftp://archive.download.redhat.com/pu...6/RedHat/RPMS/

chadl 07-19-2007 09:05 PM

Try installing this RPM:
ftp://archive.download.redhat.com/pu...2.2-5.i386.rpm
Do your own due diligence before installing this, as I have no way to test this, but it looks like the RH9 GCC RPM to me.

To install an RPM (as root):
Code:

rpm -ivh <rpm file name>
EDIT: Updated to use the redhat.com download site rather then the rpmseek.com one I had found before. Thanks to jschiwal for finding that.

babyswan 07-19-2007 09:24 PM

i am facing problems in opening the link.
once i click on the above link it will say cannot find server.
=(

babyswan 07-19-2007 09:26 PM

ohhh ok sorry i am able to download it to my desktop in the linux computer already thank u very much. I will update the situation soon!

babyswan 07-19-2007 09:36 PM

ok i am done with the installation of package thankx for the link. =)
Right now i am facing this problem:
when i type gcc at the command shell prompt, the output is as follows:

gcc: no input files

i am not sure what the above means.
But i have installed this gcc.2.1.4.tar.bz file which i know that it is the source codes for it. I have already untar it but how am i going to use it with the gcc compiler?

chadl 07-19-2007 09:42 PM

That is the normal output for GCC if you don't give it anything to do. If you give it some code to compile, it will compile it instead of telling you that there are no input files.

To give it a test:
Put this code in a file named test.c:
Code:

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

Then run the following to compile it:
Code:

gcc test.c -o test
./test

If Hello World! is printed on your screen, then GCC is working correctly.

babyswan 07-19-2007 09:47 PM

So where do I type in the source codes which i would like to compile? Is it directly at the command shell prompt? I will give it a try though....
will update again!


thank you very much chadl for your help.
Well now at least i know that i have the gcc compiler in the linux computer already. It is a slight progress for me in my project. I could not have done it without your help thankkkks so much once again!

babyswan 07-19-2007 10:06 PM

Where do i input the codes


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

to test whether my gcc is confirmed working?

How do i create the above file name test.c?

babyswan 07-19-2007 10:08 PM

How do i create a file name test.c
where do i input the codes

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

chadl 07-19-2007 10:14 PM

To make your life easy, just copy and paste the following into a shell:
Code:

echo '#include <stdio.h>
int main()
{
        printf("Hello World\n");
        return 0;
}' > test.c

Then run the folowing (again from the shell):
Code:

gcc test.c -o test
./test

Again, if hello world in printed, then everything is working.

When you are done, get rid of these files by running:
Code:

rm test.c test

babyswan 07-20-2007 01:19 AM

Thank you very muchhhh! I can now confirm my gcc compiler is working now. I will now proceed to move on with the networking part of the project =) Will need to use the gcc compiler to complile WRT54G linksys source codes....
Thank you so muchhh once again. I feel a lot at ease =)

Thank you chadl and jschiwal =)


All times are GMT -5. The time now is 08:56 AM.