构建根目录:CMake:arch64-无-Linux-gnu/包含/c ++/9.2.1/计算机标准数据库:75:15:致命错误:stdlib. h:构建grpc包时没有此类文件或目录

2hh7jdfx  于 2023-01-12  发布在  Linux
关注(0)|答案(1)|浏览(249)

我正在将一个Buildroot构建系统从Ubuntu 18.04上的gcc-8升级到Ubuntu 22.04上的gcc-11,我真的很纠结。
在构建grpc 1.32.0时,我看到了很多这样的情况:

host/opt/ext-toolchain/aarch64-none-linux-gnu/include/c++/9.2.1/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
   75 | #include_next <stdlib.h>
      |               ^~~~~~~~~~
compilation terminated.
make[5]: *** [CMakeFiles/grpc_plugin_support.dir/build.make:104: CMakeFiles/grpc_plugin_support.dir/src/compiler/node_generator.cc.o] Error 1

stdlib.h就在host/opt/ext-toolchain/aarch64-none-linux-gnu/include/c++/9.2.1/stdlib.h的位置。
我尝试从buildroot(当前为1.51.1,此处)将grpc升级到最新版本,但仍然看到错误。
最新的grpc如下所示:https://github.com/buildroot/buildroot/tree/master/package/grpc
为了将我的更新到最新版本,我执行了以下操作:

# fetch latest from upstream buildroot
cd path/to/buildroot
git remote add upstream https://github.com/buildroot/buildroot.git
git fetch upstream master

# grab those changes for the grpc package only
rm -r package/grpc
git checkout upstream/master -- package/grpc
git add -A
git status
git commit -m "Update grpc library"
50few1ms

50few1ms1#

这似乎可以让该包的构建通过:
按照我的问题中的解释更新到最新的grpc包后,将此定义添加到CMake构建选项中:CMAKE_NO_SYSTEM_FROM_IMPORTED=1.
为此,我打开了我的buildroot/package/grpc/grpc.mk makefile,并更改了以下内容:

GRPC_CONF_OPTS += \
    -DCMAKE_C_FLAGS="$(GRPC_CFLAGS)" \
    -DCMAKE_CXX_FLAGS="$(GRPC_CXXFLAGS)"

改为:

GRPC_CONF_OPTS += \
    -DCMAKE_C_FLAGS="$(GRPC_CFLAGS)" \
    -DCMAKE_CXX_FLAGS="$(GRPC_CXXFLAGS)" \
    -DCMAKE_NO_SYSTEM_FROM_IMPORTED=1
# For just above, see: https://github.com/sony/nmos-cpp/issues/150#issuecomment-817259703

下面是我的buildroot/package/grpc/grpc.mk文件的最终版本:

################################################################################
#
# grpc
#
################################################################################

GRPC_VERSION = 1.51.1
GRPC_SITE = $(call github,grpc,grpc,v$(GRPC_VERSION))
GRPC_LICENSE = Apache-2.0, BSD-3-Clause (third_party code), MPL-2.0 (etc/roots.pem)
GRPC_LICENSE_FILES = LICENSE
GRPC_CPE_ID_VENDOR = grpc

GRPC_INSTALL_STAGING = YES

# Need to use host grpc_cpp_plugin during cross compilation.
GRPC_DEPENDENCIES = c-ares host-grpc libabseil-cpp openssl protobuf re2 zlib
HOST_GRPC_DEPENDENCIES = host-protobuf

# gRPC_CARES_PROVIDER=package won't work because it requires c-ares to have
# installed a cmake config file, but buildroot uses c-ares' autotools build,
# which doesn't do this.  These CARES settings trick the gRPC cmake code into
# not looking for c-ares at all and yet still linking with the library.
GRPC_CONF_OPTS = \
    -DCMAKE_EXE_LINKER_FLAGS="$(GRPC_EXE_LINKER_FLAGS)" \
    -DgRPC_ABSL_PROVIDER=package \
    -D_gRPC_CARES_LIBRARIES=cares \
    -DgRPC_CARES_PROVIDER=none \
    -DgRPC_PROTOBUF_PROVIDER=package \
    -DgRPC_RE2_PROVIDER=package \
    -DgRPC_SSL_PROVIDER=package \
    -DgRPC_ZLIB_PROVIDER=package \
    -DgRPC_BUILD_GRPC_CPP_PLUGIN=OFF \
    -DgRPC_BUILD_GRPC_CSHARP_PLUGIN=OFF \
    -DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF \
    -DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF \
    -DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF \
    -DgRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF \
    -DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF

ifeq ($(BR2_PACKAGE_LIBEXECINFO),y)
GRPC_DEPENDENCIES += libexecinfo
GRPC_EXE_LINKER_FLAGS += -lexecinfo
endif

# grpc can use __atomic builtins, so we need to link with
# libatomic when available
ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
GRPC_EXE_LINKER_FLAGS += -latomic
endif

GRPC_CFLAGS = $(TARGET_CFLAGS)
GRPC_CXXFLAGS = $(TARGET_CXXFLAGS)

# Set GPR_DISABLE_WRAPPED_MEMCPY otherwise build will fail on x86_64 with uclibc
# because grpc tries to link with memcpy@GLIBC_2.2.5
ifeq ($(BR2_x86_64):$(BR2_TOOLCHAIN_USES_GLIBC),y:)
GRPC_CFLAGS += -DGPR_DISABLE_WRAPPED_MEMCPY
GRPC_CXXFLAGS += -DGPR_DISABLE_WRAPPED_MEMCPY
endif

ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_85180),y)
GRPC_CFLAGS += -O0
GRPC_CXXFLAGS += -O0
endif

GRPC_CONF_OPTS += \
    -DCMAKE_C_FLAGS="$(GRPC_CFLAGS)" \
    -DCMAKE_CXX_FLAGS="$(GRPC_CXXFLAGS)" \
    -DCMAKE_NO_SYSTEM_FROM_IMPORTED=1
# For just above, see: https://github.com/sony/nmos-cpp/issues/150#issuecomment-817259703

# For host-grpc, we only need the 'grpc_cpp_plugin' binary, which is needed for
# target grpc compilation. To avoid unnecessary build steps and host
# dependencies, supply enough options to pass the configure checks without
# requiring other host packages, unless those needed by grpc_cpp_plugin.
HOST_GRPC_CONF_OPTS = \
    -DgRPC_PROTOBUF_PROVIDER=package \
    -DgRPC_ABSL_PROVIDER=none \
    -DgRPC_CARES_PROVIDER=none \
    -DgRPC_RE2_PROVIDER=none \
    -DgRPC_SSL_PROVIDER=none \
    -DgRPC_ZLIB_PROVIDER=none \
    -DgRPC_BUILD_CODEGEN=OFF \
    -DgRPC_BUILD_CSHARP_EXT=OFF \
    -DgRPC_BUILD_PLUGIN_SUPPORT_ONLY=ON \
    -DgRPC_BUILD_GRPC_CSHARP_PLUGIN=OFF \
    -DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF \
    -DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF \
    -DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF \
    -DgRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF \
    -DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF

$(eval $(cmake-package))
$(eval $(host-cmake-package))

我真的不知道我在做什么,也不知道为什么会这样。我第一次看到它是在这里:www.example.comhttps://github.com/sony/nmos-cpp/issues/150#issuecomment-817259703

相关问题