首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:无法构建gem本机扩展。M1芯片未找到potracelib.h

错误:无法构建gem本机扩展。M1芯片未找到potracelib.h
EN

Stack Overflow用户
提问于 2021-10-25 21:41:26
回答 1查看 278关注 0票数 0

我正在尝试在我的Macbook Air中安装一个配备M1芯片的Rails 5应用程序。这个应用程序使用了一个名为potracer的gem。

在执行$ bundle install之后,我得到了以下错误:

代码语言:javascript
复制
Installing potracer 1.1.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/user/.rvm/gems/ruby-2.7.2/gems/potracer-1.1.4/ext/potracer
/Users/user/.rvm/rubies/ruby-2.7.2/bin/ruby -I /Users/user/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0 -r ./siteconf20211025-1533-nnxnj9.rb extconf.rb
checking for potracelib.h... no
potracelib.h not found
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/user/.rvm/rubies/ruby-2.7.2/bin/$(RUBY_BASE_NAME)
    --with-potrace-dir
    --without-potrace-dir
    --with-potrace-include
    --without-potrace-include=${potrace-dir}/include
    --with-potrace-lib
    --without-potrace-lib=${potrace-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/user/.rvm/gems/ruby-2.7.2/extensions/arm64-darwin-20/2.7.0/potracer-1.1.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/user/.rvm/gems/ruby-2.7.2/gems/potracer-1.1.4 for inspection.
Results logged to /Users/user/.rvm/gems/ruby-2.7.2/extensions/arm64-darwin-20/2.7.0/potracer-1.1.4/gem_make.out

An error occurred while installing potracer (1.1.4), and Bundler cannot continue.
Make sure that `gem install potracer -v '1.1.4' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  potracer

我在安装带有M1芯片的其他rails应用程序时遇到了其他问题,但我找到了解决方法,但不是在这种情况下。

关于如何解决这个问题的想法?

EN

回答 1

Stack Overflow用户

发布于 2021-10-26 00:12:48

之前你必须重新安装potrace loccaly。安装似乎不完整。

您需要安装库/头文件。根据您的平台,它可能类似于libpotrace和libpitrace dev。

您可以通过homebrew、apt、dnf等安装它们。

除非您在本地获得potrace.h,否则potrace执行将中止

找不到

中止potracelib.h‘除非find_header('potracelib.h')

代码语言:javascript
复制
    require 'mkmf'

RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']

LIBDIR = RbConfig::CONFIG['libdir']
INCLUDEDIR = RbConfig::CONFIG['includedir']

HEADER_DIRS = ['/opt/local/include', '/usr/local/include', INCLUDEDIR,
               '/usr/include']

LIB_DIRS = ['/opt/local/lib', '/usr/local/lib', LIBDIR, '/usr/lib']

dir_config('potrace', HEADER_DIRS, LIB_DIRS)

abort 'potracelib.h not found' unless find_header('potracelib.h')
abort 'lib potrace not found' unless find_library('potrace', 'potrace_version')

create_header
create_makefile('potracer/potracer')

来源:https://github.com/kennyp/potracer/blob/b67d3ff6a1ae672ccc6701fa5245fa532b461ef3/ext/potracer/extconf.rb

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69715067

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档