2016-06-08 4 views
-3

Я работаю над yocto, я хочу скомпилировать некоторые c-файлы в yocto и установить их во внешнюю файловую систему. Перед этим я попытался создать отдельный reciepe и скомпилировать c-код из него. Я не могу скомпилировать его.Как скомпилировать базовый файл c в yocto

+1

Пожалуйста, напишите [Минимальный, полный и проверенный пример] (http: // stackov erflow.com/help/mcve). – MikeCAT

+1

ОК, спасибо за то, что поделились своей проблемой, у вас есть конкретный вопрос? –

ответ

8

Я не уверен, что понял вопрос, так как он недостаточно точен.

Включение файлов С в рецепте дерева

Если вы хотите, чтобы файлы 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, применяя патчи, генерируемые мерзавца, используя oe_runmake компилировать с Makefiles.

С devtool

Это было предложено в комментарии о том, как добавить рецепт с devtool. В качестве примера мы снова будем использовать wiringPi. Загрузить его https://github.com/WiringPi/WiringPi Makefile is the folder 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}' 
} 

Вы можете отредактировать свой рецепт, чтобы удовлетворить ваши конфигурация

+0

Если возможно, не могли бы вы показать, как это сделать с помощью 'devtool'? Спасибо. Мне все еще нужна дополнительная информация о том, как с этим работать. –

+1

@CharlesChau, я только что отредактировал свой ответ и добавил пример с devtool –

+0

Hi David Bensoussan, Спасибо за ваш ответ, я использовал рецепты, как указано выше. когда я выполняю битбак -b /PATH_TO_BB/example_0.1.bb, он генерирует исполняемый файл. когда я запускаю bitbake core-image-minimal, он не компилирует какой-либо файл, мне нужны какие-либо дополнительные изменения для этого – anikhan

Смежные вопросы