Can't compile or install GCC

Hi all!

I have posted in the Shell Programming Scripting Forum for a problem with the use of shc and so on...

You can read it complete here: shell-programming-scripting/148510-problems-using-shc.html

I think the problem is: that there aren't compiler installed on the SuSe 10.2 server, so I can't run successfully the shc program. In the server, there is only command-line access.

I tried to install it with YAST, but it fails because ask for installation CDs that nor have nor can insert.

I've downloaded several rpm's packages with null results...

Can you help me?

Thanks in advance...

First off -

are you sure gcc is no there? What is the output of:

which gcc
echo $PATH

Hi!

First of all, thanks for your reply.

And now: yes, it isn't :

/root # which gcc
which: no gcc in (/sbin:/usr/sbin:/usr/local/sbin:/opt/gnome/sbin:/root/bin:/usr/local/bin:
/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/openv/uss0001/sbin:
/usr/openv/netbackup/bin/support:/usr/openv/uss0001/sbin:/usr/openv/netbackup/bin/support:/root/bin:
/opt/VRTS/bin:/usr/openv/netbackup/bin:/usr/openv/netbackup/bin/admincmd:
/usr/openv/netbackup/bin/goodies:/usr/openv/volmgr/bin)
/root # echo $PATH
/sbin:/usr/sbin:/usr/local/sbin:/opt/gnome/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:
/bin:/usr/games:/opt/gnome/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/openv/uss0001/sbin:
/usr/openv/netbackup/bin/support:/usr/openv/uss0001/sbin:/usr/openv/netbackup/bin/support:/root/bin:
/opt/VRTS/bin:/usr/openv/netbackup/bin:/usr/openv/netbackup/bin/admincmd:
/usr/openv/netbackup/bin/goodies:/usr/openv/volmgr/bin

Looking in yast -> Software -> Software Management -> Shearch -> gcc I see this:

|     |Name        |Avail. Vers.  |Inst. Vers.   |Summary                                    |Size       
|  i  |cpp         |4.1.2_20070115|4.1.2_20070115|The GCC Preprocessor                       |5.6 M
|  +  |gcc         |4.1.2_20070115|              |The GNU C Compiler and Support Files       |1.8 M
|  +  |gcc-c++     |4.1.2_20070115|              |The GNU C++ Compiler                       |6.3 M
|     |gcc-fortran |4.1.2_20070115|              |The GNU Fortran Compiler and Support Files |8.0 M
|     |gcc-info    |4.1.2_20070115|              |GNU Info-Pages for GCC                     |1.4 M
|     |gcc-java    |4.1.2_20070115|              |The GNU Java Compiler                      |5.9 M
|  +  |gcc-locale  |4.1.2_20070115|              |Locale Data for the GNU Compiler Collection|4.9 M
|  +  |gcc-obj-c++ |4.1.2_20070115|              |GNU Objective C++ Compiler                 |6.1 M
|  +  |gcc-objc    |4.1.2_20070115|              |GNU Objective C Compiler                   |6.0 M
|  i  |libgcc      |4.1.2_20070115|4.1.2_20070115|C compiler runtime library                 |98.6 K
|     |libgcj      |4.1.2_20070115|              |Java Runtime Library for gcc               |38.9 M
|     |libgcj-32bit|4.1.2_20070115|              |Java Runtime Library for gcc               |21.4 M

The '+' where there because I tried to install it.

I look over the FS '/' and it found this 2 directories:

/root # cd /

/ # find ./ -name gcc -print
./usr/lib/gcc
./usr/lib64/gcc

/ # ls -lrt ./usr/lib/gcc;ls -lrt ./usr/lib64/gcc
total 4
drwxr-xr-x 3 root root 4096 2009-07-02 12:08 i586-suse-linux
total 4
drwxr-xr-x 3 root root 4096 2008-04-22 02:37 x86_64-suse-linux

Looking inside them, this can be seen:

/ # ls -lrt ./usr/lib/gcc/i586-suse-linux/;ls -lrt ./usr/lib64/gcc/x86_64-suse-linux/
total 4
drwxr-xr-x 2 root root 4096 2009-07-02 12:08 2.95.3
total 4
drwxr-xr-x 2 root root 4096 2010-02-18 13:19 4.1.2

