【问题标题】:Does make behave different in different linux?make 在不同的 linux 中的行为是否不同?
【发布时间】:2017-11-17 20:43:50
【问题描述】:

我有一个在这个版本的 Linux 上运行良好的 make 文件。然而 为什么它不在这个其他版本上运行......

Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:        14.04
codename :      trusty

就在这里...它不能在这个上运行?为什么?

Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:        16.04
Codename:       xenial

我在 xenial 上收到此错误...为什么?

Ubuntu mate $:make
gcc: error: missing filename after ‘-o’
gcc: fatal error: no input files
compilation terminated.

这是我的make文件(更新了,上一篇没有这个)

CFLAGS = gcc -g
OBJ = dummyDriverX1.o x1.o error.o

# Automatic substitution using suffix rules to
%.o: %.c
    ${CFLAGS} -c $< 

%.o: %.cpp
    ${CFLAGS} -c $<

# Building x1 based on the required .o files
pell: ${OBJ}
    ${CFLAGS} -o pell ${OBJ}

clean:
    rm ${OBJ}

【问题讨论】:

  • 显示生成文件。
  • Linux版本无关,重要的是make的版本。
  • makefile 可能依赖于其他有问题的脚本。
  • 不确定这是否有任何价值,但是当我调用 make -v (以便我可以看到版本,根据手册页)我得到一个 gcc: fatal error: no input files编译终止。
  • 你的Makefile 真的错了。请参阅this 示例;删除您的Makefile,运行make -p 以了解内置规则,并正确编写您的新Makefile

标签: linux ubuntu makefile ubuntu-14.04 ubuntu-16.04


【解决方案1】:

你的 Makefile 用劣质的本土货物狂热的猜测取代了 make 良好的内置默认规则。 Make 确切地知道如何为您的编译器使用正确的标志和选项编译 C 文件;不要试图超越它,特别是如果您不熟悉编译器。 (所以,它本身并不是一个 make 问题;但是让 make 使用它的默认值会修复你不正确的编译器调用。)

【讨论】:

    猜你喜欢
    • 2020-03-21
    • 1970-01-01
    • 2013-11-21
    • 1970-01-01
    • 2021-08-10
    • 1970-01-01
    • 1970-01-01
    • 2016-01-01
    • 1970-01-01
    相关资源
    最近更新 更多