【问题标题】:How do I get autotools to compile with the Intel compiler?如何让 autotools 使用英特尔编译器进行编译?
【发布时间】:2010-11-19 19:22:20
【问题描述】:

我希望我的代码使用英特尔编译器或 gcc/g++ 编译,具体取决于配置参数。这可能吗?我需要在 configure.ac 和 Makefile.am 文件中添加什么来实现这一点?

【问题讨论】:

    标签: autotools autoconf automake


    【解决方案1】:

    我会这样做:

    AC_PROG_CC([icc gcc])
    

    这将按照指定的顺序查找编译器,除非被 ./configure 的参数覆盖

    $ ./confgure CC=gcc
    

    【讨论】:

      【解决方案2】:

      如果您想在编译时使用 gcc 以外的编译器,请将 'CC=/path/to/compiler' 作为参数传递给配置。 (即运行 ./configure CC=/path。不要使用 CC=/path ./configure 的形式。)如果你希望默认编译器是 gcc 以外的东西,你可以把

      CC=${CC-/path/to/default/compiler}

      在调用 AC_PROG_CC 之前的 configure.ac 中。

      【讨论】:

      • 这不是一个好方法。按照 freedrull 的建议使用 AC_PROG_CC。
      【解决方案3】:

      当然是。您可以在 configure.ac 中配置默认​​编译器,如果用户想使用其他编译器,他(或她)可以将其传递给 ./configure 脚本。

      您可以在这里找到更多信息:How to use autotools

      您可能感兴趣的部分位于页面中间:

      #if a compiler is not specified by the user use intel compilers
      AC_PATH_PROG(CC_PATH, $CC, NO_PATH)
      if test "$CC_PATH" = NO_PATH; then
       CC="icc"
      fi
      

      【讨论】:

      • 你不能也这样做吗:
      • autoconf 2.69 下,你建议的结果是The usual way to define 'CC' is to add 'AC_PROG_CC'
      【解决方案4】:

      通常你可以运行

      bash $ CC=icc ./configure
      

      使用 lcc 或任何其他编译器作为 C 编译器,前提是其余的配置和构建过程不使用任何 gcc'ism。

      【讨论】:

      • 最好使用:$ ./configure CC=icc。如果您将 CC 作为参数传递给配置,则使用 config-status 重新配置将起作用。如果你在环境中设置了CC,那么它不会。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-22
      • 2021-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-08
      相关资源
      最近更新 更多