ElliotCui
ElliotCui

Reputation: 395

Error when installing Gem phashion: ld: library not found for -ljpeg

When I doing bundle install of my project with Pashion in my gemfile.

I encountered troubleshooting: ld: library not found for -ljpeg.

Confirmed things are I have installed jpeg, libjpeg, libpng by following commands.
brew install jpeg and brew install libjpeg
brew install libpng

gem install phashion -v '1.2.0' will get the same error.

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).

Most like the problem here https://github.com/westonplatter/phashion/issues/19

Upvotes: 3

Views: 1375

Answers (1)

ElliotCui
ElliotCui

Reputation: 395

After lots of searching and tries, the solution is as follows:

  1. gem install phashion -v '1.2.0'
    You will get troubleshooting: ld: library not found for -ljpeg

  2. install phashion with config
    LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/opt/libjpeg/lib gem install phashion -v '1.2.0'
    Then you will get troubleshooting: fatal error: 'jpeglib.h' file not found

  3. last troubleshooting is because of clang path error. So
    Add export CPLUS_INCLUDE_PATH=/opt/homebrew/include into ~/.zshrc
    Don't forget to source ~/.zshrc.

  4. run LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/opt/libjpeg/lib gem install phashion -v '1.2.0' once again.
    Then You will get troubleshooting: ld: library not found for -lpng

  5. run LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/opt/libjpeg/lib:/opt/homebrew/opt/libpng/lib gem install phashion -v '1.2.0' once again.

Installation success!

Upvotes: 8

Related Questions