0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

makeはMakefileなしでも実行できる(時がある)

0
Last updated at Posted at 2022-06-30

概要

makeコマンドは、内部にデータベースがあるとのことで、Makefileがなくても簡単な例であれば実行できる。
(知らなかった)

内容

状況

$ ls
hello.c
hello.c
#include <stdio.h>

int main(void)
{
  printf("hello, world\n");
}

実行

$ make hello
cc     hello.c   -o hello

確認

$ ls
hello   hello.c
$ ./hello
hello, world

感想

ちょっと便利。

※追記蛇足(オプションをちょっと添えたいとき)
コンパイラを指定したり、ライブラリを指定したりしたいときは、ちょっとだけMakefileを書いておくのも良い。

$ ls
hello.c Makefile
$ make hello
clang     hello.c  -lhogefuga -o hello
$ ./hello
hello, world
Makefile
LDLIBS += -lhogefuga
CC := clang
hello.c
#include <hogefuga.h>
#include <stdio.h>

int main(void)
{
  printf("hello, world\n");
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?