<small id='eCqB9'></small><noframes id='eCqB9'>

    <bdo id='eCqB9'></bdo><ul id='eCqB9'></ul>

      <legend id='eCqB9'><style id='eCqB9'><dir id='eCqB9'><q id='eCqB9'></q></dir></style></legend>
    1. <i id='eCqB9'><tr id='eCqB9'><dt id='eCqB9'><q id='eCqB9'><span id='eCqB9'><b id='eCqB9'><form id='eCqB9'><ins id='eCqB9'></ins><ul id='eCqB9'></ul><sub id='eCqB9'></sub></form><legend id='eCqB9'></legend><bdo id='eCqB9'><pre id='eCqB9'><center id='eCqB9'></center></pre></bdo></b><th id='eCqB9'></th></span></q></dt></tr></i><div id='eCqB9'><tfoot id='eCqB9'></tfoot><dl id='eCqB9'><fieldset id='eCqB9'></fieldset></dl></div>
    2. <tfoot id='eCqB9'></tfoot>

      为什么要先编译成目标文件?

      Why Compile to an Object File First?(为什么要先编译成目标文件?)
          • <bdo id='wc1FY'></bdo><ul id='wc1FY'></ul>

          • <legend id='wc1FY'><style id='wc1FY'><dir id='wc1FY'><q id='wc1FY'></q></dir></style></legend>
            <i id='wc1FY'><tr id='wc1FY'><dt id='wc1FY'><q id='wc1FY'><span id='wc1FY'><b id='wc1FY'><form id='wc1FY'><ins id='wc1FY'></ins><ul id='wc1FY'></ul><sub id='wc1FY'></sub></form><legend id='wc1FY'></legend><bdo id='wc1FY'><pre id='wc1FY'><center id='wc1FY'></center></pre></bdo></b><th id='wc1FY'></th></span></q></dt></tr></i><div id='wc1FY'><tfoot id='wc1FY'></tfoot><dl id='wc1FY'><fieldset id='wc1FY'></fieldset></dl></div>

            <small id='wc1FY'></small><noframes id='wc1FY'>

                <tbody id='wc1FY'></tbody>

                <tfoot id='wc1FY'></tfoot>
                本文介绍了为什么要先编译成目标文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                去年,我在一所研究型大学工作,开始使用 Fortran 进行编程.我以前的大部分经验都是使用 PHP 或旧 ASP 等网络语言,所以我是编译语句的新手.

                In the last year I've started programming in Fortran working at a research university. Most of my prior experience is in web languages like PHP or old ASP, so I'm a newbie to compile statements.

                我正在修改两个不同的代码.

                I have two different code I'm modifying.

                一个在创建可执行文件之前有一个从模块创建 .o 文件的显式语句(例如 gfortran -c filea.f90).

                One has an explicit statement creating .o files from modules (e.g. gfortran -c filea.f90) before creating the executable.

                另一个直接创建可执行文件(有时创建.mod文件,但没有.o文件,例如gfortran -o executable filea.f90 fileb.f90 mainfile.f90).

                Another are creating the executable file directly (sometimes creating .mod files, but no .o files, e.g. gfortran -o executable filea.f90 fileb.f90 mainfile.f90).

                • 有没有理由(除了 Makefile 之外)一种方法比另一种方法更受欢迎?

                推荐答案

                首先编译为目标文件称为单独编译.有很多优点和一些缺点.

                Compiling to object files first is called separate compilation. There are many advantages and a few drawbacks.

                优点:

                • 易于将目标文件 (.o) 转换为库并稍后链接到它们
                • 多人可以同时处理不同的源文件
                • 更快的编译(当源代码没有改变时,你不会一次又一次地编译相同的文件)
                • 目标文件可以由不同的语言来源制成,并在以后链接在一起.为此,目标文件只需使用相同的格式和兼容的调用约定.
                • 单独编译允许分发静态或共享的系统范围的库(操作系统库、语言标准库或第三方库).

                缺点:

                • 有些优化(比如优化函数)是编译器无法执行的,链接器也不关心;然而,许多编译器现在包括执行链接时间优化"的选项,这在很大程度上消除了这个缺点.但这对于系统库和第三方库来说仍然是一个问题,尤其是对于共享库(无法优化掉每次运行时可能发生变化的组件部分,但是其他技术,如 JIT 编译可能会缓解这种情况).
                • 在某些语言中,程序员必须提供某种类型的标头以供其他将与此对象链接的人使用.例如,在 C 中,您必须提供 .h 文件以与您的目标文件一起使用.但无论如何,这是一种很好的做法.
                • 在像 C 或 C++ 这样的基于文本的包含的语言中,如果你改变一个函数原型,你必须在两个地方改变它.一次在头文件中,一次在实现文件中.
                • There are some optimizations (like optimizing functions away) that the compiler cannot perform, and the linker does not care about; however, many compilers now include the option to perform "link time optimization", which largely negates this drawback. But this is still an issue for system libraries and third party libraries, especially for shared libraries (impossible to optimize away parts of a component that may change at each run, however other techniques like JIT compilation may mitigate this).
                • in some languages, the programmer has to provide some kind of header for the use of others that will link with this object. For example in C you have to provide .h files to go with your object files. But it is good practice anyway.
                • in languages with text based includes like C or C++, if you change a function prototype, you have to change it in two places. Once in header file, once in the implementation file.

                这篇关于为什么要先编译成目标文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Is Type(::x); valid?(是类型(::x);有效的?)
                Difference between an inline function and static inline function(内联函数和静态内联函数的区别)
                Compilation fails randomly: quot;cannot open program databasequot;(编译随机失败:“无法打开程序数据库)
                Too many initializers error for a simple array in bcc32(bcc32 中的简单数组的初始值设定项过多错误)
                No Member named stoi in namespace std(命名空间 std 中没有名为 stoi 的成员)
                Error using a constexpr as a template parameter within the same class(在同一个类中使用 constexpr 作为模板参数时出错)
              1. <i id='tOLlL'><tr id='tOLlL'><dt id='tOLlL'><q id='tOLlL'><span id='tOLlL'><b id='tOLlL'><form id='tOLlL'><ins id='tOLlL'></ins><ul id='tOLlL'></ul><sub id='tOLlL'></sub></form><legend id='tOLlL'></legend><bdo id='tOLlL'><pre id='tOLlL'><center id='tOLlL'></center></pre></bdo></b><th id='tOLlL'></th></span></q></dt></tr></i><div id='tOLlL'><tfoot id='tOLlL'></tfoot><dl id='tOLlL'><fieldset id='tOLlL'></fieldset></dl></div>
                • <bdo id='tOLlL'></bdo><ul id='tOLlL'></ul>
                  <legend id='tOLlL'><style id='tOLlL'><dir id='tOLlL'><q id='tOLlL'></q></dir></style></legend>

                        <tbody id='tOLlL'></tbody>

                      <small id='tOLlL'></small><noframes id='tOLlL'>

                        <tfoot id='tOLlL'></tfoot>