LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Using C compiler on Linux (https://www.linuxquestions.org/questions/linux-newbie-8/using-c-compiler-on-linux-215896/)

hopbalt 08-10-2004 02:44 PM

Using C compiler on Linux
 
OK, somebody gave me their old machine, its been completely abandoned, and I dont hardly know a thing about it. I am a complete newbie at Linux so please dont yell at me.

uname -a:

Linux machine_name 2.4.20-20.7.XFS.1.3.1smp #1 SMP <date> <time> i686 unknown

1) What kind of Linux is this? On startup, it doesnt tell me this information, so I have no clue if its redhat, caldera, mandrake, or what.

Now this is what happens when I type gcc or cc

gcc: Command not found

2) I thought all Linux software came with a C compiler?

3) So now I guess I have to download and install a compiler. This seems pretty complex to me. How do I do this?

Does one C compiler work on all the different types of Linux or do I have to find one that SPECIFICALLY matches that machine?

Please help :scratch:


ToniT 08-10-2004 03:07 PM

1.
Check if there is a file named /etc/redhat-release or /etc/debian_version.
Alternatively you can check /etc/issue and /etc/motd to get some more hints about the system.

2.
They should. But eg. SuSe personal doesn't. And you can always uninstall any component you want, but IMHO system is broken without c compiler (all W systems are broken).

3.
It is easiest to first figure out what distribution that is and then find a matching package that contains the c compiler in question.

hopbalt 08-10-2004 03:11 PM

Quote:

Originally posted by ToniT
1.
Check if there is a file named /etc/redhat-release or /etc/debian_version.
Alternatively you can check /etc/issue and /etc/motd to get some more hints about the system.

2.
They should. But eg. SuSe personal doesn't. And you can always uninstall any component you want, but IMHO system is broken without c compiler (all W systems are broken).

3.
It is easiest to first figure out what distribution that is and then find a matching package that contains the c compiler in question.

OK I will look to see what can be found.

Komakino 08-10-2004 03:13 PM

Personally I would start again anyway. Linux is free to download, get a copy of Fedora or Mandrake and start from scratch. You'll get a more up to date kernel for a start.

As for the line about:
Code:

Linux machine_name 2.4.20-20.7.XFS.1.3.1smp #1 SMP <date> <time> i686 unknown
the 2.4.20 refers to the kernel version. Linux is only the kernel, the distributions add different packages to go with the kernel to give you a complete system. The system is technically GNU/Linux because the tools are part of the GNU project for a linux kernel architecture.

Tinkster 08-10-2004 03:17 PM

Many distro's will leave a file in
/etc
that gives an inidcation of what you're
dealing with ....

Mine for instance says
[tink@diggn:~]$ cat /etc/slackware-version
Slackware 10.0.0

