Solved

newbie here

Posted on 2004-09-09
38
225 Views
Last Modified: 2010-04-21
I want run a C program but i am not sure how to access the C compiler in UNIX. How can I do that. Thanks in advance.
0
Comment
Question by:Carl3003
  • 17
  • 8
  • 5
  • +3
38 Comments
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
In most of the Unix has a C complier, cc or gcc,

type in:
which cc
or which gcc
to find out where it located, if you can't find it, ask your sys adm.
0
 
LVL 23

Expert Comment

by:brettmjohnson
Comment Utility
> ... if you can find it, ask your sys adm.

That should probably read:
... if you can NOT find it, ask your sys adm.

0
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
brettmjohnson,

    Good catch, I'm going fix it now!
0
 

Author Comment

by:Carl3003
Comment Utility
"where cc"
"where gcc"
it gives me-" no such file or directory"
0
 

Author Comment

by:Carl3003
Comment Utility
ops
0
 

Author Comment

by:Carl3003
Comment Utility
I meant which gcc or which cc: they both give "no file or directory
0
 
LVL 23

Expert Comment

by:brettmjohnson
Comment Utility
It sounds like there is not a C compiler installed on the system
(or it is not found on your PATH):

echo $PATH
0
 
LVL 48

Expert Comment

by:Tintin
Comment Utility
What Unix flavour are you on?

Your C compile (assuming it is installed), may be in a non standard location (or at least not in your PATH)
0
 

Author Comment

by:Carl3003
Comment Utility
i just tried running which gcc,cc in the root dir but got same message
0
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
ask your sys adm.
0
 
LVL 20

Expert Comment

by:Gns
Comment Utility
And do tell what flavour of unix this is... as requested by Tintin. It might not even be named "cc":-)

-- Glenn
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
please post result of following first:

  uname -a
0
 

Author Comment

by:Carl3003
Comment Utility
SunOS eniac 5.9 Generic_117172-07 i86pc i386 i86pc

this is what i got
0
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
Solaris 9 X 86, you have /usr/ucb/cc (it is not a fully working C complier!),

do a:
ls /usr/local/bin/gcc
to see if your adm has install the gcc complier, if not, you can ask him to download
gcc from:
http://sunfreeware.com/
0
 
LVL 23

Expert Comment

by:brettmjohnson
Comment Utility
Sun does not provide a compiler in their default installations.  
The Developer tools are available as a separate installation.
I don't know about Solaris x86, but the Solaris SPARC compilers were
not inexpensive last I checked (~5 years ago).  You can download the
GNU C Compiler for Solaris x86 from here:
http://www.sunfreeware.com/

Unfortunately, the site provides installation packages for individual tools,
(they don't have a "Developer Tools" installation of a common set of tools).
However, you will need at least gcc, libgcc (might be installed along with the
compiler), and make.

0
 
LVL 48

Expert Comment

by:Tintin
Comment Utility
OK, Solaris 9.

If you have a C compiler installed, it will either be gcc, which typically would be installed in /usr/local/bin
or Sun C compiler which will be in /opt/SUNWspro

Do either of those exist?
0
 

Author Comment

by:Carl3003
Comment Utility
i could not fine anything in both directories
0
 

Author Comment

by:Carl3003
Comment Utility
i could not find anything in both directories
0
 
LVL 48

Expert Comment

by:Tintin
Comment Utility
It appears then, that you don't have a C compiler installed on the server (unless it's in an unusual location).

Ask your system administrator to install one for you.  Easiest option is to install gcc from http://sunfreeware.com/
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:Carl3003
Comment Utility
i guess thats what i have to do..
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
/usr/ccs/bin/cc
otherwise get gcc from sunfreeware as Tintin suggested
0
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
Too many repeating comments
starting from http:#12040922 !
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
agreed
0
 

Author Comment

by:Carl3003
Comment Utility
does the C compiler has anythign to do with the .bash_profile? I was told that i should copy this file into my directory
0
 
LVL 48

Expert Comment

by:Tintin
Comment Utility
The .bash_profile *might* contain the relevant paths and environment for your C compiler, but it entirely depends on whether you do in fact have a C compiler installed and what the contents of the bash profile are.
0
 

Author Comment

by:Carl3003
Comment Utility


This is what is in the bash_profile file

CPLUS_INCLUDE_PATH=/usr/local/include/g++
LD_LIBRARY_PATH=/usr/lib:/usr/local/lib
MANPATH=/usr/share/man:/usr/local/man
export MANPATH CPLUS_INCLUDE_PATH LD_LIBRARY_PATH
0
 
LVL 48

Expert Comment

by:Tintin
Comment Utility
There's nothing there that you specifically need.

It would only be relevant if /usr/local/bin/g++ exists.
0
 

Author Comment

by:Carl3003
Comment Utility
/usr/local/bin/g++ does not exist, but /usr/local/bin/c++ exist !!!
0
 

Author Comment

by:Carl3003
Comment Utility
/usr/local/include/c++/3.4.1
this directory contains library files

algorithm             cstring               limits
backward/             ctime                 list
bits/                 cwchar                locale
bitset                cwctype               map
cassert               cxxabi.h              memory
cctype                debug/                new
cerrno                deque                 numeric
cfloat                exception             ostream
ciso646               exception_defines.h   queue
climits               ext/                  set
clocale               fstream               sstream
cmath                 functional            stack
complex               i386-pc-solaris2.9/   stdexcept
csetjmp               iomanip               streambuf
csignal               ios                   string
cstdarg               iosfwd                typeinfo
cstddef               iostream              utility
cstdio                istream               valarray
cstdlib               iterator              vector
0
 
LVL 48

Expert Comment

by:Tintin
Comment Utility
A breakthrough!!

Looks like just have C++ installed, which may or may not be want you need.

What does

/usr/local/bin/c++ -v

display?
0
 

Author Comment

by:Carl3003
Comment Utility
/usr/local/include/c++: is a directory
0
 

Author Comment

by:Carl3003
Comment Utility
/usr/local/include/c++/3.4.1: is a directory
0
 
LVL 48

Accepted Solution

by:
Tintin earned 50 total points
Comment Utility
/usr/local/bin/c++ -v

Note, "bin" not "local"
0
 

Author Comment

by:Carl3003
Comment Utility
sorry...this is the output
 
/usr/local/bin/c++ -v
Reading specs from /usr/local/lib/gcc/i386-pc-solaris2.9/3.4.1/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --disable-nls --disable-libgcj --enable-languages=c,c++
Thread model: posix
gcc version 3.4.1
0
 

Author Comment

by:Carl3003
Comment Utility
i am gonna go to get some sleep. I will probably check again tommorow
Thansk for your help..
0
 
LVL 20

Expert Comment

by:Gns
Comment Utility
So with that config the tenthousand$$$ question becomes (again!)... does /usr7Local/bin/gcc or /usr/local/bin/cc exist too? If not, it's a strange c++ only install (which is a bit silly:-).

-- Glenn
0
 
LVL 48

Expert Comment

by:Tintin
Comment Utility
Slowly....very slowly...getting there.

Just to confirm 100% that you have or don't have gcc installed, what is the output of

ls -l /usr/local/bin/*cc*
0
 

Author Comment

by:Carl3003
Comment Utility

I did it. Everything should be ok now..Thanks for the excellent assistance..
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now