Yocto: CMake Error (find_package) when trying to bitbake a Recipe, but when running it in Cmake alone it works

huangapple go评论78阅读模式
英文:

Yocto: CMake Error (find_package) when trying to bitbake a Recipe, but when running it in Cmake alone it works

问题

我正在尝试在树莓派上使用pigpio库运行一个简单的程序,使用yocto项目

我已经尝试使用cmake进行构建,当我在终端上运行它时,它可以正常工作。但是当我尝试使用bitbake构建我的配方时,我遇到了以下cmake错误,我似乎找不到问题所在,以及为什么只有在bitbake中而不是在控制台中运行cmake时才出现此错误。

| CMake Error at /home/ibschwarzfischer/yocto/poky/build-rpi3/tmp/work/cortexa53-poky-linux/blinker/1.0-r0/recipe-sysroot-native/usr/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
|   Could NOT find pigpio (missing: pigpio_INCLUDE_DIR pigpio_LIBRARY
|   pigpiod_if_LIBRARY pigpiod_if2_LIBRARY)
| Call Stack (most recent call first):
|   /home/ibschwarzfischer/yocto/poky/build-rpi3/tmp/work/cortexa53-poky-linux/blinker/1.0-r0/recipe-sysroot-native/usr/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
|   /home/ibschwarzfischer/yocto/packages/pigpio-master/util/Findpigpio.cmake:29 (find_package_handle_standard_args)
|   CMakeLists.txt:12 (find_package)

我的CMakeLists.txt如下:

cmake_minimum_required(VERSION 3.5)
project(blinker)

set(CMAKE_BUILD_TYPE RelWithDebInfo)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../packages/pigpio-master/util)

set(pigpio_DIR ${PROJECT_SOURCE_DIR}/../../packages/pigpio-master/cmake)

find_package(pigpio REQUIRED)

add_executable(blinker main.c)

target_link_libraries(blinker PRIVATE pigpio)

pigpio库中还包含一个Findpigpio.cmake:

# Find the path to the pigpio includes.
find_path(pigpio_INCLUDE_DIR 
    NAMES pigpio.h pigpiod_if.h pigpiod_if2.h
    HINTS /usr/local/include)
    
# Find the pigpio libraries.
find_library(pigpio_LIBRARY 
    NAMES libpigpio.so
    HINTS /usr/local/lib)
find_library(pigpiod_if_LIBRARY 
    NAMES libpigpiod_if.so
    HINTS /usr/local/lib)
find_library(pigpiod_if2_LIBRARY 
    NAMES libpigpiod_if2.so
    HINTS /usr/local/lib)
    
# Set the pigpio variables to plural form to make them accessible for 
# the paramount cmake modules.
set(pigpio_INCLUDE_DIRS ${pigpio_INCLUDE_DIR})
set(pigpio_INCLUDES     ${pigpio_INCLUDE_DIR})

# Handle REQUIRED, QUIET, and version arguments 
# and set the <packagename>_FOUND variable.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(pigpio 
    DEFAULT_MSG 
    pigpio_INCLUDE_DIR pigpio_LIBRARY pigpiod_if_LIBRARY pigpiod_if2_LIBRARY)

所以,如果有人知道可能有帮助的信息,我会非常感激!提前谢谢!

英文:

i am trying to run a simple program using the pigpio library on my raspberry pi, with the yocto project.

I have already tried out the build with cmake and when i run it in the terminal on my pc it works. But when i try to bitbake my recipe, i get following cmake error and i cant seem to find out whats the problem and why i only get this error in bitbake and not when running cmake in the console.

| CMake Error at /home/ibschwarzfischer/yocto/poky/build-rpi3/tmp/work/cortexa53-poky-linux/blinker/1.0-r0/recipe-sysroot-native/usr/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
|   Could NOT find pigpio (missing: pigpio_INCLUDE_DIR pigpio_LIBRARY
|   pigpiod_if_LIBRARY pigpiod_if2_LIBRARY)
| Call Stack (most recent call first):
|   /home/ibschwarzfischer/yocto/poky/build-rpi3/tmp/work/cortexa53-poky-linux/blinker/1.0-r0/recipe-sysroot-native/usr/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
|   /home/ibschwarzfischer/yocto/packages/pigpio-master/util/Findpigpio.cmake:29 (find_package_handle_standard_args)
|   CMakeLists.txt:12 (find_package)

