All of lore.kernel.org
 help / color / mirror / Atom feed
* Application depending on gRPC not linking properly
@ 2020-09-09 12:56 broeckaert.goran
  2020-09-10  0:15 ` [OE-core] " Khem Raj
  2020-09-11 14:17 ` [OE-core] " Stefan Herbrechtsmeier
  0 siblings, 2 replies; 4+ messages in thread
From: broeckaert.goran @ 2020-09-09 12:56 UTC (permalink / raw)
  To: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 1229 bytes --]

Hello,

I have a simple application which depends on grpc. I'm using Yocto Zeus for
my project and I've written the following recipe:

DESCRIPTION = "Test Application"
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""

SRC_URI = "\
git://git/dev/test-application.git;protocol=ssh;branch=yocto;name=testapp \
"

inherit cmake qmake5_paths

DEPENDS = "\
qtbase \
qtbase-native \
grpc \
grpc-native \
"

PV = "1.0+git${SRVPV}"

SRCREV_testapp = "c1dd51dd6c812a99f6af3e5b1c367a3155e5e96f"

S = "${WORKDIR}/git"

EXTRA_OECMAKE = "\
-DCMAKE_PREFIX_PATH=${WORKDIR}/recipe-sysroot/usr/ \
-DOE_QMAKE_PATH_EXTERNAL_HOST_BINS=${OE_QMAKE_PATH_EXTERNAL_HOST_BINS} \
-DCMAKE_CROSSCOMPILING=ON \
"

The linker tries to link with the -native version of gRPC instead of the
target one. Can be seen in the following line from the output:

recipe-sysroot-native/usr/lib/libgrpc++.so.1.24.1: error adding symbols:
file in wrong format

When checking the recipe-sysroot, the grpc libraries are properly
installed. There has been an issue opened on the grpc github, but it got
closed without specifying a solution:
https://github.com/grpc/grpc/issues/17708

Thanks for the help,

Kind regards,
Goran Broeckaert

