Re: using grpc fails with linker error: file in wrong format

Juergen Landwehr

Hello Khem,

we use CMake as build system.

I checked the "sysdig" recipe and they defined both the "grpc" and "grpc-native" (same with protbuf) in the DEPENDS variable like so:

DEPENDS += "... grpc grpc-native protobuf protobuf-native ..."

If I do this in my recipe I get the following error:
18:55:09  -- Found Protobuf: /data/jenkins/workspace/e0_mbient_yocto_mbient_manifests_master_downstream/build/tmp/work/corei7-64-mbient-linux/tokenmaster-client/git-r0/recipe-sysroot/usr/lib/;-lpthread (found version "3.12.3") 
18:55:09  CMake Error at /data/jenkins/workspace/e0_mbient_yocto_mbient_manifests_master_downstream/build/tmp/work/corei7-64-mbient-linux/tokenmaster-client/git-r0/recipe-sysroot/usr/lib/cmake/grpc/gRPCTargets.cmake:197 (message):
18:55:09    The imported target "gRPC::grpc_cpp_plugin" references the file
18:55:09       "/data/jenkins/workspace/e0_mbient_yocto_mbient_manifests_master_downstream/build/tmp/work/corei7-64-mbient-linux/tokenmaster-client/git-r0/recipe-sysroot/usr/bin/grpc_cpp_plugin"
18:55:09    but this file does not exist.  Possible reasons include:
which is correct as the directory ".../recipe-sysroot/usr/bin" does not contain any grpc plugins. However the directory ".../recipe-sysroot-native/usr/bin" does (due to the dependency to grpc-native).

It seems to work for sysdig, as they do not use "find_package(Protobuf)" or "find_package("gRPC") to detect gRPC related libraries/programs but use some custom code.

So it looks like:

1) If I use "DEPENDS += "... grpc-native protobuf-native ..." I am able to generate grpc stubs and I am also able to successfully build my component, but only, if the build-host and target-host are compatible => NO CROSS COMPING
2) If I use "DEPENDS += "... grpc grpc-native protobuf protobuf-native ..." CMake immediately complains, that some the grpc plugins are missing
3) Using RDEPENDS seems to have no effect

So it seems the only way to make this work is to use "DEPENDS += grpc grpc-native ...." and write some custom CMake code to detect grpc related libraries (e.g. and programs (e.g. protoc, grpc_cpp_plugin).

But again, I am new to Yocto and still hope, that there is an easier way?

Join to automatically receive all group messages.