Thread: A general quaetion on portability

  1. #1
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342

    A general question on portability

    IF i have a C program that is running on SUN OS and If I want to get the same program to compile in RED-HAT LINUX, what are the things I need to look at ?..
    Or can some one guide me to any resourse that gives some details on this...
    Last edited by kris.c; 07-19-2006 at 12:00 AM.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Too vague. If it's a purely Standard/ANSI C compliant program, there's nothing you have to worry about or look into. The difference comes down to really the difference between compilers, libraries, and system calls.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    With any luck, you will have only used functions which are either
    - ANSI-C standard functions
    - POSIX functions.

    Just look at each external function you've written and read the manual page for it.
    It it says "ANSI-C" (like strcpy) or POSIX (like stat), then you should be good to go.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342
    Well, I can be more precise now, As the last assignment for this summer, my project guide has asked me to get a program that runs on DEC--ALPHA to work on LINUX. I have no idea what this does, all i know is it uses pg-plot.. It compiles and runs successfully on DEC_ALPHA, but I get the following errors in LINUX,


    Code:
     In function `main':
    : the `gets' function is dangerous and should not be used.
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `do_lio'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `e_wsle'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `e_wsfe'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `s_rsfe'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `s_cmp'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `do_uio'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `e_rsfe'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `f_inqu'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `e_rsue'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `i_indx'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `do_fio'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `e_wsfi'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `s_cat'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `s_stop'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `s_wsfi'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `G77_getenv_0'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `s_rsue'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `f_clos'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `f_open'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `s_wsle'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `s_wsfe'
    /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../..//libpgplot.so: undefined 
    reference to `s_copy'
    I sniffed around and I could locate some of the " .h " files on the net, but to create the " .a " or the " .so " lib files, I need the ".c " or the ". o " files. Any idea how to go about..I am having pgplot installed on my machine.

  5. #5
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342
    yeah, found out all of them sit in the file " libg2c.a" ..thanks anyway

  6. #6
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    looks like u have been using gets fucntion. don't use then read FAQ

    ssharish2005

  7. #7
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342
    Well, its actually not my program, just helping some one else..That is taken care of.. I am still getting one more error :

    Code:
      
      In function `_start':
    ../sysdeps/i386/elf/start.S:77: undefined reference to `main'

    And "_start" is actually defined as a variable.. Any suggestions?
    I have used main in the normal way itself ,

    Code:
      int main( int argc, char *argv[])
       .............
      ..............
      return 0;

  8. #8
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342
    ha! -combine to the rescue ..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The Tone of General Discussions
    By sean in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 06-03-2009, 09:06 PM
  2. General Guidelines on Preventing Header File collision
    By stanlvw in forum C++ Programming
    Replies: 12
    Last Post: 07-05-2008, 04:02 AM
  3. Password program / general programming questions
    By plr112387 in forum C++ Programming
    Replies: 13
    Last Post: 11-04-2007, 10:10 PM
  4. Program Portability (code portability)
    By Perica in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2002, 10:03 AM
  5. General Protection Exception
    By s9uare in forum C++ Programming
    Replies: 1
    Last Post: 11-02-2002, 10:46 AM