在 makefile 中检查操作系统时如何修复此错误?

问题描述 投票:0回答:1

如果操作系统是 Windows,我试图在我的代码中添加 .exe 扩展名。 生成文件代码:

check_os:
    ifeq ($(OS),Windows_NT)
        g++ hello.cpp -o hello.exe
    else
        g++ hello.cpp -o hello
    endif

all: check_os

但我收到此错误:

ifeq (Windows_NT,Windows_NT)
process_begin: CreateProcess(NULL, ifeq (Windows_NT,Windows_NT), ...) failed.
make (e=2): Systemet finner ikke angitt fil.
make: *** [Makefile:2: check_os] Error 2

我尝试搜索,但找不到任何好的答案

makefile operating-system
1个回答
0
投票

您只需移除一层填充物即可:

check_os:
ifeq ($(OS),Windows_NT)
    echo windows
else
    echo not windows
endif


all: check_os

ifeq
现在降低了 1 个 TAB

© www.soinside.com 2019 - 2024. All rights reserved.