Solved

newbie here

Posted on 2004-09-09
38
256 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
ID: 12023491
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
ID: 12023495
> ... 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
ID: 12023506
brettmjohnson,

    Good catch, I'm going fix it now!
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

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

Author Comment

by:Carl3003
ID: 12023608
ops
0
 

Author Comment

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

Expert Comment

by:brettmjohnson
ID: 12023633
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
ID: 12023638
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
ID: 12023647
i just tried running which gcc,cc in the root dir but got same message
0
 
LVL 38

Expert Comment

by:yuzh
ID: 12023965
ask your sys adm.
0
 
LVL 20

Expert Comment

by:Gns
ID: 12026767
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
ID: 12039595
please post result of following first:

  uname -a
0
 

Author Comment

by:Carl3003
ID: 12040862
SunOS eniac 5.9 Generic_117172-07 i86pc i386 i86pc

this is what i got
0
 
LVL 38

Expert Comment

by:yuzh
ID: 12040922
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
ID: 12040923
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
ID: 12040924
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
ID: 12040941
i could not fine anything in both directories
0
 

Author Comment

by:Carl3003
ID: 12040943
i could not find anything in both directories
0
 
LVL 48

Expert Comment

by:Tintin
ID: 12040983
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
 

Author Comment

by:Carl3003
ID: 12040995
i guess thats what i have to do..
0
 
LVL 51

Expert Comment

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

Expert Comment

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

Expert Comment

by:ahoffmann
ID: 12044123
agreed
0
 

Author Comment

by:Carl3003
ID: 12051217
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
ID: 12051266
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
ID: 12051302


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

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

Author Comment

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

Author Comment

by:Carl3003
ID: 12051357
/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
ID: 12051380
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
ID: 12051435
/usr/local/include/c++: is a directory
0
 

Author Comment

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

Accepted Solution

by:
Tintin earned 50 total points
ID: 12051469
/usr/local/bin/c++ -v

Note, "bin" not "local"
0
 

Author Comment

by:Carl3003
ID: 12051482
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
ID: 12051513
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
ID: 12052597
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
ID: 12059675
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
ID: 12089610

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

856 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