I have some problems to build my own package "grpcSandbox", which depends on gRPC and protobuf. There already exists recipes for gRPC and protobuf which builds well.
The problem is: cmake project of grpcSandbox requires the directory of gRPC header/libs and protobuf header/libs + protobuf-compiler (protoc).
I do not really understand how to link from my grpcSandbox package to the shared libs from gRPC and how to execute the meta-compiler "protoc" which is provided by protobuf.
All I have done is to add dependencies to the two packages in my recipe.
# 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 = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=79bfc140d04e521d1032e65eef60cfa8"
SRC_URI = "***"
# Modify these as desired
PV = "1.1+git${SRCPV}"
SRCREV = "***"
S = "${WORKDIR}/git"
# This depends on gRPC and protobuf (gRPC depends on protobuf)
RDEPENDS_${PN} += " grpc protobuf nativesdk-protobuf"
#protobuf-native makes the protoc (protobuf compiler) at build time accessible (host version)
#Need to check if this works, since it will convert proto-files to cpp/hpp files
DEPENDS_${PN} += " protobuf protobuf-native grpc"
# NOTE: unable to map the following CMake package dependencies: Protobuf GRPC
inherit cmake
# Specify any options you want to pass to cmake using EXTRA_OECMAKE:
# Pass the path of sysroot to the cmake compiler script. Required to find headers of protobuf/protoc
EXTRA_OECMAKE = "-DOE_SYSROOT:STRING=${STAGING_DIR_HOST}"
When I start a devshell with "bitbake -c devshell grpcsandbox", the command "protoc" is not available and I cannot find the gRPC libs/headers in the sysroot of package grpcsandbox (which I thought they should be there, since I listed them as dependency for grpcSandbox).
What am I doing wrong?
I've not used protobuf in Yocto so can't tell you exactly how it's designed to be used but I can point out some issues in the recipe:
# This depends on gRPC and protobuf (gRPC depends on protobuf)
RDEPENDS_${PN} += " grpc protobuf nativesdk-protobuf"
RDEPENDS is about runtime dependencies. It's unlikely that you would want to depend on a nativesdk- package here and I'm doubtful about protobuf itself too -- is protobuf needed at runtime on the target?
#protobuf-native makes the protoc (protobuf compiler) at build time accessible (host version)
#Need to check if this works, since it will convert proto-files to cpp/hpp files
DEPENDS_${PN} += " protobuf protobuf-native grpc"
DEPENDS is about build time dependencies and is not package-specific: you should just say DEPENDS = ...
. Fixing this should put the protoc binary into the native sysroot so it's available during build.