linux - make在不同的linux下有不同的表现吗?

标签 linux ubuntu makefile ubuntu-14.04 ubuntu-16.04

我有一个在这个版本的 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}

最佳答案

你的 Makefile 用劣质的本土 cargo 崇拜猜测取代了 make 良好的内置默认规则。 Make 确切地知道如何使用适合您的编译器的正确标志和选项来编译 C 文件;不要试图智胜它,特别是如果您不熟悉编译器。 (因此,这本身并不是一个 make 问题;但是让 make 使用它的默认值将修复您不正确的编译器调用。)

关于linux - make在不同的linux下有不同的表现吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47358966/

相关文章:

c++ - 在Linux上的C++中执行Shell命令xdotool

linux - Nginx+RTMP 设置与 USB 摄像头

java - Elasticsearch 内存问题

c - 在 Linux 中创建静态库时出现问题

python - 检查 Makefile 中是否存在 conda 环境

c++ - USB2Serial 的 Linux IOCTL

linux - 如何用蓝色邮寄邮件正文文本 |Linux |

具有大量 RAM 的 Python 2.7 MemoryError(64 位,Ubuntu)

python - egg_info 失败,错误代码 1

c++ - GNU make 有时不在 VPATH 中声明的文件夹中搜索