首页 > 解决方案 > 安装 Gem phashion 时出错:ld: library not found for -ljpeg

问题描述

Pashion当我在我的 gemfile 中捆绑安装我的项目时。

我遇到了故障排除: ld: library not found for -ljpeg.

确认的东西是我jpeg, libjpeg, libpng通过以下命令安装的。
brew install jpegbrew install libjpeg
brew install libpng

gem install phashion -v '1.2.0'会得到同样的错误。

Machine: MacBook Air (M1, 2020)
Os: macOS BigSur 11.2 (20D64)

$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: arm64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Related:
I use homebrew, which has full support on NEW Mac(M1), to install pacakges.
I use rvm(1.29.12) to manage ruby(2.6.3 as default).

最喜欢这里的问题https://github.com/westonplatter/phashion/issues/19

标签: rubyrubygemsapple-m1

解决方案


经过大量搜索和尝试,解决方案如下:

  1. gem install phashion -v '1.2.0'
    您将获得故障排除:ld: library not found for -ljpeg

  2. 使用 config 安装 phashion
    LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/opt/libjpeg/lib gem install phashion -v '1.2.0'
    然后您将得到故障排除:fatal error: 'jpeglib.h' file not found

  3. 最后的故障排除是因为铿锵路径错误。所以
    添加export CPLUS_INCLUDE_PATH=/opt/homebrew/include~/.zshrc
    不要忘记source ~/.zshrc

  4. LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/opt/libjpeg/lib gem install phashion -v '1.2.0'再次运行。
    然后您将获得故障排除:ld: library not found for -lpng

  5. LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/opt/libjpeg/lib:/opt/homebrew/opt/libpng/lib gem install phashion -v '1.2.0'再次运行。

安装成功!


推荐阅读