Are object files platform independent?

后端 未结 9 783
走了就别回头了
走了就别回头了 2020-12-24 02:15

Is it possible to compile program on one platform and link with other ? What does object file contain ? Can we delink an executable to produce object file ?

9条回答
  •  孤独总比滥情好
    2020-12-24 02:50

    It doesn't need to be said again: C/C++ object files aren't portable.

    On the other hand, ANSI C is one of the most portable languages there is. You may not be able to pick up your object files, but recompiling your source is likely to work if you stick to the ANSI C standard. This might also be true of C++ as well.

    I don't know how universal GNU C++ is, but if you can compile with gcc on one computer you're good to go on any other machine that also has gcc installed. Just about every machine you can think of has a C compiler. That's portability.

提交回复
热议问题