本文介绍了使用 OS X Mojave 安装旧的 scrypt gem 版本时出现 i386 arch 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在全新安装 OS X 10.14 Mojave 和 XCode 命令行工具后,我正在尝试为旧项目安装旧的 gem 版本.我尝试安装的 gem 是 scrypt,版本 1.2.1,它是 authlogic 的依赖项.

I'm trying to install an old gem version for an old project after a fresh install of OS X 10.14 Mojave and XCode Command Line Tools. The gem I'm trying to install is scrypt, version 1.2.1, which is a dependency of authlogic.

gem install scrypt -v=1.2.1

gem install scrypt -v=1.2.1

返回以下错误:

Building native extensions. This could take a while...
ERROR:  Error installing scrypt:
    ERROR: Failed to build gem native extension.

    current directory: /Users/chris/.rvm/gems/ruby-2.4.4@rails5/gems/scrypt-1.2.1/ext/scrypt
/Users/chris/.rvm/rubies/ruby-2.4.4/bin/ruby -rrubygems /Users/chris/.rvm/gems/ruby-2.4.4@global/gems/rake-12.0.0/exe/rake RUBYARCHDIR=/Users/chris/.rvm/gems/ruby-2.4.4@rails5/extensions/x86_64-darwin-18/2.4.0/scrypt-1.2.1 RUBYLIBDIR=/Users/chris/.rvm/gems/ruby-2.4.4@rails5/extensions/x86_64-darwin-18/2.4.0/scrypt-1.2.1
mkdir -p x86_64-darwin
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -Wall -msse -msse2 -arch x86_64 -arch i386   -o x86_64-darwin/crypto_scrypt-sse.o -c ./crypto_scrypt-sse.c
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -Wall -msse -msse2 -arch x86_64 -arch i386   -o x86_64-darwin/memlimit.o -c ./memlimit.c
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -Wall -msse -msse2 -arch x86_64 -arch i386   -o x86_64-darwin/scrypt_calibrate.o -c ./scrypt_calibrate.c
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -Wall -msse -msse2 -arch x86_64 -arch i386   -o x86_64-darwin/scrypt_ext.o -c ./scrypt_ext.c
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -Wall -msse -msse2 -arch x86_64 -arch i386   -o x86_64-darwin/scryptenc_cpuperf.o -c ./scryptenc_cpuperf.c
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -Wall -msse -msse2 -arch x86_64 -arch i386   -o x86_64-darwin/sha256.o -c ./sha256.c
gcc -bundle -o x86_64-darwin/libscrypt_ext.bundle x86_64-darwin/crypto_scrypt-sse.o x86_64-darwin/memlimit.o x86_64-darwin/scrypt_calibrate.o x86_64-darwin/scrypt_ext.o x86_64-darwin/scryptenc_cpuperf.o x86_64-darwin/sha256.o -fexceptions -arch x86_64 -arch i386 
ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd, missing required architecture i386 in file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd
Undefined symbols for architecture i386:
  "___error", referenced from:
      _crypto_scrypt in crypto_scrypt-sse.o
      _memtouse in memlimit.o
  "___stack_chk_fail", referenced from:
      _scrypt_SHA256_Transform in sha256.o
      _scrypt_SHA256_Final in sha256.o
      _HMAC_scrypt_SHA256_Init in sha256.o
      _HMAC_scrypt_SHA256_Final in sha256.o
      _PBKDF2_scrypt_SHA256 in sha256.o
  "___stack_chk_guard", referenced from:
      _scrypt_SHA256_Transform in sha256.o
      _scrypt_SHA256_Final in sha256.o
      _HMAC_scrypt_SHA256_Init in sha256.o
      _HMAC_scrypt_SHA256_Final in sha256.o
      _PBKDF2_scrypt_SHA256 in sha256.o
  "_free", referenced from:
      _crypto_scrypt in crypto_scrypt-sse.o
  "_getrlimit$UNIX2003", referenced from:
      _memtouse in memlimit.o
  "_gettimeofday", referenced from:
      _scryptenc_cpuperf in scryptenc_cpuperf.o
  "_malloc", referenced from:
      _crypto_scrypt in crypto_scrypt-sse.o
  "_memcpy", referenced from:
      _scrypt_SHA256_Update in sha256.o
      _PBKDF2_scrypt_SHA256 in sha256.o
  "_mmap$UNIX2003", referenced from:
      _crypto_scrypt in crypto_scrypt-sse.o
  "_munmap$UNIX2003", referenced from:
      _crypto_scrypt in crypto_scrypt-sse.o
  "_sysconf", referenced from:
      _memtouse in memlimit.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
rake aborted!
Command failed with status (1): [gcc -bundle -o x86_64-darwin/libscrypt_ext...]
/Users/chris/.rvm/gems/ruby-2.4.4@rails5/gems/ffi-compiler-1.0.1/lib/ffi-compiler/compile_task.rb:153:in `block in define_task!'
/Users/chris/.rvm/gems/ruby-2.4.4@global/gems/rake-12.0.0/exe/rake:27:in `<main>'
Tasks: TOP => default => x86_64-darwin/libscrypt_ext.bundle
(See full trace by running task with --trace)

rake failed, exit code 1

推荐答案

我遇到了这个确切的问题.

I was experiencing this exact problem.

我正在运行 Mojave (10.14.4) 和 10.2 版的 XCode 命令行工具,并且在运行 gem install scrypt -v 1.2.1 时,我得到了完全相同的错误如上所述.

I'm running Mojave (10.14.4) and Version 10.2 of the XCode Command Line Tools, and when running gem install scrypt -v 1.2.1, I was getting the exact same error as described above.

解决方案是安装这个包:/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg(如升级到 Mojave 后无法在 Mac 上编译 C 程序).显然,问题的根源在于在这个过程中的某个地方(bundler?scrypt?)期望头文件可以在 /usr/include 中找到.最新版本的 XCode 不会将头文件放在该位置,但运行包会将它们放在那里(如 XCode 发行说明)

The solution was to install this package: /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg (as described in Can't compile C program on a Mac after upgrade to Mojave). Apparently the root of the issue was that somewhere in this process (bundler? scrypt?) there was an expectation that header files could be found in /usr/include. The latest version of XCode does not place header files in that location, but running the package places them there (as documented in the XCode release notes)

这篇关于使用 OS X Mojave 安装旧的 scrypt gem 版本时出现 i386 arch 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 23:09