I've seen similar things on debian, Redhat and
Mandrake machines ...
tink@server:~ ls -l /etc/*version*
-rw-r--r-- 1 root root 17 Jul 18 2002 /etc/debian_version


Cheers,
Tink

hopbalt 08-10-2004 03:19 PM

OK I looked:

In the etc directory, there IS a file called redhat-release.

There is no file called debian_version.

There is also a file called motd, but its an empty file.

There is also a file called issue, but it only says "GEMS Linux 1.8.9"

OK, so I'm assuming that this machine has Red Hat. Can I assume that its Redhat version 2.4 or what? Do those uname numbers go together with the Red Hat version or is that something else?

masand 08-10-2004 03:19 PM

hi have a look here for gcc

http://gcc.gnu.org/install/binaries.html
regards

Komakino 08-10-2004 03:22 PM

Quote:

Originally posted by hopbalt

OK, so I'm assuming that this machine has Red Hat. Can I assume that its Redhat version 2.4 or what? Do those uname numbers go together with the Red Hat version or is that something else?

No, the uname numbers are JUST the linux kernel version. The distribution's own versioning system will be totally different. The current kernel is 2.6.x but Red Hat got upto release 9, Mandrake is on 10, Suse is on 9.1, Slackware is 10....the distribution numbering bears no resemblance to the kernel version.

rjlee 08-10-2004 03:23 PM

1) uname won't tell you which distribution you are running, only the version of the kernel that you have running.

Most Linux distributions will tell you a welcome message on each text console on a virtual terminal, so you can probably find this out by pressing Ctrl+Alt+F1 through Ctrl+Alt+F7 and seeing what it says. (F7 should get you back to a graphical desktop if you run one).

You could also try running “locate SuSE”, “locate debian” etc. as most distributions install at least one configuration or setup file containing the distro's name.

2) All major distributions usually ship with a C compiler on the install disks. This doesn't mean it will necessarily be installed. Assuming you're on an RPM based system (most distros except Debian seem to use RPM), you can run the command
Code:

rpm -qil gcc | more
to see information and installed files for the gcc package.

3) Debian is easy; you can install gcc by connecting to the 'net, and typing (as root)
Code:

apt-get --install gcc
If you don't have gcc (and you don't have the origninal install disks), then you'll need to go to http://www.rpmfind.net/ and download a binary RPM for gcc. rpmfind.net will also list several “dependency” programs and libraries like glibc; your system will need the right versions of all the various dependencies; either installed (rpm -qi name again to find out the versions you have) or downloaded as extra RPMs.

You can install the rpms using
Code:

rpm --install *.rpm
in the directory you downloaded from.

Note: gcc is big and will take a long time to download and install, especially if you try to download its dependencies as well.

You could also look at other C compilers for Linux, such as IBM's (which boasts slightly better optimisation than gcc for later processors).

4) As with any linux program, a C compiler will not work on all versions of Linux. It is, however, possible to compile a program and link it statically (copying the library routines instead of linking to them) so that it will work on any Linux or UNIX system with the same processor (and anything compiled for a 386 will run on later Intel processors too).

But I don't thing there are any staticly-linked C compilers out there. I may be wrong.

Hope that's of some help,

— Robert J. Lee

320mb 08-10-2004 03:26 PM

Quote:

Originally posted by Komakino


the 2.4.20 refers to the kernel version. Linux is only the kernel, the distributions add different packages to go with the kernel to give you a complete system. The system is technically GNU/Linux because the tools are part of the GNU project for a linux kernel architecture.

So technically it should be called KDE/Perl/GNU/linux........Richard Stallman did NOT write the "Kernel" and Richard Stallman did NOT have
any thing to do with Linux development at all.........so Technically GNU is NOT part of linux........

hopbalt 08-10-2004 03:26 PM

I went to that website for the binary pre-compiled gcc programs, and found the following available for download:

ftp://ftp.thewrittenword.com/package...ame/gcc-3.3.2/

gcc.3.3.2.rpm4.tar.z

The website said it was for i686 redhat linux 9. I guess I can try this and see if its compatible. Unfortunately, its 131 MB so I will be waiting many hours for download.

What if my Redhat is only release 7 or something? Does that mean this software wont work?


Tinkster 08-10-2004 03:31 PM

Quote:

Originally posted by hopbalt
In the etc directory, there IS a file called redhat-release.

OK, so I'm assuming that this machine has Red Hat.
Fair enough assumption ;)

Try a cat /etc/redhat-release


Cheers,
Tink

penguin4 08-10-2004 03:31 PM

hopbalt; from u r last post reply #6 u stated u found a reference to redhat
so it maybe remanents left by last owner. that could be a starting point. or as some of the others suggested acquire any other distro via download or
cd,whatever & update to that os acquired. my bet would be upgrade is better & probably newer more stable. 2nd ? compile if u wish its your machine (know what ur doing?) & that makes u boss(superuser/root) og for it!

Komakino 08-10-2004 03:33 PM

Quote:

Originally posted by 320mb
So technically it should be called KDE/Perl/GNU/linux........Richard Stallman did NOT write the "Kernel" and Richard Stallman did NOT have
any thing to do with Linux development at all.........so Technically GNU is NOT part of linux........

I didn't say GNU was part of linux. A complete (though pretty useless) system would include the linux kernel and the gnu linker, gnu c, gnu make and gnu binutils. Hence GNU/Linux - in fact what Debian still refers to itself as. What you add on is optional but you are building on a GNU/Linux system. I'm just trying to describe around the issue, it can give new users a better insight into what linux actually is.

Hey it may even put an end to the "What version of linux is best for me?" questions that are forever posted by people too lazy to search.

hopbalt 08-10-2004 03:34 PM

Quote:

Originally posted by Tinkster
Fair enough assumption ;)

Try a cat /etc/redhat-release


Cheers,
Tink

OK I did that and it said "GEMS Linux release"

GEMS is the name of the company that used to own this machine. They gave it away to a friend of mine who works there because they upgraded all their machines and threw the old ones away. Then the friend gave it to me.

What I dont understand is that even when the GUI loads up, it doesnt tell you antying about what version of Redhat it is.

I hope the RPM I'm downloading works.


All times are GMT -5. The time now is 05:29 PM.