Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Installing gcc 3.1 problem

Status
Not open for further replies.

afrl

MIS
Aug 5, 2002
7
US
I have an Ultra 1 sparc with Solaris 8. I need to update my Apache webserver. Apache won't compile without a c compiler. Went to sunfreeware.com.

I passed up gcc-3.1-sol8-sparc-local.gz for two reasons: I was told that sunfreeware was not a Sun site so the gcc-3.1-sol8-sparc-local.gz file cannot be guaranteed to be free of a trojan. At the site I am at I cannot take any chances. Secondly, it is the full c compiler version and I only need the core c compiler so I can compile Apache and other programs.

I found gcc-3.0.4.tar.gz at a gnu mirror site. It is about 18Mb and is the core compiler.

I gunzipped and untarred it and when I tried to rune the configure executable I got the error:

[deleted]...
./configure: gcc: not found
*** The command "gcc -o conftest -g -O2 conftest.c failed.
*** You must set the environment variable CC to a working compiler.

"Working compiler"? I am trying to install a working compiler. What does this mean? Any suggestions?
 



Installing gcc
Following the download procedures above, you should be left with a package named accordingly to your platform - and ending with ".local" in the filename. In order to install this package, you should be root or have root access as it installs in your /usr/local filesystem - or creates it if you don't have one. So, become root somehow by logging in as root, using the su or sudo commands or however your system is set up.

Next, issue the pkgadd (PacKaGe ADD or "package add") command to install it on the system, changing the actual package name to fit the one you downloaded, for example:

# pkgadd -d gcc-2.95.2-sol7-sparc-local (hit return)

You will then be presented with the standard pkgadd response:

The following packages are available:
1 SMCgcc gcc
(sparc) 2.95.2

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:

...to which you'll want to answer with an "all" or just hit return, since that is the default value. You'll see the files being installed start to scroll by on your screen and the package will be installed! Yes, it's that simple - and why we like packages, right?

You may be presented with a few questions along the way if you haven't installed any other packages in this fashion before, including the creation of the /usr/local directory or perhaps the permissions settings on various "conflicting" files. Just answer "y" to these questions and hit return.

Once the package has completed installing, you'll be returned to the command prompt after a brief line that reads, hopefully:

.
.
.
Installation of <SMCgcc> was successful.
# _

You can verify this and see some information about the package with the pkginfo (PacKaGe INFOrmation or &quot;package information&quot;) command:

# pkginfo -l SMCgcc (hit return)
PKGINST: SMCgcc
NAME: gcc
CATEGORY: application
ARCH: sparc
VERSION: 2.95.2
BASEDIR: /usr/local
VENDOR: Free Software Foundation
PSTAMP: Steve Christensen
INSTDATE: Mar 12 2001 13:26
EMAIL: steve@smc.vnet.net
STATUS: completely installed
FILES: 349 installed pathnames
10 shared pathnames
2 linked files
21 directories
23 executables
127203 blocks used (approx)
# _

Yours may vary slightly, but should more or less look like the above. You're all set, and should now log out as root and &quot;be yourself&quot; again.

Environment Variables
You may want to define a certain set of environment variables so that gcc knows where to find things, and will come in handy when compiling other Open Source software. Many utilities rely on environment variables like configure and make as well as gcc. If you are using the GNOME environment especially, it's good to set these up.

If you're using bash as your shell, just add the following lines into your ~/.bashrc file, or modify any existing lines to include those shown. You should of course, adjust these paths to your system - but for most situations, these will be appropriate:

export PATH=/opt/gnome/bin:/usr/local/bin:/opt/netscape:/usr/ccs/bin:$PATH
export LD_LIBRARY_PATH=/opt/gnome/lib:/usr/local/lib:/usr/lib:/lib
export GNOME_PATH=/opt/gnome
export MANPATH=/usr/local/man:/opt/gnome/man:$MANPATH
export CPPFLAGS=&quot;-I/opt/gnome/include -I/usr/openwin/share/include/X11/extensions -I/usr/openwin/include&quot;

For the changes to take effect, you'll either need to log out and back in again, or start a fresh terminal window. You can also just enter &quot;source ~/.bashrc&quot; at the command-line to do the same thing. As a quick test, try entering the following at the command-line and you should see something like this:

$ set | grep LD_LIBRARY_PATH
LD_LIBRARY_PATH=/opt/gnome/lib:/usr/local/lib:/usr/lib:/lib
$ _

These environment variables tell various utilities where files reside on your system. Important things like libraries, include files, man pages and even GNOME itself.

