Find the answer to your Linux question:
Results 1 to 2 of 2
I have some source code that was compiling well with gcc 4.1, recently I moved to openSuse that has gcc 4.3.1 and the same code fails to compile using this ...
  1. #1
    Just Joined!
    Join Date
    Sep 2007
    Posts
    6

    Question gcc 4.1 vs 4.3 source code compatibility

    I have some source code that was compiling well with gcc 4.1, recently I moved to openSuse that has gcc 4.3.1 and the same code fails to compile using this version of compiler.
    Generally it complains that it doesn't know functions like malloc or wtol. I can easily fix this by including appropriate headers like stdlib.h or what ever is necessary.

    But it is important not to change the source code at all. Is it possible to make them compile using 4.3.1? Is there some flag that I can specify to the compiler?
    Or do I need to uninstall 4.3.1 and install 4.1?

    Thanks.

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    If the source code is the only thing you don't need to change, here's a kluge for you.

    First, make a file whose only purpose is to include what needs to be included. I'm going to call it fred.h. The file might consist of this and only this, for example:
    Code:
    #include stdlib.h
    Then, before compiling each module, make a temporary file which is a concatenation of fred.h and the original source file. So instead of this:
    Code:
    gcc barney.c -o barney
    you might do this:
    Code:
    cat fred.h barney.c > barney.tmp.c
    gcc barney.tmp.c -o barney
    or instead of this:
    Code:
    gcc barney.c betty.c wilma.c -o barney
    do this:
    Code:
    cat fred.h barney.c > barney.tmp.c
    cat fred.h betty.c > betty.tmp.c
    cat fred.h wilma.c > wilma.tmp.c
    gcc barney.tmp.c betty.tmp.c wilma.tmp.c -o barney
    Might this help?
    --
    Bill

    Old age and treachery will overcome youth and skill.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...