【发布时间】:2021-06-15 22:46:43
【问题描述】:
我对 Petalinux 2020.2 版本还很陌生,我正在尝试使用 C 模板在我的项目中创建一个简单的应用程序。
使用命令创建 helloworld-app 后:
petalinux-create -t apps --template c --name helloworld-app
启用默认应用程序并成功构建后,我尝试通过在 helloworld-app/files 下创建一个名为 Ethernet 的新目录来添加一些功能,其中包含 2 个文件Etherent.c 和 Ethernet.h
最后,我将 Ethernet.o 对象添加到自动生成的模块 Makefile 内的列表中,为了简单起见,我还添加了一个 VPATH。
不幸的是,构建失败了,实际上 bitbake 告诉我没有为对象 Ethernet.o 指定规则。
- 如何修改 makefile 以编译这个简单的代码?
- 我可以编辑 .bb 文件吗?我不想这样做,因为这样我就必须指定每个 src 文件...
感谢您的支持! 以太网.c:
#include "Ethernet.h"
//some C code
helloworld-app.c:
#include <stdio.h>
#include "Ethernet/Ethernet.h"
//some C code
生成文件:
APP = helloworld-app
VPATH=Ethernet
# Add any other object files to this list below
APP_OBJS = helloworld-app.o Ethernet.o
all: build
build: $(APP)
$(APP): $(APP_OBJS)
$(CC) -o $@ $(APP_OBJS) $(LDFLAGS) $(LDLIBS)
clean:
rm -f $(APP) *.o
【问题讨论】:
-
我猜
Ethernet.c源(和头)文件应该在其他目录中? -
您是否尝试将对象设置为
Ethernet/Ethernet.o? -
我也尝试过使用Ethernet/Ethernet.o,结果是一样的。
-
Ethernet目录是否在本示例项目的目录下? -
Ethernet/ 与 helloworld-app.c 处于同一级别