makefile出错 Entering directory `/home/xxx/libtest/lib'

初次用makefile
总体过程是在libtest文件在建立include src lib

libtest/include/hello.h下

#ifndef _HELLO_H_
#define _HELLO_H_
void hello();
#endif

libtest/lib/hello.c

#include "hello.h"
#include<stdio.h>
void hello()
{
    printf("hello world!\n");
}

libtest/src/main.c

#include "hello.h"
int main()
{
    hello();
}

lib文件下makefile生成libhello.a libhello.so都是成功的
但是在src下makefile有错误

lxq@ubuntu:~/libtest/src$ make
make -C ../lib
make[1]: Entering directory `/home/lxq/libtest/lib'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/lxq/libtest/lib'

src下makefile编写如下:

STATIC_FLAGS=-L ../lib -lhello -static -I ../include
DYNAMIC_FLAGS=-L ../lib -lhello -I ../include

STATIC_MAIN=main_static
DYNAMIC_MAIN=main_dync

.PHONY:submake clean
all:submake $(STATIC_MAIN) $(DYNAMIC_MAIN)

submake:
    $(MAKE) -C ../lib
$(STATIC_MAIN):main.c
    gcc $< $(STATIC_FLAGS) -o $@
$(DYNAMIC_MAIN):main.c
    gcc $< $(DYNAMIC_FLAGS) -o $@
clean:
    rm -rf *.o $(STATIC_MAIN) $(DYNAMIC_MAIN)

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