В чем разница между вызовом «make» в eclipse и вызовом «make» в терминале?

#windows #eclipse #makefile #autotools #msys2

#Windows #eclipse #makefile #autotools #msys2

Вопрос:

Я пытаюсь создать проект makefile в eclipse под Windows, но сборка завершается неудачно (Проект> Создать проект). Однако, если я перейду в каталог сборки в терминале msys2 и вызову «make», все будет работать просто отлично. Чтобы выяснить, почему сборка в eclipse не работает, я сейчас пытаюсь найти разницу между использованием make в терминале и в eclipse. До момента сбоя сборки консольный вывод 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 также одинаков в обоих случаях.
Что могло вызвать это?

Комментарии:

1. Когда вы запускаете make , это, в свою очередь, запускает то, что кажется скриптом Autotools configure , и именно здесь возникает разница в поведении. Вы должны иметь возможность получить подробную информацию о сбое, проверив config.log файл в случае сбоя. Скорее всего, разница заключается в переменной окружения в make среде или в аргументах, переданных make — вероятно, в первом, потому что кажется, что make в обоих случаях вызывается без аргументов.

2. Спасибо @JohnBollinger! Теперь я знаю, что искать. Я воссоздал Makefile, перенастроив проект один раз с помощью eclipse, а затем снова из терминала, запустив сценарий настройки. Затем я искал различия в config.log ‘s. Как вы предположили, переменные PATH различны. Я не совсем понимаю, как действовать дальше, но, по крайней мере, теперь я знаю, где искать ошибку 🙂

3. Позже в config.log, созданном неудачным configure запуском, вы найдете конкретную команду компиляции, которую запускал скрипт, и результат. Это может быть более информативным о конкретном характере проблемы. Обратите особое внимание на разные флаги, передаваемые компилятору.

Ответ №1:

Разница между вызовом make в eclipse и в терминале msys2 заключается в том, что он выполняется в разных средах. Чтобы гарантировать, что я получу одинаковый результат с помощью обоих методов, я должен был убедиться, что мой путь к Windows содержит правильные записи. Чтобы выяснить, какие записи мне пришлось добавить в PATH, я проверил config.log как для неудачного, так и для успешного случая.

Кроме того, мне пришлось запустить eclipse от имени администратора, поскольку у него не было прав на создание временных файлов.