/ # ls -lrt ./usr/lib/gcc/i586-suse-linux/2.95.3/;ls -lrt ./usr/lib64/gcc/x86_64-suse-linux/4.1.2/
total 144
-rw-r--r-- 1 root root 123628 2006-06-16 15:13 libgcc.a
-rw-r--r-- 1 root root   1400 2006-06-16 15:13 crtendS.o
-rw-r--r-- 1 root root   1316 2006-06-16 15:13 crtend.o
-rw-r--r-- 1 root root   2152 2006-06-16 15:13 crtbeginS.o
-rw-r--r-- 1 root root   1916 2006-06-16 15:13 crtbegin.o
total 5644
-rwxr-xr-x 1 root root 5765088 2008-04-22 02:37 cc1

So, finally there are a 'cc1' file that can be a compiler. But, it's really? If yes, what should I make?

Thanks in advance...

Best regards

---------- Post updated at 10:33 AM ---------- Previous update was at 09:21 AM ----------

If this helps:

I add the directory where the cc1 file exists to the PATH:

PATH=$PATH:/usr/lib64/gcc/x86_64-suse-linux/4.1.2/

I create this file:

/bin/magius/shc-3.8.6 # echo "#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
    char testvar[255];
    strcpy(testvar, "Hello, Magius");
    printf("%s\n", testvar);
    return 1;
}" > magius.c

I create two soft links to cc1:

/bin/magius/shc-3.8.6 # ln -s /usr/lib64/gcc/x86_64-suse-linux/4.1.2/cc1 /usr/lib64/gcc/x86_64-suse-linux/4.1.2/cc
/bin/magius/shc-3.8.6 # ls -lrt /usr/lib64/gcc/x86_64-suse-linux/4.1.2/cc
lrwxrwxrwx 1 root root 42 2010-11-18 10:27 /usr/lib64/gcc/x86_64-suse-linux/4.1.2/cc -> /usr/lib64/gcc/x86_64-suse-linux/4.1.2/cc1
/bin/magius/shc-3.8.6 # ln -s /usr/lib64/gcc/x86_64-suse-linux/4.1.2/cc1 /usr/lib64/gcc/x86_64-suse-linux/4.1.2/gcc
/bin/magius/shc-3.8.6 # ls -lrt /usr/lib64/gcc/x86_64-suse-linux/4.1.2/gcc
lrwxrwxrwx 1 root root 42 2010-11-18 10:36 /usr/lib64/gcc/x86_64-suse-linux/4.1.2/gcc -> /usr/lib64/gcc/x86_64-suse-linux/4.1.2/cc1


And I try to compile with all: gcc, cc and cc1:

/bin/magius/shc-3.8.6 # gcc -o magius magius.c
magius.c:1:19: error: stdio.h: No such file or directory
magius.c:2:20: error: string.h: No such file or directory
 main
magius.c: In function �main�:
magius.c:6: warning: incompatible implicit declaration of built-in function �strcpy�
magius.c:6: error: �Hello� undeclared (first use in this function)
magius.c:6: error: (Each undeclared identifier is reported only once
magius.c:6: error: for each function it appears in.)
magius.c:6: error: �Magius� undeclared (first use in this function)
magius.c:6: error: too many arguments to function �strcpy�
magius.c:7: warning: incompatible implicit declaration of built-in function �printf�
magius.c:7: error: expected expression before �%� token

Execution times (seconds)
 TOTAL                 :   0.00             0.00             0.01               1824 kB

/bin/magius/shc-3.8.6 # cc -o magius magius.c
magius.c:1:19: error: stdio.h: No such file or directory
magius.c:2:20: error: string.h: No such file or directory
 main
magius.c: In function �main�:
magius.c:6: warning: incompatible implicit declaration of built-in function �strcpy�
magius.c:6: error: �Hello� undeclared (first use in this function)
magius.c:6: error: (Each undeclared identifier is reported only once
magius.c:6: error: for each function it appears in.)
magius.c:6: error: �Magius� undeclared (first use in this function)
magius.c:6: error: too many arguments to function �strcpy�
magius.c:7: warning: incompatible implicit declaration of built-in function �printf�
magius.c:7: error: expected expression before �%� token

