【问题标题】:Execution error of multiple C files in PetalinuxPetalinux中多个C文件执行错误
【发布时间】:2019-03-02 04:47:06
【问题描述】:

我是 Xilinx Petalinux SDK 2016.4 的新手。我在目标 Zybo-Z7 板上成功安装了 linux 操作系统。我还构建了一个 helloworld 应用程序,直到现在都很好。目前我想测试我的应用程序,它的名称为test.c,带有额外的一个标题和 C 文件(new.cnew.h)。 文件 test.c、new.c、new.h 位于路径中:

/$Petalinux-project-dir/project-spec/meta-user/recipes-apps/test/test

test.c 有代码:

#include <stdio.h>
#include "new.h"

int main(int argc, char **argv)
{
        printf("Hello World!\n");

        return 0;
} 

new.c 的代码如下:

#include "new.h"

void fun(void)
{
    printf("my function!\n");

}

new.h 有以下单行代码:

#include <stdio.h>

Makefile 有以下内容:

APP = test

# Add any other object files to this list below
APP_OBJS = test.o
APP_OBJS += new.o


all: build

build: $(APP)

$(APP): $(APP_OBJS)
    $(CC) $(LDFLAGS) -o $@ $(APP_OBJS) $(LDLIBS)

clean:
    $(RM) $(APP) $(OBJS)

最后,bitbake 文件 test.bb:

#
# This file is the test recipe.
#

SUMMARY = "Simple test application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://test.c \
           file://new.c \
           file://new.h \
           file://Makefile \
          "

S = "${WORKDIR}"

do_compile() {
         oe_runmake
}

do_install() {
         install -d ${D}${bindir}
         install -m 0755 test ${D}${bindir}
         install -m 0755 new ${D}${bindir}
}

然后我尝试通过键入命令来构建应用程序:

petalinux-build -c test -x build 

但我在 log.do_configure 中收到以下错误消息:

DEBUG: Executing python function sysroot_cleansstate
DEBUG: Python function sysroot_cleansstate finished
DEBUG: Executing shell function do_configure
NOTE: make clean
make: *** No rule to make target 'clean'.  Stop.

petalinux-build -c test -x build 
ERROR: oe_runmake failed


ERROR: Function failed: do_configure (log file is located at /$petalinux-project-directory/build/tmp/work/cortexa9hf-neon-xilinx-linux-gnueabi/test/1.0-r0/temp/log.do_configure.7230)

我在控制台中有以下内容:

    petalinux-build -c test -x build
    [INFO] building test
    [INFO] sourcing bitbake
    INFO: bitbake test -c build
    Loading cache: 100% |###########################################| ETA:  00:00:00
    Loaded 2942 entries from dependency cache.
    Parsing recipes: 100% |#########################################| Time: 00:00:02
    Parsing of 2326 .bb files complete (2292 cached, 34 parsed). 2941 targets, 196 skipped, 0 masked, 0 errors.
    NOTE: Resolving any missing task queue dependencies
    NOTE: Preparing RunQueue
    NOTE: Checking sstate mirror object availability (for 38 objects)
    NOTE: Executing SetScene Tasks
    NOTE: Executing RunQueue Tasks
    ERROR: test-1.0-r0 do_configure: oe_runmake failed
    ERROR: test-1.0-r0 do_configure: Function failed: do_configure (log file is located at /$Petalinux-project-dir/build/tmp/work/cortexa9hf-neon-xilinx-linux-gnueabi/test/1.0-r0/temp/log.do_configure.7230)
    ERROR: Logfile of failure stored in: /$Petalinux-project-dir/build/tmp/work/cortexa9hf-neon-xilinx-linux-gnueabi/test/1.0-r0/temp/log.do_configure.7230
    Log data follows:
    | DEBUG: Executing python function sysroot_cleansstate
    | DEBUG: Python function sysroot_cleansstate finished
    | DEBUG: Executing shell function do_configure
    | NOTE: make clean
    | make: *** No rule to make target 'clean'.  Stop.
    | ERROR: oe_runmake failed
    | ERROR: Function failed: do_configure (log file is located at /$Petalinux-project-dir/build/tmp/work/cortexa9hf-neon-xilinx-linux-gnueabi/test/1.0-r0/temp/log.do_configure.7230)
    ERROR: Task 5 (/$Petalinux-project-dir/project-spec/meta-user/recipes-apps/test/test.bb, do_configure) failed with exit code '1'
    NOTE: Tasks Summary: Attempted 610 tasks of which 605 didn't need to be rerun and 1 failed.
    Waiting for 0 running tasks to finish:

    Summary: 1 task failed:
      /$Petalinux-project-dir/project-spec/meta-user/recipes-apps/test/test.bb, do_configure
    Summary: There were 2 ERROR messages shown, returning a non-zero exit code.
    ERROR: Failed to build test

我试过了: https://forums.xilinx.com/t5/Embedded-Linux/How-to-build-when-multiple-source-files-in-rootfs-of-petalinux/td-p/780949https://www.xilinx.com/support/answers/67189.html 还有这个类似的问题 How to build when multiple source files in rootfs in embedded linux? 但它不起作用!

你能帮帮我吗?

【问题讨论】:

  • 我再次尝试更改makefile,如下所示:APP = test .....但应用程序test.c也没有提供任何目标。 new.c is not seen on the target # 将任何其他目标文件添加到此列表下方 APP_OBJS = test.o APP_OBJS += new.o .PHONY: all build clean all: build build: $(APP) $(APP): $(APP_OBJS) $(CC) $(LDFLAGS) -o $@ $(APP_OBJS) $(LDLIBS) 清洁:$(RM) $(APP) $(OBJS)

标签: makefile embedded-linux bitbake petalinux


【解决方案1】:

您的 makefile 中没有 clean 目标。试试:

APP := test

APP_OBJS := test.o new.o

.PHONY: all build clean

all: build

build: $(APP)

$(APP): $(APP_OBJS)
    $(CC) $(LDFLAGS) -o $@ $(APP_OBJS) $(LDLIBS)

clean:
    $(RM) $(APP) $(OBJS)

【讨论】:

  • 感谢您的回答。我现在会尝试你的答案并给你我的反馈
  • @A.欢迎来到 Stackoverflow!这里一次一个问题。如果您(最初)发布的问题的解决方案揭示了一个新问题,而您自己无法解决,您应该发布一个新问题。您应该通过提供有用的答案将您的问题更改为另一个问题,使它们变得无关紧要。见What should I do when someone answers my question?
  • @A.S 如果你愿意,你可以rollback to revision 1
  • 抱歉更改原帖。现在原帖又回来了。好吧,我尝试了您的建议。好消息是错误消失了。但是当我在目标 Zybo 板上加载 linux 操作系统时,当我尝试实现它时,应用程序 test.c 什么也没提供。此外,应用程序 new.c 也未加载到 linux 映像中。我还删除了第三行表单 do_install "install -m 0755 new ${D}${bindir}" 因为应用程序 new.c 加载到应用程序 test.c 的同一路径中
  • @A.S 感谢您回复帖子 :) 为了有机会获得有关新问题的帮助,您应该发布另一个问题,仔细提供读者可以用来调查它的信息。
猜你喜欢
  • 2016-07-13
  • 1970-01-01
  • 1970-01-01
  • 2021-06-15
  • 2019-10-31
  • 1970-01-01
  • 1970-01-01
  • 2015-07-21
  • 1970-01-01
相关资源
最近更新 更多