如何将自己的软件添加到Buildroot Linux软件包中? [英] How to add my own software to a Buildroot Linux package?

查看:2047
本文介绍了如何将自己的软件添加到Buildroot Linux软件包中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将自己的程序添加到使用Buildroot创建的小型Linux中. 到目前为止,我已经完成了什么:

I am trying to add my own program to a small linux, created with Buildroot. What I've done so far:

  • 我已经在我的"buildroot/package/"内部创建了一个名为"HelloWorld"的新目录. 在"buildroot/package/HelloWorld"中,我有:Config.in,HelloWorld.mk和HelloWorld目录. Config.in 包含以下内容:

  • I've created a new directory inside my 'buildroot/package/' called 'HelloWorld'. Inside 'buildroot/package/HelloWorld' I have : a Config.in, HelloWorld.mk and HelloWorld directory. Config.in holds this:

    config BR2_PACKAGE_HELLOWORLD
    bool "helloworld"
    default y
    help
            Hello world component.

HelloWorld.mk包含以下内容:

HelloWorld.mk holds this:

HELLOWORLD_VERSION:= 1.0.0
HELLOWORLD_SITE:= /home/userpc/Downloads/helloworld/
HELLOWORLD_SITE_METHOD:=local
HELLOWORLD_INSTALL_TARGET:=YES

define HELLOWORLD_BUILD_CMDS
        $(MAKE) CC="$(TARGET_CC)" LD="$(TARGET_LD)" -C $(@D) all
endef

define HELLOWORLD_INSTALL_TARGET_CMDS
        $(INSTALL) -D -m 0755 $(@D)/helloworld $(TARGET_DIR)/bin
endef

define HELLOWORLD_PERMISSIONS
       /bin/helloworld f 4755 0 0 - - - - - 
endef

$(eval $(generic-package))

(灵感) HelloWorld目录包含:main.c&生成文件:

(inspiration source) The HelloWorld directory contains: main.c & Makefile:

main.c:

#include <stdio.h>

int main()
{
        printf("\nMain entry.\n");
        return 0;
}

Makefile:

CC=gcc
CFLAGS=-I.

all: *.c
        $(CC) -Os -Wall  *.c -o helloworld
#       $(STRIP) helloworld

clean:
        rm -f a.out helloworld
        rm -f *.o

编辑:而且我还将源"package/HelloWorld/Config.in" 添加到了"package/Config.in" 但是,当我挂载rootfs.ext2分区时,在/usr/bin ..中找不到我的HelloWorld可执行文件.我错过了,因为我确定我做错了什么.

Edit: And I have also added source "package/HelloWorld/Config.in" to 'package/Config.in' But when I mount my rootfs.ext2 partition I can't find my HelloWorld executable inside /usr/bin .., I am really new to this and don't have any prior knowledge, so could you please explain to me, what am I missing from this, because I'm sure I'm doing something wrong.

更新:该程序在所需的位置构建并安装,但是当我尝试像这样运行它时:./helloworld,我得到:bash:./helloworld:没有这样的文件或目录,它具有执行权..这是怎么回事? (我将rootfs.ext2安装到ubuntu目录中后尝试运行它,buildroot的目标目录是i368,所以应该可以,对吧?)

UPDATE: The program builds and install at the desired location but when I try to run it like so: ./helloworld, I get: bash: ./helloworld: No such file or directory, it has execution rights.. what is the matter with it? (I try to run it after I mount the rootfs.ext2 into a ubuntu directory, the target arch for buildroot is i368, so it should be ok, right?)

在构建和安装HelloWorld程序并最终运行它之后,我想添加到init.d中,以便它在启动后启动,并用不需要X服务器的Qt Window替换HelloWorld,例如此处.

After building and installing the HelloWorld program, and eventually running it, I'd like to add to init.d so it starts after booting, and replace the HelloWorld with a Qt Window that doesn't need a X server, like this thing here.

此处..

推荐答案

通常,buildroot软件包的资源来自(下载的)tarball.您现在正在做的事情(将源放置在package/HelloWorld中)不是正确的方法.

In general, the sources for buildroot packages are taken from a (downloaded) tarball. What you are doing right now (placing the sources inside package/HelloWorld) is not the right way to proceed.

Buildroot确实提供了本地"软件包源的规定,如果您确实需要的话,可以使用它们.为此,您将需要HELLOWORLD_SITE_METHOD变量.

Buildroot does have provisions for 'local' package sources, which you could use if you really need to. You'll need the HELLOWORLD_SITE_METHOD variable for that.

请参考 http://buildroot.uclibc.org/downloads /manual/manual.html#adding-packages 了解更多信息.

此外,您无需定义HELLOWORLD_DIR,HELLOWORLD_BINARY,HELLOWORLD_TARGET_BINARY.

Also, you don't need to define HELLOWORLD_DIR, HELLOWORLD_BINARY, HELLOWORLD_TARGET_BINARY.

更新:关于您的其他问题:

更新:该程序在所需位置生成并安装,但是当我尝试运行它时 像这样:./helloworld,我得到:bash:./helloworld:没有这样的文件或目录,它有 执行权..这是怎么回事? (我在安装 将rootfs.ext2放入ubuntu目录,buildroot的目标目录是i368,因此它应该 没事吧?)

UPDATE: The program builds and install at the desired location but when I try to run it like so: ./helloworld, I get: bash: ./helloworld: No such file or directory, it has execution rights.. what is the matter with it? (I try to run it after I mount the rootfs.ext2 into a ubuntu directory, the target arch for buildroot is i368, so it should be ok, right?)

不,它不能那样工作.您不能只挂载rootfs.ext2并期望从中运行程序.这尤其是因为rootfs.ext2内的程序也是针对rootfs.ext2内的库编译的,但是如果这样运行,它将使用/usr/lib中的库.您必须使用rootfs.ext2完全启动系统,使用qemu或使用chroot环境.对于chroot,您应该使用"tar"文件系统格式,而不是ext2.另请参阅此处: http://buildroot.uclibc.org/downloads/manual/manual.html#_chroot

No, it does not work like that. You can't just mount rootfs.ext2 and expect to run programs from it. This is, among others, because the programs inside rootfs.ext2 are compiled against the libraries also inside rootfs.ext2, but if you run it like that it will use the libraries in /usr/lib. You either have to boot your system entirely with the rootfs.ext2, use qemu, or use a chroot environment. For chroot, you should use the 'tar' filesystem format, not ext2. See also here: http://buildroot.uclibc.org/downloads/manual/manual.html#_chroot

这篇关于如何将自己的软件添加到Buildroot Linux软件包中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