我正在研究yocto,我想在yocto中編譯一些c文件並將它們安裝到外部文件系統。 在此之前,我試着創建一個單獨的reciepe並從它編譯c代碼。 我無法編譯它。如何在yocto中編譯基本c文件
回答
我不確定要理解這個問題,因爲它不夠精確。
包括配方樹C文件
如果你想在你的食譜的C文件,其文件樹這樣的:
recipe-example/example/example_0.1.bb
recipe-example/example/example-0.1/helloworld.c
當你創建一個新的可以產生這個例子層使用
yocto-layer <your-layer-name>
你的BB文件將是這樣的:
#
# This file was derived from the 'Hello World!' example recipe in the
# Yocto Project Development Manual.
#
SUMMARY = "Simple helloworld application"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://helloworld.c"
S = "${WORKDIR}"
do_compile() {
${CC} helloworld.c -o helloworld
}
do_install() {
install -d ${D}${bindir}
install -m 0755 helloworld ${D}${bindir}
}
它將編譯hello world文件並將其安裝到映像的/ usr/bin中。
從一個Git回購
您也可以從一個Git倉庫編譯,我建議你閱讀在你的文件夾yocto手冊和示例。下面是這裏wiringPi的示例:
DESCRIPTION = "A library to control Raspberry Pi GPIO channels"
HOMEPAGE = "https://projects.drogon.net/raspberry-pi/wiringpi/"
SECTION = "devel/libs"
LICENSE = "LGPLv3+"
LIC_FILES_CHKSUM = "file://COPYING.LESSER;md5=e6a600fd5e1d9cbde2d983680233ad02"
# tag 2.29
SRCREV = "d79506694d7ba1c3da865d095238289d6175057d"
S = "${WORKDIR}/git"
SRC_URI = "git://git.drogon.net/wiringPi \
file://0001-Add-initial-cross-compile-support.patch \
file://0001-include-asm-ioctl.h-directly-for-_IOC_SIZEBITS.patch \
"
COMPATIBLE_MACHINE = "raspberrypi"
CFLAGS_prepend = "-I${S}/wiringPi -I${S}/devLib"
EXTRA_OEMAKE += "'INCLUDE_DIR=${D}${includedir}' 'LIB_DIR=${D}${libdir}'"
EXTRA_OEMAKE += "'DESTDIR=${D}/usr' 'PREFIX=""'"
do_compile() {
oe_runmake -C devLib
oe_runmake -C wiringPi
oe_runmake -C gpio 'LDFLAGS=${LDFLAGS} -L${S}/wiringPi -L${S}/devLib'
}
do_install() {
oe_runmake -C devLib install
oe_runmake -C wiringPi install
oe_runmake -C gpio install
}
它是從一個git倉庫取出,施加由GIT中產生的貼劑,使用oe_runmake與生成文件進行編譯。
隨着devtool
有人問如何添加配方與devtool評論。 我們仍然會使用wiringPi作爲例子。下載它做 https://github.com/WiringPi/WiringPi Makefile是文件夾wiringPi。 然後,您可以做
devtool add <name_of_recipe> <path_to_Makefile_folder>
小心的警告從devtool
NOTE: Creating workspace layer in /home/dbensoussan/new_poky/poky/build/workspace
NOTE: Enabling workspace layer in bblayers.conf
NOTE: Using source tree as build directory since that would be the default for this recipe
NOTE: Recipe /home/dbensoussan/new_poky/poky/build/workspace/recipes/project/project.bb has been automatically created; further editing may be required to make it fully functional
這是生成的配方如下:
# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)
#
# WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is
# your responsibility to verify that the values are complete and correct.
LICENSE = "Unknown"
LIC_FILES_CHKSUM = "file://COPYING.LESSER;md5=e6a600fd5e1d9cbde2d983680233ad02"
# No information for SRC_URI yet (only an external source tree was specified)
SRC_URI = ""
# NOTE: this is a Makefile-only piece of software, so we cannot generate much of the
# recipe automatically - you will need to examine the Makefile yourself and ensure
# that the appropriate arguments are passed in.
do_configure() {
# Specify any needed configure commands here
:
}
do_compile() {
# You will almost certainly need to add additional arguments here
oe_runmake
}
do_install() {
# This is a guess; additional arguments may be required
oe_runmake install 'DESTDIR=${D}'
}
然後,您可以編輯你的食譜,以滿足您配置
如果可能,你可以通過'devtool'演示怎麼做?謝謝。我仍然需要一些關於如何使用它的信息。 –
@CharlesChau,我剛剛編輯了我的答案,並添加了一個devtool –
的例子嗨大衛Bensoussan,感謝您的回答,我使用上面提到的食譜示例。當我執行bitbake -b /PATH_TO_BB/example_0.1.bb它正在生成一個可執行文件。當我運行bitbake core-image-minimal時,它不會編譯任何文件,我是否需要對此進行任何額外的更改 – anikhan
- 1. 在yocto中編譯C++程序
- 2. 如何在C#中編譯* .compiled文件?
- 3. 如何強制包重新編譯Yocto
- 4. 編譯基本的C++類
- 5. 在C++中獲取基本的文本處理器來編譯
- 6. 使用插件編譯rygel for yocto
- 7. 如何在C++中編譯編譯器?
- 8. 如何在c編程中編譯和鏈接文件?
- 9. 如何重新編譯nginx基本文件名?
- 10. 如何通過android ndk在C/C++文件中檢測編譯?
- 11. C++編譯文件
- 12. 編譯C文件
- 13. 如何在基於Debian的linux中編譯和運行C/C++?
- 14. 在Visual Studio 2010中編譯`C`文件時,它是否編譯爲C++文件?
- 15. 如何將C++文件編譯爲WebAssembly?
- 16. 如何使用C++編譯.java文件
- 17. 如何在C#winforms中翻譯文本
- 18. 如何基於文本文件創建或修改基於文本文件的QT表單(編譯後)
- 19. 如何在linux中編譯幾個java類和文本文件
- 20. 如何在預編譯中編譯自動生成的C文件?
- 21. 在OS X中編譯C文件
- 22. 在Objective-C文件中編譯錯誤
- 23. Xcode:在ARC中編譯.c文件?
- 24. 用C++編譯器編譯C99文件
- 25. 用文本編譯C++
- 26. 基於文件存在的NSIS腳本條件編譯
- 27. 如何在Java中編譯.java文件?
- 28. 如何在makefile中編譯.h文件?
- 29. 如何在「期望」中編譯文件?
- 30. 如何通過一個ant編譯腳本編譯.drl文件
請發佈[最小,完整和可驗證示例](http:// stackov erflow.com/help/mcve)。 – MikeCAT
好的,感謝您分享您的問題,您是否也有具體問題? –