How do I make my code compatible to run in Linux (gcc) compiler?

Discussion in 'C++' started by mahesh, Sep 26, 2006.

  1. mahesh

    mahesh Guest

    Hi all,
    I am using Dev C++ IDE for the programming but for the time efficiency,
    I tried to use supercomputer (Linux) to run my program, but some of the
    function such as
    pow(double,double) , `ftime' leads to an error in gcc compiler.
    What kinda changes do I need to adapt so that I can run program in both
    environment??
    I would appreciate any help.
    Mahesh
     
    mahesh, Sep 26, 2006
    #1
    1. Advertising

  2. mahesh wrote:
    > Hi all,
    > I am using Dev C++ IDE for the programming but for the time efficiency,
    > I tried to use supercomputer (Linux) to run my program, but some of the
    > function such as
    > pow(double,double) , `ftime' leads to an error in gcc compiler.
    > What kinda changes do I need to adapt so that I can run program in both
    > environment??
    > I would appreciate any help.
    > Mahesh
    >


    IIRC Dev C++ on Windows uses gcc under the hood.

    What errors are you getting? Did you #include the right headers? Anyway,
    you will have to investigate and correct each error separately.

    Generally you can only call functions that are in the ISO C++ standard
    if you want your code to work everywhere. "pow" is standard, "ftime"
    isn't (however ftime might still work in your case; but you want to ask
    these questions in a gcc, Linux and/or Dev C++ - related newsgroup, not
    here).

    D.
     
    Davlet Panech, Sep 26, 2006
    #2
    1. Advertising

  3. mahesh

    Gavin Deane Guest

    mahesh wrote:
    > Hi all,
    > I am using Dev C++ IDE for the programming but for the time efficiency,
    > I tried to use supercomputer (Linux) to run my program, but some of the
    > function such as
    > pow(double,double) , `ftime' leads to an error in gcc compiler.


    I'm not a gnu compiler expert, but isn't gcc a C compiler? If it is, it
    will have trouble with C++ code.

    > What kinda changes do I need to adapt so that I can run program in both
    > environment??
    > I would appreciate any help.


    If it's not the problem above, you need to identify all the features in
    your program that only work on one compiler and replace them with
    features that work on both compilers.

    For a more specific answer, post some of the troublesome code following
    the guidelines in FAQ 5.8.
    http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.8

    Gavin Deane
     
    Gavin Deane, Sep 26, 2006
    #3
  4. mahesh

    Noah Roberts Guest

    Gavin Deane wrote:
    > mahesh wrote:
    > > Hi all,
    > > I am using Dev C++ IDE for the programming but for the time efficiency,
    > > I tried to use supercomputer (Linux) to run my program, but some of the
    > > function such as
    > > pow(double,double) , `ftime' leads to an error in gcc compiler.

    >
    > I'm not a gnu compiler expert, but isn't gcc a C compiler? If it is, it
    > will have trouble with C++ code.


    Yes, the OP should be using g++. Often people say the one when they
    mean the other though. The gcc command usually does just fine right up
    to the point of linking.
     
    Noah Roberts, Sep 26, 2006
    #4
  5. mahesh

    Nate Barney Guest

    Noah Roberts wrote:
    >
    > Yes, the OP should be using g++. Often people say the one when they
    > mean the other though. The gcc command usually does just fine right up
    > to the point of linking.


    Well, IIRC, "GCC" means two things: 1) GNU C Compiler and 2) GNU
    Compiler Collection. So, GCC is also the name of the entire suite of
    compilers.

    Nate
     
    Nate Barney, Sep 26, 2006
    #5
  6. mahesh wrote:
    > Hi all,
    > I am using Dev C++ IDE for the programming but for the time efficiency,
    > I tried to use supercomputer (Linux) to run my program, but some of the
    > function such as
    > pow(double,double) , `ftime' leads to an error in gcc compiler.
    > What kinda changes do I need to adapt so that I can run program in both
    > environment??
    > I would appreciate any help.

    for pow, you need to include the math.h header, and link to the libm
    library. You need to find a replacement for ftime, e.g. gettimeofday.
     
    =?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?=, Sep 27, 2006
    #6
  7. mahesh

    benben Guest

    mahesh wrote:
    > Hi all,
    > I am using Dev C++ IDE for the programming but for the time efficiency,
    > I tried to use supercomputer (Linux) to run my program, but some of the
    > function such as
    > pow(double,double) , `ftime' leads to an error in gcc compiler.
    > What kinda changes do I need to adapt so that I can run program in both
    > environment??
    > I would appreciate any help.
    > Mahesh
    >


    We don't know either. You need to show us the code. That way we can
    compile your program and tell you exactly what you are getting wrong.

    Ben
     
    benben, Sep 27, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. P
    Replies:
    5
    Views:
    2,065
  2. Replies:
    6
    Views:
    393
  3. Alexander Dong Back Kim

    Compatible codes for both Visual Studio 2005 and gcc

    Alexander Dong Back Kim, Sep 23, 2007, in forum: C++
    Replies:
    12
    Views:
    544
    Ian Collins
    Sep 24, 2007
  4. Replies:
    10
    Views:
    2,910
    Frank
    Aug 2, 2009
  5. pantagruel
    Replies:
    0
    Views:
    246
    pantagruel
    Feb 17, 2006
Loading...

Share This Page