[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

newbie here

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
Carl3003
Asked:
Carl3003
  • 17
  • 8
  • 5
  • +3
1 Solution
 
yuzhCommented:
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
 
brettmjohnsonCommented:
> ... if you can find it, ask your sys adm.

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

0
 
yuzhCommented:
brettmjohnson,

    Good catch, I'm going fix it now!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Carl3003Author Commented:
"where cc"
"where gcc"
it gives me-" no such file or directory"
0
 
Carl3003Author Commented:
ops
0
 
Carl3003Author Commented:
I meant which gcc or which cc: they both give "no file or directory
0
 
brettmjohnsonCommented:
It sounds like there is not a C compiler installed on the system
(or it is not found on your PATH):

echo $PATH
0
 
TintinCommented:
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
 
Carl3003Author Commented:
i just tried running which gcc,cc in the root dir but got same message
0
 
yuzhCommented:
ask your sys adm.
0
 
GnsCommented:
And do tell what flavour of unix this is... as requested by Tintin. It might not even be named "cc":-)

-- Glenn
0
 
ahoffmannCommented:
please post result of following first:

  uname -a
0
 
Carl3003Author Commented:
SunOS eniac 5.9 Generic_117172-07 i86pc i386 i86pc

this is what i got
0
 
yuzhCommented:
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
 
brettmjohnsonCommented:
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
 
TintinCommented:
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
 
Carl3003Author Commented:
i could not fine anything in both directories
0
 
Carl3003Author Commented:
i could not find anything in both directories
0
 
TintinCommented:
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
 
Carl3003Author Commented:
i guess thats what i have to do..
0
 
ahoffmannCommented:
/usr/ccs/bin/cc
otherwise get gcc from sunfreeware as Tintin suggested
0
 
yuzhCommented:
Too many repeating comments
starting from http:#12040922 !
0
 
ahoffmannCommented:
agreed
0
 
Carl3003Author Commented:
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
 
TintinCommented:
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
 
Carl3003Author Commented:


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
 
TintinCommented:
There's nothing there that you specifically need.

It would only be relevant if /usr/local/bin/g++ exists.
0
 
Carl3003Author Commented:
/usr/local/bin/g++ does not exist, but /usr/local/bin/c++ exist !!!
0
 
Carl3003Author Commented:
/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
 
TintinCommented:
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
 
Carl3003Author Commented:
/usr/local/include/c++: is a directory
0
 
Carl3003Author Commented:
/usr/local/include/c++/3.4.1: is a directory
0
 
TintinCommented:
/usr/local/bin/c++ -v

Note, "bin" not "local"
0
 
Carl3003Author Commented:
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
 
Carl3003Author Commented:
i am gonna go to get some sleep. I will probably check again tommorow
Thansk for your help..
0
 
GnsCommented:
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
 
TintinCommented:
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
 
Carl3003Author Commented:

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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 17
  • 8
  • 5
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now