My CMakeLists.txt looks like this:

> cmake_minimum_required(VERSION 3.5)
> project(blinker)
>
> set(CMAKE_BUILD_TYPE RelWithDebInfo)
>
> set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../packages/pigpio-master/util)
>
> set(pigpio_DIR ${PROJECT_SOURCE_DIR}/../../packages/pigpio-master/cmake)
>
> #target_include_directories(blinker PUBLIC include/pigpio)
>
> find_package(pigpio REQUIRED)
>
> add_executable(blinker main.c)
>
> target_link_libraries(blinker PRIVATE pigpio)

and there is also a Findpigpio.cmake included in the pigpio library:

################################################################################
### Find the pigpio shared libraries.
################################################################################

# Find the path to the pigpio includes.
find_path(pigpio_INCLUDE_DIR 
	NAMES pigpio.h pigpiod_if.h pigpiod_if2.h
	HINTS /usr/local/include)
	
# Find the pigpio libraries.
find_library(pigpio_LIBRARY 
	NAMES libpigpio.so
	HINTS /usr/local/lib)
find_library(pigpiod_if_LIBRARY 
	NAMES libpigpiod_if.so
	HINTS /usr/local/lib)
find_library(pigpiod_if2_LIBRARY 
	NAMES libpigpiod_if2.so
	HINTS /usr/local/lib)
    
# Set the pigpio variables to plural form to make them accessible for 
# the paramount cmake modules.
set(pigpio_INCLUDE_DIRS ${pigpio_INCLUDE_DIR})
set(pigpio_INCLUDES     ${pigpio_INCLUDE_DIR})

# Handle REQUIRED, QUIET, and version arguments 
# and set the <packagename>_FOUND variable.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(pigpio 
    DEFAULT_MSG 
    pigpio_INCLUDE_DIR pigpio_LIBRARY pigpiod_if_LIBRARY pigpiod_if2_LIBRARY)

so if anyone knows something that might help i am very happy about it!
Thanks in advance!

i tried to compile it with cmake in the terminal using cmake -S . -B out/build and then cmake --build out/build and when i ran the program in the terminal it worked and cmake didnt give me an error so i know the package is linked to the target and cmake also finds the Findpigpio.cmake.

答案1

得分: 0

似乎CMake找不到您创建的blinker软件包所需的pigpio软件包。可能是因为它在您的计算机上已安装,所以在您的计算机上手动工作,因为它能够找到它。

为了检查您的系统根文件夹(sysroot)上是否已安装了该软件包,您可以运行以下命令:

bitbake -e blinker | grep "^OE_BUILD_SYSROOT="

在该路径中,您可以查看是否有CMake构建您的软件包所需的必要库、pkg-config文件等。

如果pigpio软件包不在那里,您可能需要在您的配方中将其添加为构建依赖项:

DEPENDS += "pigpio"

但为此,您需要有一个提供该软件包的pigpio配方。通过搜索,我找到了这个链接,但我不知道它是否适用,也无法提供更多上下文:https://gist.github.com/dir-ableton/7ad9045e242165a9e4707c84e6df754b

希望这有所帮助。

英文:

It seems like cmake is not being able to find the pigpio package for the blinker package you have created. And probably is working on your PC because you have it somehow installed on it, so manually it works as it finds it.

In order to check if you have that package installed on the recipe sysroot, you can run

> bitbake -e blinker | grep "^OE_BUILD_SYSROOT="

In that path, you can see if there are the required libraries, pkg-config files, etc. that you need for cmake to build your package properly.

If the pigpio package is not there, probably you need to add it as a build dependency inside your recipe with

> DEPENDS += "pigpio"

But for this, you need to have a pigpio recipe that actually provides the package. Doing a search, I found this one, but I don't know if it can work and I can't help you with more context: https://gist.github.com/dir-ableton/7ad9045e242165a9e4707c84e6df754b

Hope this helps a little

huangapple
  • 本文由 发表于 2023年2月14日 21:53:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/75448829.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定