A Quick Test
If you want to make sure that it's working and wish to perform a quick test, why not use the old standby of a &quot;hello world&quot; program? What article on a language would be complete without it...

Using the text editor of your choice, create a file called &quot;helloworld.c&quot; in your home directory and enter the following code:

main()
{
printf(&quot;Hello world.\n&quot;);
}

Okay, so it's not the best C program in terms of what it does or ANSI C correctness, but it will suffice to test the install. Next, on the command line we'll compile this C source code into a usable Solaris binary:

$ gcc helloworld.c -o helloworld (hit return)
$ _

If all goes well, you'll be returned to the command line with no further output. Pretty simple, no? What you're left with is a binary called &quot;helloworld&quot; which is ready to execute:

$ ./helloworld (hit return)
Hello world.
$ _

If this is what you got, congratulations! If not, resolve any errors you get in response to the compiler (known as warnings) and try again. You've now successfully installed gcc and compiled a very simple test program.

You're now ready to move on to bigger and better things - enjoy!

I copied from
EverythingSolaris

.

Farah regal
good luck
&quot;think twice and hit enter once&quot;
 
U have downloaded the source code of GCC. So u need to compile it with a working C compiler first and then install it on ur machine. After compiling-installing GCC, make the GCC to be default C compiler by updating the CC environment variable.

U will get Sun C compiler evaluation copy on ur Sun installation CD kit. Use that to compile ur GCC source code..

All the best,

Regds,

- Hemant
Networking and Systems Integration Group
Satyam Computer Services Ltd
 
Farah: THanks for taking the time to answer my question, however I cannot use that solution. As I said I did not select gcc-3.1-sol8-sparc-local.gz but rather the uncompiled version. I cannot use the pre-compiled version.

So I am still left with the problem of how to compile it.

Hemant: Thank you for taking the time to answer my question. I will try that solution.

Frank
 
I've run into this problem with the gcc from sunfreeware and it was just a naming issue. What i would do is where ever you have the &quot;gcc&quot; binary, create a link to it called &quot;cc&quot;.

example:

# cd /usr/local/bin
# ln -s gcc cc

That worked for me.

-jared
 
For those that read this and the following helpers:

Hemant (Butterfly123):

The Sun CD only has the full version with all the bells and whistles. I cannot use that for the sake of space and I am not a C programmer. I just need the core compiler so that I can compile Apache and other programs.

Jared (Jared71)
Thanks for the reply but I don't understand it. What gcc binary? I don't even have it yet. That is what I am trying to compile and install. I have obtained the basic gcc from the gnu website: gcc-core-3.0.4.tar.gz. This is what I gunzipped, untarred, and, accorsing to the directions, started with the command ./configure...

and the results I get from running ./configure are:

Configuring for a sparc-sun-solaris2.8 host.
*** This configuration is not supported in the following subdirectories:
target-libffi target-boehm-gc target-zlib target-libjava
(Any other directories should still work fine.)
Created &quot;Makefile&quot; in /export/home/jagarwal/gcc-3.0.3 using &quot;mh-frag&quot;
/usr/ucb/cc: language optional software package not installed
*** The command 'cc -o conftest -g conftest.c' failed.
*** You must set the environment variable CC to a working compiler.

Unless I am missing something, I cannot set the &quot;environment variable&quot; to a &quot;working compiler&quot; because I don't even have a working compiler...yet. That's what gcc-core-3.0.4.tar.gz is supposed to provide me...right? Or am I clueless about something?

Sure. The obvious solution is to use gcc-3.1-sol8-intel-local.gz, a precompiled package on which I would run pkgadd but that package is the full version with all the bells and whistles. As I said, I can't use that one.

So any help you folks can provide me would be appreciated.

Frank
in New Mexico, USA, Land of Enchantment
 
A couple questions.

1. Is make installed? Usually ./configure is preceeded by make and makefile...

2. just out of curiosity, is there a gcc in /usr/bin or /usr/local/bin? I wonder if it's possible that the ./configure is dumping a gcc 'light' to build the compiler in some directory that isn't in the path. Many sunfreeware untils put files in /usr/local/bin, but it isn't in the path. I find many times I have to go to a directory in the path variable and link them. If you find a gcc there, I would suggest linking it as 'cc' and 'gcc' from /usr/bin...

just grasping at straws at this point.
 
If you dont want to invest disk space for GCC, then u can download the Apache webserver package from sunfreeware.com.. But beware, it will not be the latest apache version. If u can do with any apache version, then u got many apache downloads in package format from sunfreeware.com.. Those will be in the form of &quot;.local.gz&quot;..

