【问题标题】:Whats the difference between calling "make" in eclipse and calling "make" in terminal?在 Eclipse 中调用“make”和在终端中调用“make”有什么区别?
【发布时间】:2020-08-14 13:10:06
【问题描述】:

我正在尝试在 windows 下的 eclipse 中构建一个 makefile 项目,但构建失败(项目 > 构建项目)。但是,如果我导航到 msys2 终端中的构建目录并调用“make”,一切都会运行得很好。 为了弄清楚为什么在 Eclipse 中构建不起作用,我现在试图找出在终端和 Eclipse 中使用 make 之间的区别。 在构建失败之前,eclipse 的控制台输出与 msys2 终端中的输出相同:

这是eclipse中的控制台输出:

make 
Making all in i386-rtems5/c
make[1]: Entering directory '/c/rt5/rtems/kernel/pc/i386-rtems5/c'
Making all in .
make[2]: Entering directory '/c/rt5/rtems/kernel/pc/i386-rtems5/c'
Configuring RTEMS_BSP=pc686
checking for gmake... no
checking for make... make
checking build system type... x86_64-w64-mingw32
checking host system type... i386-pc-rtems5
checking rtems target cpu... i386
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for i386-rtems5-strip... i386-rtems5-strip
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... yes
checking for RTEMS_BSP... pc686
checking whether CPU supports libposix... yes
configure: setting up make/custom
configure: creating make/pc686.cache
make[3]: Entering directory '/c/rt5/rtems/kernel/pc/i386-rtems5/c/pc686'
make[3]: Leaving directory '/c/rt5/rtems/kernel/pc/i386-rtems5/c/pc686'
checking for RTEMS_CPU_MODEL... 
checking for RTEMS_BSP_FAMILY... pc386
checking for CPU_CFLAGS... (cached) -mtune=pentiumpro -march=pentium
checking for CFLAGS_OPTIMIZE_V... (cached) -O2 -g -ffunction-sections -fdata-sections
checking for style of include used by make... GNU
checking for i386-rtems5-gcc... i386-rtems5-gcc
checking for i386-rtems5-gcc... (cached) i386-rtems5-gcc
checking whether the C compiler works... no
configure: error: in `/c/rt5/rtems/kernel/pc/i386-rtems5/c/pc686':
configure: error: C compiler cannot create executables
See `config.log' for more details
make[2]: *** [Makefile:731: pc686] Error 1
make[2]: Leaving directory '/c/rt5/rtems/kernel/pc/i386-rtems5/c'
make[1]: *** [Makefile:289: all-recursive] Error 1
make[1]: Leaving directory '/c/rt5/rtems/kernel/pc/i386-rtems5/c'
make: *** [Makefile:410: all-recursive] Error 1
"make" terminated with exit code 2. Build might be incomplete.

这是msys2终端的输出:

$ make
Making all in i386-rtems5/c
make[1]: Verzeichnis „/c/rt5/rtems/kernel/pc/i386-rtems5/c“ wird betreten
Making all in .
make[2]: Verzeichnis „/c/rt5/rtems/kernel/pc/i386-rtems5/c“ wird betreten
Configuring RTEMS_BSP=pc686
configure: loading site script /mingw64/etc/config.site
checking for gmake... no
checking for make... make
checking build system type... x86_64-w64-mingw32
checking host system type... i386-pc-rtems5
checking rtems target cpu... i386
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for i386-rtems5-strip... i386-rtems5-strip
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... yes
checking for RTEMS_BSP... pc686
checking whether CPU supports libposix... yes
configure: setting up make/custom
configure: creating make/pc686.cache
make[3]: Entering directory '/c/rt5/rtems/kernel/pc/i386-rtems5/c/pc686'
make[3]: Leaving directory '/c/rt5/rtems/kernel/pc/i386-rtems5/c/pc686'
checking for RTEMS_CPU_MODEL...
checking for RTEMS_BSP_FAMILY... pc386
checking for CPU_CFLAGS... (cached) -mtune=pentiumpro -march=pentium
checking for CFLAGS_OPTIMIZE_V... (cached) -O2 -g -ffunction-sections -fdata-sections
checking for style of include used by make... GNU
checking for i386-rtems5-gcc... i386-rtems5-gcc
checking for i386-rtems5-gcc... (cached) i386-rtems5-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
[...]

据我所知,在这两种情况下都调用了 make 但结果不同。 Makefile 在这两种情况下也是相同的。 这是什么原因造成的?

【问题讨论】:

  • 当您运行make 时,它又会运行看起来像Autotools configure 的脚本,这就是行为差异出现的地方。您应该能够通过检查失败案例中的config.log 文件来获取失败的详细信息。可能区别在于 make 的环境中的环境变量或传递给 make 的参数——可能是前者,因为在这两种情况下似乎都调用了 make 而没有参数。
  • 谢谢@JohnBollinger!我现在知道要寻找什么了。我通过使用 eclipse 重新配置项目一次,然后通过运行配置脚本再次从终端重新创建 Makefile。然后我寻找 config.log 的差异。正如您所建议的,PATH 变量是不同的。我不太清楚如何从这里继续,但至少我现在知道在哪里查找错误:)
  • 稍后在由失败的configure 运行创建的config.log 中,您将找到脚本运行的特定编译命令以及结果。这可能更能说明问题的具体性质。特别注意传递给编译器的不同标志。

标签: windows eclipse makefile autotools msys2


【解决方案1】:

在eclipse和msys2终端调用make的区别在于运行在不同的环境。为了确保我使用这两种方法获得相同的结果,我必须确保我的 windows PATH 包含正确的条目。为了找出我必须添加到 PATH 的条目,我检查了 config.log 的失败案例和成功案例。

此外,我必须以管理员身份运行 eclipse,因为它没有创建临时文件的权限。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-21
    • 2013-12-02
    • 2010-10-20
    • 2010-11-14
    • 1970-01-01
    • 2021-11-04
    • 1970-01-01
    • 2014-06-07
    相关资源
    最近更新 更多