如何使用英特尔编译器来使用自动工具进行编译?

发布于 2024-08-01 21:05:36 字数 105 浏览 5 评论 0原文

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

I want my code to compile with the Intel compiler(s) or with gcc/g++ depending on a configure argument. Is this possible? What do I need to put in my configure.ac and Makefile.am files to make this happen?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

网白 2024-08-08 21:05:36

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

您可以在这里找到更多相关信息:如何使用自动工具

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

#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

Of course it is. You can configure a default compiler in configure.ac and if the user wants to use another compiler, he (or she) can pass it to the ./configure script.

You'll find more about it here: How to use autotools.

The part that might be interesting for you is at the middle of the page:

#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
无声静候 2024-08-08 21:05:36

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

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

在调用之前放入 configure.ac AC_PROG_CC。

If you want to use a compiler other than gcc when you compile, pass 'CC=/path/to/compiler' as an argument to configure. (That is, run ./configure CC=/path. Do not use the form CC=/path ./configure.) If you want the default compiler to be something other than gcc, you can put

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

in configure.ac before the invocation of AC_PROG_CC.

欲拥i 2024-08-08 21:05:36

我会这样做:

AC_PROG_CC([icc gcc])

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

$ ./confgure CC=gcc

I would do this:

AC_PROG_CC([icc gcc])

This will look for the compilers in the order specified, unless overridden with an argument to ./configure

$ ./confgure CC=gcc
ゞ记忆︶ㄣ 2024-08-08 21:05:36

通常,您可以运行

bash $ CC=icc ./configure

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

Usually you can just run

bash $ CC=icc ./configure

to use lcc, or any other compiler as the C compiler, provided the rest of the configure and build process doesn't use any gcc'ism.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文