[-- Attachment #2: Type: text/html, Size: 1842 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [OE-core] Application depending on gRPC not linking properly
  2020-09-09 12:56 Application depending on gRPC not linking properly broeckaert.goran
@ 2020-09-10  0:15 ` Khem Raj
  2020-09-11  8:10   ` Goran Broeckaert
  2020-09-11 14:17 ` [OE-core] " Stefan Herbrechtsmeier
  1 sibling, 1 reply; 4+ messages in thread
From: Khem Raj @ 2020-09-10  0:15 UTC (permalink / raw)
  To: Goran Broeckaert, openembedded-core



On 9/9/20 5:56 AM, Goran Broeckaert wrote:
> Hello,
> 
> I have a simple application which depends on grpc. I'm using Yocto Zeus
> for my project and I've written the following recipe:
> 
> DESCRIPTION = "Test Application"
> LICENSE = "CLOSED"
> LIC_FILES_CHKSUM = ""
> 
> SRC_URI = "\
> git://git/dev/test-application.git;protocol=ssh;branch=yocto;name=testapp \
> "
> 
> inherit cmake qmake5_paths
> 
> DEPENDS = "\
> qtbase \
> qtbase-native \
> grpc \
> grpc-native \
> "
> 
> PV = "1.0+git${SRVPV}"
> 
> SRCREV_testapp = "c1dd51dd6c812a99f6af3e5b1c367a3155e5e96f"
> 
> S = "${WORKDIR}/git"
> 
> EXTRA_OECMAKE = "\
> -DCMAKE_PREFIX_PATH=${WORKDIR}/recipe-sysroot/usr/ \
> -DOE_QMAKE_PATH_EXTERNAL_HOST_BINS=${OE_QMAKE_PATH_EXTERNAL_HOST_BINS} \
> -DCMAKE_CROSSCOMPILING=ON \
> "
> 
> The linker tries to link with the -native version of gRPC instead of the
> target one. Can be seen in the following line from the output:
> 
> recipe-sysroot-native/usr/lib/libgrpc++.so.1.24.1: error adding symbols:
> file in wrong format
> 
> When checking the recipe-sysroot, the grpc libraries are properly
> installed. There has been an issue opened on the grpc github, but it got
> closed without specifying a
> solution: https://github.com/grpc/grpc/issues/17708


Can you take a look at
https://github.com/grpc/grpc/blob/master/test/distrib/cpp/run_distrib_test_raspberry_pi.sh
and see if some of those options are useful either compiling gRPC or
your app ?

also check this patch
https://git.openembedded.org/meta-openembedded/commit/?id=38f6ef9b1432cbafd416ec162b0a30366311095b

especially how it looks for libcares, might give some ideas how to solve
this issue perhaps.

> 
> Thanks for the help,
> 
> Kind regards,
> Goran Broeckaert
> 
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Application depending on gRPC not linking properly
  2020-09-10  0:15 ` [OE-core] " Khem Raj
@ 2020-09-11  8:10   ` Goran Broeckaert
  0 siblings, 0 replies; 4+ messages in thread
From: Goran Broeckaert @ 2020-09-11  8:10 UTC (permalink / raw)
  To: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 1353 bytes --]

I have been able to fix it by searching for the right grpc libraries in the recipe-sysroot:

find_library(GRPC_LIBRARY grpc++
HINTS
${CMAKE_SOURCE_DIR}/recipe- sysroot)

if (GRPC_LIBRARY-NOTFOUND)
message(FATAL_ERROR "Could not find grpc++")
endif ()

find_path(GRPC_INCLUDE_DIR grpc++/grpc++.h
HINTS
${CMAKE_SOURCE_DIR}/recipe- sysroot)

add_library(gRPC::grpc++ UNKNOWN IMPORTED)
set_target_properties(gRPC:: grpc++
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${GRPC_INCLUDE_DIR}")
set_target_properties(gRPC:: grpc++
PROPERTIES IMPORTED_LOCATION
"${GRPC_LIBRARY}")
set(GRPC_LIBRARIES gRPC::grpc++)

and then at the end add to link the found grpc library to your application:

target_link_libraries(${ PROJECT_NAME}
PRIVATE protobuf::libprotobuf
PRIVATE ${GRPC_LIBRARIES}
)

I haven't changed anything to my recipe, just that I added an environment setting which gets set as "YOCTO" to only execute this when it's being ran by Yocto. Can do less hard coding (setting the hint as ${CMAKE_SOURCE_DIR}/recipe- sysroot) by looking in CMAKE_SYSROOT.

This doesn't seem like an easy patch to add to gRPC. And since the issue, which I linked in my first post, got already closed without providing a real solution; it seems like the people at gRPC aren't really sure what is happening either.

Kind regards,
Goran Broeckaert

[-- Attachment #2: Type: text/html, Size: 4431 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [OE-core] Application depending on gRPC not linking properly
  2020-09-09 12:56 Application depending on gRPC not linking properly broeckaert.goran
  2020-09-10  0:15 ` [OE-core] " Khem Raj
@ 2020-09-11 14:17 ` Stefan Herbrechtsmeier
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Herbrechtsmeier @ 2020-09-11 14:17 UTC (permalink / raw)
  To: Goran Broeckaert, openembedded-core

Hi,

Am 09.09.20 um 14:56 schrieb Goran Broeckaert:
> I have a simple application which depends on grpc. I'm using Yocto Zeus 
> for my project and I've written the following recipe:

[snip]

> The linker tries to link with the -native version of gRPC instead of the 
> target one. Can be seen in the following line from the output:
> 
> recipe-sysroot-native/usr/lib/libgrpc++.so.1.24.1: error adding symbols: 
> file in wrong format

The grpc cmake config requires the binaries and Yocto doesn't install 
cross compile binaries into the sysroot. Therefore the grcp recipe has a 
bad hack and install the cmake files from the native package:

SYSROOT_DIRS_BLACKLIST_append_class-target = "${baselib}/cmake/grpc"

I have try to fix the root cause in grpc but the pull request was closed 
by the developers because 'Yocto is not a platform we [grpc] officially 
support':

https://github.com/grpc/grpc/pull/22498

Regards
   Stefan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-11 14:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-09 12:56 Application depending on gRPC not linking properly broeckaert.goran
2020-09-10  0:15 ` [OE-core] " Khem Raj
2020-09-11  8:10   ` Goran Broeckaert
2020-09-11 14:17 ` [OE-core] " Stefan Herbrechtsmeier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.