ruby - gem install bson 在 Windows 10 上失败

标签 ruby installation rubygems bson hanami

我正在尝试使用 mongoid 制作 ruby​​ hanami api,但由于 bson,安装失败。 我得到这个错误



    compiling bytebuf.c
    compiling endian.c
    In file included from endian.c:18:
    bson-endian.h:109:1: error: unknown type name 'uint16_t'; did you mean 'wint_t'?
      109 | uint16_t __bson_uint16_swap_slow(uint16_t v);
          | ^~~~~~~~
          | wint_t
    bson-endian.h:109:34: error: unknown type name 'uint16_t'; did you mean
    'wint_t'?
      109 | uint16_t __bson_uint16_swap_slow(uint16_t v);
          |                                  ^~~~~~~~
          |                                  wint_t
    bson-endian.h:110:1: error: unknown type name 'uint32_t'; did you mean 'wint_t'?
      110 | uint32_t __bson_uint32_swap_slow(uint32_t v);
          | ^~~~~~~~
          | wint_t
    bson-endian.h:110:34: error: unknown type name 'uint32_t'; did you mean
    'wint_t'?
      110 | uint32_t __bson_uint32_swap_slow(uint32_t v);
          |                                  ^~~~~~~~
          |                                  wint_t
    bson-endian.h:111:1: error: unknown type name 'uint64_t'
      111 | uint64_t __bson_uint64_swap_slow(uint64_t v);
          | ^~~~~~~~
    bson-endian.h:111:34: error: unknown type name 'uint64_t'
      111 | uint64_t __bson_uint64_swap_slow(uint64_t v);
          |                                  ^~~~~~~~
    endian.c:35:1: error: unknown type name 'uint16_t'; did you mean 'wint_t'?
       35 | uint16_t __bson_uint16_swap_slow(uint16_t v)
          | ^~~~~~~~
          | wint_t
    endian.c:35:34: error: unknown type name 'uint16_t'; did you mean 'wint_t'?
       35 | uint16_t __bson_uint16_swap_slow(uint16_t v)
          |                                  ^~~~~~~~
          |                                  wint_t
    endian.c:56:1: error: unknown type name 'uint32_t'; did you mean 'wint_t'?
       56 | uint32_t __bson_uint32_swap_slow(uint32_t v)
          | ^~~~~~~~
          | wint_t
    endian.c:56:34: error: unknown type name 'uint32_t'; did you mean 'wint_t'?
       56 | uint32_t __bson_uint32_swap_slow(uint32_t v)
          |                                  ^~~~~~~~
          |                                  wint_t
    endian.c:80:1: error: unknown type name 'uint64_t'
       80 | uint64_t __bson_uint64_swap_slow(uint64_t v)
          | ^~~~~~~~
    endian.c:80:34: error: unknown type name 'uint64_t'
       80 | uint64_t __bson_uint64_swap_slow(uint64_t v)
          |                                  ^~~~~~~~
    endian.c: In function '__bson_double_swap_slow':
    endian.c:109:4: error: unknown type name 'uint64_t'
      109 |    uint64_t uv;
          |    ^~~~~~~~
    In file included from endian.c:18:
    bson-endian.h:65:57: error: 'uint64_t' undeclared (first use in this function)
       65 | #  define BSON_UINT64_SWAP_LE_BE(v) __builtin_bswap64 ((uint64_t)v)
          |                                                         ^~~~~~~~
    bson-endian.h:65:57: note: in definition of macro 'BSON_UINT64_SWAP_LE_BE'
       65 | #  define BSON_UINT64_SWAP_LE_BE(v) __builtin_bswap64 ((uint64_t)v)
          |                                                         ^~~~~~~~
    bson-endian.h:65:57: note: each undeclared identifier is reported only once for
    each function it appears in
       65 | #  define BSON_UINT64_SWAP_LE_BE(v) __builtin_bswap64 ((uint64_t)v)
          |                                                         ^~~~~~~~
    bson-endian.h:65:57: note: in definition of macro 'BSON_UINT64_SWAP_LE_BE'
       65 | #  define BSON_UINT64_SWAP_LE_BE(v) __builtin_bswap64 ((uint64_t)v)
          |                                                         ^~~~~~~~
    endian.c:112:32: error: expected ')' before 'uv'
      112 |    uv = BSON_UINT64_SWAP_LE_BE(uv);
          |                                ^~
    bson-endian.h:65:66: note: in definition of macro 'BSON_UINT64_SWAP_LE_BE'
       65 | #  define BSON_UINT64_SWAP_LE_BE(v) __builtin_bswap64 ((uint64_t)v)
          |                                                                  ^
    make: *** [Makefile:244: endian.o] Error 1

    make failed, exit code 2


我的 ruby​​ 版本是 2.6.5 。

我在互联网上寻找解决方案,但没有一个有效。我尝试使用 gem update 更新我的 gem 版本. 我试着添加 #include<stdint.h>在 bson-endian.h 中。

我该如何解决这个问题。

最佳答案

安装 BSON Gem 4.5.0 版。问题出在 Gem 的 4.6.0 版本中。

bundle : 将 gem 'bson', '~> 4.5.0' 添加到 Gemfile 并运行 bundle install

没有:gem install bson -v 4.5.0

关于ruby - gem install bson 在 Windows 10 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58825894/

相关文章:

ruby - Gem 在安装 jekyll 时无法构建 native 扩展

ruby-on-rails - Ruby on Rails 的 gem "Devise"在 app/controllers 中甚至没有 Controller 文件?

ruby - 如何在 Ruby 中删除 4 字节的 utf-8 字符?

ruby - Gemfile 中的 jeweler 和 gemspec 是否一起工作?

ruby - self.class.delete 是否调用类方法?

installation - nsis 安装程序自动退出/关闭,我正在使用 pre 和 show 函数来显示目录 MUI 页面

ubuntu - Lua、nmap、sqlite3 和 ubuntu - 找不到模块 'luasql.sqlite3'

ruby-on-rails - 在Gemfile中将插件指定为来自github的gem

ruby - $ :. push 在 ruby​​ 中做什么?

ruby - 迭代多个数组的最佳方法?