Execution times (seconds)
 TOTAL                 :   0.00             0.01             0.01               1824 kB
/bin/magius/shc-3.8.6 # cc1 -o magius magius.c
magius.c:1:19: error: stdio.h: No such file or directory
magius.c:2:20: error: string.h: No such file or directory
 main
magius.c: In function �main�:
magius.c:6: warning: incompatible implicit declaration of built-in function �strcpy�
magius.c:6: error: �Hello� undeclared (first use in this function)
magius.c:6: error: (Each undeclared identifier is reported only once
magius.c:6: error: for each function it appears in.)
magius.c:6: error: �Magius� undeclared (first use in this function)
magius.c:6: error: too many arguments to function �strcpy�
magius.c:7: warning: incompatible implicit declaration of built-in function �printf�
magius.c:7: error: expected expression before �%� token

Execution times (seconds)
 parser                :   0.01 (100%) usr   0.00 ( 0%) sys   0.00 ( 0%) wall      70 kB ( 4%) ggc
 TOTAL                 :   0.01             0.00             0.01               1824 kB

As I expect any of them works. Its the same file at the end...

I don't know what more I can do ...

Thanks in advance...

Using cc1 directly is not the way to go. If anything, it will only perform the first stage of the compilation.

I tried to use gcc -v in order to see ho it is done, and there are many more flags it uses on the command line.

my compilation line was: gcc -o checkstatvfs checkstatvfs.c.

The result:

/usr/lib/gcc/x86_64-linux-gnu/4.4.3/cc1 -quiet -v checkstatvfs.c -D_FORTIFY_SOURCE=2 -quiet -dumpbase checkstatvfs.c -mtune=generic -auxbase checkstatvfs -version -fstack-protector -o /tmp/ccmVxJF6.s

as you can see, the output is an assembler file.

Then, the assembler is run:
as -V -Qy -o /tmp/ccYDwa43.o /tmp/ccmVxJF6.s

and after that, collect2 is run:
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/collect2 --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=both -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o checkstatvfs -z relro /usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.4.3/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.4.3 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.3 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../.. -L/usr/lib/x86_64-linux-gnu /tmp/ccYDwa43.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.4.3/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crtn.o

which does the linking, apparently.

You need to determine where did /usr/bin/gcc have gone away. I don't think that doing the compilation one step at the time will work for you.

Hi all, and thanks dhzdh for your reply...

I think gcc never had been installed, or it has been removed some time ago. Yast offers the posibility of install it, look:

 |     |Name        |Avail. Vers.  |Inst. Vers.   |Summary                                    |Size      
 |  i  |cpp         |4.1.2_20070115|4.1.2_20070115|The GCC Preprocessor                       |     5.6 M|
 |     |gcc         |4.1.2_20070115|              |The GNU C Compiler and Support Files       |     1.8 M|
 |     |gcc-c++     |4.1.2_20070115|              |The GNU C++ Compiler                       |     6.3 M|
 |     |gcc-fortran |4.1.2_20070115|              |The GNU Fortran Compiler and Support Files |     8.0 M|
 |     |gcc-info    |4.1.2_20070115|              |GNU Info-Pages for GCC                     |     1.4 M|
 |     |gcc-java    |4.1.2_20070115|              |The GNU Java Compiler                      |     5.9 M|
 |     |gcc-locale  |4.1.2_20070115|              |Locale Data for the GNU Compiler Collection|     4.9 M|
 |     |gcc-obj-c++ |4.1.2_20070115|              |GNU Objective C++ Compiler                 |     6.1 M|
 |     |gcc-objc    |4.1.2_20070115|              |GNU Objective C Compiler                   |     6.0 M|
 |  i  |libgcc      |4.1.2_20070115|4.1.2_20070115|C compiler runtime library                 |    98.6 K|
 |     |libgcj      |4.1.2_20070115|              |Java Runtime Library for gcc               |    38.9 M|
 |     |libgcj-32bit|4.1.2_20070115|              |Java Runtime Library for gcc               |    21.4 M|

How can install it without the installation CDs/DVDs? I can't download any working package from any web site, the dependencies are killing me.

Thanks in advance again...