programming in C

Hi Guys,

I am willing to write some programs in C/C++ for Solaris machine.
I am pretty good in C++ programming for PC.
But I have some questions, while starting programming in solaris.

  1. Which one is the most suitable & easy to use compiler?
    (Most probabaly I will use vi editor to edit programs, any suggestions welcomed)
  2. From where I can get that compiler and how to install the compiler
  3. From where I can get C/C++ libraries for Solaris/UNIX?
  4. How to start compiling and running program?
  5. Will those programs written portable on both LINUX/SOLARIS?

Regards
@Asteroid

I'd suggest gcc. At its very simplest, gcc filename1.c -o filename can transform one C file into one executable. More complex options and methods are there to transform .c files into .o files, which can all be linked together into one executable. Try 'gcc --version' to see if you have it already.

(Most probabaly I will use vi editor to edit programs, any suggestions welcomed)

Text is text, the compiler doesn't care. :slight_smile: Personally I prefer editors designed for keyboards newer than the ADM3A but tastes differ :wink:

Depends what you mean. A program compiled on solaris won't run on linux and vice versa, but proper C code using portable features should compile fine in either.

Hi Guys,

Fortunately I have both machines, LINUX on HP Prolient and SUN on SPARC. Both has GCC compilers.

So, should I write source and compile same source on both machines separately to obtain two distributions of executable.

Or on the other hand write code in such a way if compiled on any of the machine(SUN) will work on the other (LINUX).

which approach is appropriate. Will the 1st approach will work?
What you guys suggest.

SUN:

LINUX:

Yep, that's the idea. Programs using POSIX features should compile on most any POSIX system.

You won't be able to produce an executable that'll work on both.

The first approach is the preferred one and I don't think you can compile a single executable to work on both Linux and Solaris machines. Differences in MPU instruction set, endianness etc. come into play during compilation so the object code produced on one platform would be incompatible on the other.