我正在尝试在 Windows 上的 mingw/msys 下编译一个开源项目。
makefile 包含(除其他外)此行
@${MAKE} --no-print-directory -C . -f physfs.make
physfs.make 包含(除其他外)以下几行:
ifndef CC
CC = gcc
endif
当我运行 make 时,出现以下错误:
Creating obj/Debug/physfs
physfs.c
make[1]: cc: Command not found
make[1]: *** [obj/Debug/physfs/physfs.o] Error 127
make: *** [physfs] Error 2
如果我注释 ifndef / endif 对,使 CC = gcc 完好无损,则构建可以正常工作。如果我发出这个命令而不是 make:
make -e CC=gcc
构建也可以工作。但是当我在 msys 中运行以下命令时:
echo $CC
没有显示任何内容。
我认为环境变量在 MSYS 中的工作原理有一些基本的内容,但我不明白。
请帮我解决这个问题,这样我就可以理解为什么简单的“make”命令会抱怨,以及为什么 ifndef 块不能按我期望的方式运行。
I'm trying to compile an open source project on windows under mingw/msys.
The makefile contains (among others) this line
@${MAKE} --no-print-directory -C . -f physfs.make
physfs.make contains (among others) these lines:
ifndef CC
CC = gcc
endif
when I ran make I get the following error:
Creating obj/Debug/physfs
physfs.c
make[1]: cc: Command not found
make[1]: *** [obj/Debug/physfs/physfs.o] Error 127
make: *** [physfs] Error 2
If I comment the ifndef / endif pair leaving CC = gcc intact, the build works. If instead of make I issue this command:
make -e CC=gcc
the build works as well. But when I run the following command in msys:
echo $CC
nothing is displayed.
I think there is something basic about how environment variables work in MSYS and make that I don't understand.
Could please some help me troubleshoot this issue, so I can understand why simple 'make' command complains and why the ifndef block doesn't function as I expect it to function.
发布评论
评论(1)
CC
是几个隐式变量之一< /a> 在 make 会话中自动定义,因此ifndef CC
行应该永远评估为 true。这解释了为什么您在命令行上看不到
echo $CC
的任何内容。 MSYS环境没有CC的概念。如果您想在 make 会话中查看变量的值,您可以随时使用 info 函数:
这将在评估 makefile 中的该行时将 CC 变量的值回显到控制台。
CC
is one of several implicit variables automatically defined in a make session, so the lineifndef CC
should never evaluate to true.This explains why you see nothing on the command line for
echo $CC
. The MSYS environment has no concept of CC.If you want to see the value of variables from within a make session, you can always use the info function:
This will echo the value of the CC variable to the console at the point when that line in the makefile is evaluated.