【问题标题】:'glog/logging.h' file not found找不到“glog/logging.h”文件
【发布时间】:2018-09-14 08:55:27
【问题描述】:

前段时间,每次我启动一个新的 react-native 项目或安装模块时都会出现此错误。

'glog/logging.h' file not found.

我找到了解决方法

cd node_modules/react-native/third-party/glog-0.3.4
../../scripts/ios-configure-glog.sh

但是每次都运行这个非常乏味。

这似乎是节点的一些错误配置或类似的东西

【问题讨论】:

    标签: react-native node-modules


    【解决方案1】:

    假设您从项目根目录开始

    cd node_modules/react-native/third-party/glog-0.3.4

    sh ../../scripts/ios-configure-glog.sh

    ios-configure-glog.sh 使用到 ./configure 的相对路径,因此您必须先更改此路径或 cd,否则会出错。

    @jose920405 的所有道具!

    【讨论】:

    • 但这并没有改变任何东西。
    • 我收到此错误“正在检查与 BSD 兼容的安装... /usr/bin/install -c 检查构建环境是否正常...配置:错误:不安全的绝对工作目录名称"
    【解决方案2】:

    您好,问题来自于 ios-configure-glog.sh 您需要将此文件替换为较新的版本,因为在 0.034 上缺少模拟器测试...

    好的代码是

    #!/bin/bash
    set -e
    
    PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}"
    CURRENT_ARCH="${CURRENT_ARCH}"
    
    if [ -z "$CURRENT_ARCH" ] || [ "$CURRENT_ARCH" == "undefined_arch" ]; then
        # Xcode 10 beta sets CURRENT_ARCH to "undefined_arch", this leads to incorrect linker arg.
        # it's better to rely on platform name as fallback because architecture differs between simulator and device
    
        if [[ "$PLATFORM_NAME" == *"simulator"* ]]; then
            CURRENT_ARCH="x86_64"
        else
            CURRENT_ARCH="armv7"
        fi
    fi
    
    export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"
    export CXX="$CC"
    
    # Remove automake symlink if it exists
    if [ -h "test-driver" ]; then
        rm test-driver
    fi
    
    ./configure --host arm-apple-darwin
    
    # Fix build for tvOS
    cat << EOF >> src/config.h
    
    /* Add in so we have Apple Target Conditionals */
    #ifdef __APPLE__
    #include <TargetConditionals.h>
    #include <Availability.h>
    #endif
    
    /* Special configuration for AppleTVOS */
    #if TARGET_OS_TV
    #undef HAVE_SYSCALL_H
    #undef HAVE_SYS_SYSCALL_H
    #undef OS_MACOSX
    #endif
    
    /* Special configuration for ucontext */
    #undef HAVE_UCONTEXT_H
    #undef PC_FROM_UCONTEXT
    #if defined(__x86_64__)
    #define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip
    #elif defined(__i386__)
    #define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip
    #endif
    EOF
    

    【讨论】:

      【解决方案3】:

      如果您的问题在./configure 之后仍未解决,

      使用旧版本初始化项目

      react-native init --version 0.57.1 test2
      

      react-native 的版本列表在这里

      https://facebook.github.io/react-native/versions

      之后打开 Xcode,清理,构建 iphone 6 模拟器

      【讨论】:

        【解决方案4】:

        如果这些解决方案中的任何一个不起作用,请检查您的项目路径。

        项目路径和/或目录名称中不应包含任何空格,或者您可以在 Desktop 或 Documents 目录中创建项目。

        【讨论】:

          【解决方案5】:

          希望有帮助

          info Fetching system and libraries information...
          System:
              OS: macOS 10.14.6
              CPU: (8) x64 Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
              Memory: 680.81 MB / 16.00 GB
              Shell: 3.2.57 - /bin/bash
            Binaries:
              Node: 12.8.1 - /usr/local/bin/node
              Yarn: 1.17.3 - /usr/local/bin/yarn
              npm: 6.10.3 - /usr/local/bin/npm
              Watchman: 4.9.0 - /usr/local/bin/watchman
            SDKs:
              iOS SDK:
                Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
            IDEs:
              Xcode: 10.3/10G8 - /usr/bin/xcodebuild
            npmPackages:
              react: 16.8.6 => 16.8.6 
              react-native: 0.60.5 => 0.60.5 
            npmGlobalPackages:
              react-native-cli: 2.0.1
              react-native-git-upgrade: 0.2.7
              react-native-macos-cli: 2.0.1
          
          =====================================    
          1. rm -rf node_modules/ && yarn cache clean && yarn install
          2. rm -rf ~/.rncache
          3. cd node_modules/react-native/scripts
          4. ./ios-install-third-party.sh (install folly-2016.10.31.00 double-conversion glog)
          5. cd <Your-Project-Folder>/node_modules/react-native/third-party/glog*
          6. ./configure
          7. Xcode clean (Cmd + Shift + K) and build (react-native run-ios).
          

          【讨论】:

            【解决方案6】:

            试试 cd ios &amp;&amp; pod install

            它可以工作

            【讨论】:

              【解决方案7】:

              我通过删除 podlock 文件和 Pods 文件夹来修复它
              然后 pod 安装
              在这里分享,以便对某人有所帮助。

              【讨论】:

                【解决方案8】:

                如果您使用的是 GNU/linux - 例如在基于 Debian 的操作系统中,您可以简单地通过以下方式修复此错误:

                sudo apt install libgoogle-glog-dev
                

                安装谷歌日志库

                【讨论】:

                  猜你喜欢
                  • 2019-07-22
                  • 1970-01-01
                  • 2017-05-11
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 2013-05-02
                  • 2021-12-26
                  • 1970-01-01
                  相关资源
                  最近更新 更多