If u need to hav latest apache, then its available only in source code form. U need to compile it and u MUST install a compiler. Get GCC 2.85 version from sunfreeware.. It takes about 12mb on ur HDD. latest versions of GCC would take about 18 MB. but u MUST hav C compiler to install latest apache..

Regds,

- Hemant
Networking and Systems Integration Group
Satyam Computer Services Ltd
 
I thank Jared and Butterfly again for the replies.

Jared: I have make in /usr/ccs/bin and in /usr/share/lib. The process of running ./configure on the gcc package does create a gcc in /usr/bin, but it is a directory with a sub called /config, which contains numerous .h files that are config files for different varieties of UNIX (it seems). Nothing for Sun systems. No gcc executable is created.

As for make, the directions did not start with make. The following is from the configuraton directions:

1. It says that cc or gcc must be in my path (??? that's what I am trying to install!!!!)
2. ...or I must set CC (a config variable) in my environment before running configure. &quot;Otherwise the configuration scripts may fail.&quot; Well, the CC variable is supposed to define the path to the C compiler command. I don't have C set up as you know. (Same directions are in the Apache configuration.)
3. The configuration then starts with the following commands:
#mkdir <i>objdir</i> (I did that)
#cd <i>objdir</i> (OK)
#<i>srcdir</i>/configure [<i>options</i>] [<i>target</i>] (I did not select any options or target because the defaults seemed OK)

Butterfly: I am in a bad situation. I have this old ULTRA 1 that runs sendmail and the office web site and I will not be given the money to upgrade. I am expected to make do with what I have. I am also required (this system will be inspected in a month) to keep up with security patches and the latest on Apache give a solution which is to upgrade to the latest version of 1.3 or go to 2.0. Either way my problem is the same: I need a working gcc in order to install Apache. I am leaving out all the office politics that caused this situation because it is not relevant.

 
OKay;
On sunfreeware.com, u will get gcc 2.8 or little later version for sparc in package format (*.local.gz). Just unzip it and get it installed on ur machine.

Later, hav the Apache and Sendmail upgraded to latest version with the help of C compiler.

THen, remove GCC from your mache again!!

Removing GCC is very simple! Just remove the folder where u hav installed GCC (by default its /usr/local). See that you keep apache files somewhere else than /usr/local/ folder.

After you install GCC, see that CC environmental variable
is set to /usr/local/bin/gcc. Also, Checkout the makefiles (Makefile) of the Apache and Sendmail and update the CC variables to /usr/local/bin/gcc.

Also, after installing GCC, update your path variable to add all the header files, library files, and executables of GCC. I guess they are in /usr/local/include, /usr/local/bin/, /usr/local/lib/ etc..


Hope this helps..

Regds,

- Hemant
Networking and Systems Integration Group
Satyam Computer Services Ltd
 
I got the *local.gz for 3.1 and used a simple C program to test it before I used it to complile a good clean copy of gcc-core-2.95.3.tar.gz.

The test program started with #include <stdio.h> naturally and it gave an error that another file, called by the stdio.h, could not be found. The file was stdio_iso.h and I did a search and could not find it.

So I unloaded 3.1 and downloaded the *local.gz for 2.95 and had the same problem.

What is going on? Stdio calls an h file that is not included?

Frank
 
Hey sorry for being late! Was on long weekend vacation!

Well, so u hav got GCC installed (package form).. After installing GCC, u need to update ur path variable. Whats happening there is ur compiler is not able to find the location of header files. Since u hav used package form of GCC, i guess the header files should be in /usr/local/include folder.. Just update ur PATH variable with all the folders of header and library files and u will be done!

Regds,

- Hemant
Networking and Systems Integration Group
Satyam Computer Services Ltd
 
Hemant:

The PATH variable was taken care of. The file, stdio_iso.h, which is supposed to be in the iso directory is simply not there. The directory is there with two files but not the missing file. Nor is it anywhere else in my computer, nor is it in gcc 3.04 nor in 2.95 as I wrote. Ain't there.

My test program is :

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

The error is:

In file included from samp.c:1:
stdio.h:36:27:iso/stdio_iso.h: No such file or directory
In file included from samp.c:1:
stdio.h:194: parse error before '*' token
stdio.h:194: warning: data definition has no type or storage class.

...and line 194 reads:
extern FILE *_lastbuf;

I am not a c programmer so I don't understand the line 194 error, but stdio_iso.h is not in /iso or anywhere else.

Thanks for your patience.

Frank


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top