【问题标题】:how can I do manually , without the following make file?如果没有以下make文件,我该如何手动操作?
【发布时间】:2016-09-04 23:22:40
【问题描述】:

我有以下 make 文件,可以完美运行:

CFLAGS=-O2 -g -Wall 
RANLIB=ranlib

all: test libeasyperf.a

libeasyperf.a: easyperf.o
    $(AR) rc $@ $^
    $(RANLIB) $@

test: easyperf.o test.o
    $(CC) -o $@ $^ -lm

clean:
    rm -f *.o test libeasyperf.a

我们可以在没有ranlib 和存档 (ar) 的情况下重写 make 文件吗?实际上,我想通过手动编译每个文件(easyperf.ctest.c)来运行./test,而不需要 Makefile 执行所有这些操作。

有可能吗?

【问题讨论】:

  • Make 在执行之前输出将要运行的命令。您可以直接复制这些行。
  • 是的。你说的对! @ZanLynx

标签: c unix makefile


【解决方案1】:
gcc -O2 -g -Wall -c test.c -o test.o
gcc -O2 -g -Wall -c easyperf.c -o easyperf.o
gcc -O2 -g -o test easyperf.o test.o -lm
./test

【讨论】:

    【解决方案2】:
    gcc -O2 -g -Wall test.c easyperf.c -o test -lm
    ./test
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-15
      • 2012-03-05
      • 2019-01-15
      • 1970-01-01
      • 2022-01-24
      • 2023-01-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多