gmake 覆盖编译器目录

发布于 2024-12-17 05:45:23 字数 700 浏览 2 评论 0原文

有没有办法指定 gmake 备用编译器目录。即:我安装了多个编译器并尝试在编译时使用备用 gcc。

就像我指定它使用新指定的 gcc 一样。

gmake CC=/opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/gcc 
    CXX=/opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/g++ 
    LD=/opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/gcc 
    AR=/opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/ar 

我试图避免的是为所有工具指定绝对路径。我正在尝试类似的事情

gmake COMPILER_DIR=/opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/

也可能适合作为交叉编译器问题。

Is there any way to specify gmake an alternate compiler directory. ie: i have multiple compilers installed and trying to use alternate gcc while compilation.

like if i specify it uses the new specified gcc.

gmake CC=/opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/gcc 
    CXX=/opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/g++ 
    LD=/opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/gcc 
    AR=/opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/ar 

what i am trying to avoid is specify absolute path for all tools. i am trying something like

gmake COMPILER_DIR=/opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/

this might fit as a cross-compiler question also.

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

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

发布评论

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

评论(3

听风念你 2024-12-24 05:45:23

在 makefile 中,您可以使用如下内容:

CC = $(COMPILER_DIR)gcc

如果您未定义 COMPILER_DIR,则将使用普通系统 gcc,否则从您的目录中使用。

In the makefile you can use something like this:

CC = $(COMPILER_DIR)gcc

If you do not define COMPILER_DIR then the normal system gcc will be used, otherwise from your directory.

遇见了你 2024-12-24 05:45:23

以下是 crosstool tool chainkit 的建议,仅供将来参考。
方法一
不要使用完整的 /opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/ 使用 PATH=/opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/bin 并在 make 文件中保留CC=$(CROSSCOMPILERVERSION)gcc 其中 CROSSCOMPILERVERSION=i686-unknown-linux-gnu 不知怎的,这个设置效果最好,但仍然不确定如何。

方法2
使用方法 1 中建议的路径,但另外在 crosstool bin 目录中创建软链接。就像在/opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/bin中添加i686-unknown-linux-gnu-gcc的软链接作为gcc。这比更改 makefile 更容易(或者在您没有更改 makefile 的权限的情况下)

Just for future reference here's how crosstool tool chainkit suggest.
Method 1
Instead of using complete /opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/ use PATH=/opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/bin and in make files keep CC=$(CROSSCOMPILERVERSION)gcc where CROSSCOMPILERVERSION=i686-unknown-linux-gnu somehow this setup works best, still not sure how.

Method 2
Use the path as suggested in method.1 but additionally create softlink in crosstool bin dir. like in /opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/bin add softlink of i686-unknown-linux-gnu-gcc as gcc. This is easier than changing makefile (or in cas you dont have permission to change makefiles)

阳光下的泡沫是彩色的 2024-12-24 05:45:23

当您构建 binutilsgcc 时,它们会安装在两个不同的路径中:

  • bin/PREFIX-gcc
  • PREFIX/bin/gcc >

这允许您在路径中拥有多个交叉编译器,每个交叉编译器具有不同的可执行文件名称,但您也可以简单地将第二个变体放入路径中,这样 gcc 现在就是选择的交叉版本。这对于 Makefile 很有用。

您的示例已使用第二种形式: /opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/ar/opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/bin/i686-unknown-linux-gnu-ar (它可能也存在于您的系统)。

因此,您可以使用 PATH=/opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/:$PATH make 进行构建。 .. 现在默认的 gcc 将是交叉版本。

When you build binutils and gcc they install in two different paths:

  • bin/PREFIX-gcc
  • PREFIX/bin/gcc

This allows you to have several cross compilers in your path each with different executables names, but you can also simply put the second variant in your path such that gcc is now the cross version of choice. This is useful for Makefiles.

Your example already uses the second form: /opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/ar as opposed to /opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/bin/i686-unknown-linux-gnu-ar (which probably also exists on your system).

So you can build with PATH=/opt/crosstool/gcc-3.2.2-glibc-2.2.5/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin/:$PATH make ... and now the default gcc will be the cross version.

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