make:源名称和二进制名称相同 [英] make : source and binary same name

查看:73
本文介绍了make:源名称和二进制名称相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多扩展名为.cpp

f001.cpp
abc.cpp
...

我尝试以此编译任何文件

I try compile any file with this

%.cpp:
        g++ -o $* $*.cpp

但我知道

make: *** No hay objetivos.  Alto.

推荐答案

这项工作有效吗?

f001.o:

%.o: %.cpp
        g++ -o $@ $<

好!现在尝试这个:

OBJETIVOS = f001.o abc.o def.o ghi.o

todos: $(OBJETIVOS)

%.o: %.cpp
        g++ -o $@ $<

这里有一个问题.通常,abc是可执行二进制文件,而abc.o是目标文件.您正在构建可执行文件,但将其称为abc.o.如果希望它们成为可执行文件,则最好将它们称为abc.

There is one problem here. Usually abc is the executable binary file, and abc.o is the object file. You are building executable files, but calling them abc.o. If you want them to be executable files, it would be better to call them abc.

这篇关于make:源名称和二进制名称相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