gRPC C++ 在 Yocto 2.2 上

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

gRPC C++ on Yocto 2.2

问题

我正在尝试在Yocto 2.2上为armv5e构建gRPC。我使用的是gRPC 1.6.8,但在进行do_compile时遇到了错误。以下是我用于gRPC的配方:

inherit autotools-brokensep pkgconfig

DEPENDS = "\
    protobuf3 \
    protobuf3-native \
    zlib \
    openssl \
    c-ares \
";

SRC_URI = "gitsm://github.com/grpc/grpc.git;branch=v1.6.x"
SRCREV = "4735689cc5af6c56eeae5c9ab10fa538552dc08e"

DEPENDS_append_class-target = " gtest grpc-native "
DEPENDS_append_class-nativesdk = " grpc-native"


SRC_URI_append_class-target = " file://0001-CMakeLists.txt-Fix-grpc_cpp_plugin-path-during-cross.patch"
PR = "r0"

S = "${WORKDIR}/git"

# 修复静态库生成
AR += "rcs"

OUTDIR = "${S}/libs/opt/"

CXXFLAGS_append_class-native = " --with-protoc=protoc,--host=x86_64-linux,CC=\"${CC}\",CXX=\"${CC}\",HOST_CC=\"gcc-6\",HOST_CXX=\"gcc-6\",RANLIB=\"${CC}\",LD=\"${CC}\",LDXX=\"${CC}\""

do_configure () {
}
do_compile () {
    make clean
    export LD="${CC}"
    export GRPC_CROSS_COMPILE=true
    export HAS_PKG_CONFIG=false
    make prefix=${exec_prefix} static_cxx shared_cxx
    # make shared_cxx static_cxx
}

do_install () {
    
    oe_runmake prefix=${D}${exec_prefix} install-headers_c

    oe_libinstall -C ${OUTDIR} -so libgpr ${D}${libdir}
    oe_libinstall -C ${OUTDIR} -so libgrpc ${D}${libdir}
    oe_libinstall -C ${OUTDIR} -so libgrpc_cronet ${D}${libdir}
    oe_libinstall -C ${OUTDIR} -so libgrpc_unsecure ${D}${libdir}

    oe_libinstall -C ${OUTDIR} -so libgrpc++ ${D}${libdir}
    oe_libinstall -C ${OUTDIR} -so libgrpc++_cronet ${D}${libdir}
    oe_libinstall -C ${OUTDIR} -so libgrpc++_unsecure ${D}${libdir}

    install -d ${D}${libdir}/pkgconfig
    install -m 0644 ${OUTDIR}/pkgconfig/*.pc ${D}${libdir}/pkgconfig/
}

INSANE_SKIP_${PN} = "already-stripped rpaths"

我收到以下错误信息:

| /usr/bin/ld: /home/src/build/tmp/work/armv5e-linux-gnueabi/grpc/1.6.8-r0/git/objs/opt/src/compiler/cpp_plugin.o: Relocations in generic ELF (EM: 40)
| /home//src/build/tmp/work/armv5e-linux-gnueabi/grpc/1.6.8-r0/git/objs/opt/src/compiler/cpp_plugin.o: error adding symbols: File in wrong format
| collect2: error: ld returned 1 exit status
| Makefile:15002: recipe for target '/home/src/build/tmp/work/armv5e-linux-gnueabi/grpc/1.6.8-r0/git/bins/opt/grpc_cpp_plugin' failed
| make: *** [/home/src/build/tmp/work/armv5e-polatis-gnueabi/grpc/1.6.8-r0/git/bins/opt/grpc_cpp_plugin] Error 1

我正在使用此Makefile

当我尝试构建static_c和shared_c目标时,构建是成功的。但是当我尝试构建static_cxx和shared_cxx时,会出现错误。请帮助解决。

英文:

Im trying to build gRPC on yocto 2.2 for armv5e. Im using gRPC 1.6.8 and facing error during the do_compile. Heres the recipie im using for grpc

inherit autotools-brokensep pkgconfig

DEPENDS = "\
    protobuf3 \
    protobuf3-native \
    zlib \
    openssl \
    c-ares \
"

SRC_URI = "gitsm://github.com/grpc/grpc.git;branch=v1.6.x"
SRCREV = "4735689cc5af6c56eeae5c9ab10fa538552dc08e"

DEPENDS_append_class-target = " gtest grpc-native "
DEPENDS_append_class-nativesdk = " grpc-native"


SRC_URI_append_class-target = " file://0001-CMakeLists.txt-Fix-grpc_cpp_plugin-path-during-cross.patch"
PR = "r0"

S = "${WORKDIR}/git"

# Fix static library generation
AR += "rcs"

OUTDIR = "${S}/libs/opt/"

CXXFLAGS_append_class-native = " --with-protoc=protoc,--host=x86_64-linux,CC="${CC}",CXX="${CC}",HOST_CC="gcc-6",HOST_CXX="gcc-6",RANLIB="${CC}",LD="${CC}",LDXX="${CC}""

do_configure () {
}
do_compile () {
    make clean
    export LD="${CC}"
    export GRPC_CROSS_COMPILE=true
    export HAS_PKG_CONFIG=false
    make prefix=${exec_prefix} static_cxx shared_cxx
    # make shared_cxx static_cxx
}

do_install () {
    
    oe_runmake prefix=${D}${exec_prefix} install-headers_c

    oe_libinstall -C ${OUTDIR} -so libgpr ${D}${libdir}
    oe_libinstall -C ${OUTDIR} -so libgrpc ${D}${libdir}
    oe_libinstall -C ${OUTDIR} -so libgrpc_cronet ${D}${libdir}
    oe_libinstall -C ${OUTDIR} -so libgrpc_unsecure ${D}${libdir}

    oe_libinstall -C ${OUTDIR} -so libgrpc++ ${D}${libdir}
    oe_libinstall -C ${OUTDIR} -so libgrpc++_cronet ${D}${libdir}
    oe_libinstall -C ${OUTDIR} -so libgrpc++_unsecure ${D}${libdir}

    install -d ${D}${libdir}/pkgconfig
    install -m 0644 ${OUTDIR}/pkgconfig/*.pc ${D}${libdir}/pkgconfig/
}

INSANE_SKIP_${PN} = "already-stripped rpaths"

Im getting the error as
> | /usr/bin/ld: /home/src/build/tmp/work/armv5e-linux-gnueabi/grpc/1.6.8-r0/git/objs/opt/src/compiler/cpp_plugin.o: Relocations in generic ELF (EM: 40)
> | /home//src/build/tmp/work/armv5e-linux-gnueabi/grpc/1.6.8-r0/git/objs/opt/src/compiler/cpp_plugin.o: error adding symbols: File in wrong format
> collect2: error: ld returned 1 exit status
> Makefile:15002: recipe for target '/home/src/build/tmp/work/armv5e-linux-gnueabi/grpc/1.6.8-r0/git/bins/opt/grpc_cpp_plugin' failed
> make: *** [/home/src/build/tmp/work/armv5e-polatis-gnueabi/grpc/1.6.8-r0/git/bins/opt/grpc_cpp_plugin] Error 1

Im using this Makefile

I have tried building fr static_c and shared_c targets and build is successful. When i try for static_cxx and shared_cxx it gives the error. Please help

答案1

得分: 0

问题实际上出现在交叉编译过程中。源代码使用32位编译器编译,但尝试使用主机64位链接器进行链接。通过更改 EXTRA_OEMAKE_append_class-target 来修复。

英文:

It was actually problem during cross-compilation. The source was compiled using 32 bits compiler but it was trying to link using host 64 bit linker. Fixed by changing the linker through EXTRA_OEMAKE_append_class-target.

huangapple
  • 本文由 发表于 2023年6月9日 14:40:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76437818.html
匿名

发表评论

匿名网友

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

确定