Install libjpeg v8 to /opt/local

2019-08-18 05:42发布

问题:

How do I install libjpeg 8 to /opt/local on OSX? The reason I am asking is that I would like to create small movies of brain activity using the MNE-C libraries.

I executed 'mne_make_movie' which results in the following error:

Movie production selected (from data)... Scanning /Users/user/mne/MNE-2.7.4-3420-MacOSX-x86_64/lib for plugins Found lqt_mjpeg.so...Getting codec info from module Trying to load /Users/user/mne/MNE-2.7.4-3420-MacOSX-x86_64/lib/lqt_mjpeg.so... dlopen failed for /Users/user/mne/MNE-2.7.4-3420-MacOSX-x86_64/lib/lqt_mjpeg.so: dlopen(/Users/user/mne/MNE-2.7.4-3420-MacOSX-x86_64/lib/lqt_mjpeg.so, 2): Library not loaded: /opt/local/lib/libjpeg.8.dylib Referenced from: /Users/user/mne/MNE-2.7.4-3420-MacOSX-x86_64/lib/lqt_mjpeg.so
Reason: image not found ERROR: lqt_find_video_codec failed to find codecs!

Since everything is already compiled I don't think I can change the location where 'mne_make_movie' is looking for libjpeg. So I tried installing libjpeg using Mac Ports, which only has libjpeg-turbo available. However, then I get another error:

Movie production selected (from data)... Scanning /Users/user/mne/MNE-2.7.4-3420-MacOSX-x86_64/lib for plugins Found lqt_mjpeg.so...Getting codec info from module Trying to load /Users/user/mne/MNE-2.7.4-3420-MacOSX-x86_64/lib/lqt_mjpeg.so... dlopen failed for /Users/user/mne/MNE-2.7.4-3420-MacOSX-x86_64/lib/lqt_mjpeg.so: dlopen(/Users/user/mne/MNE-2.7.4-3420-MacOSX-x86_64/lib/lqt_mjpeg.so, 2): Library not loaded: /opt/local/lib/libjpeg.8.dylib Referenced from: /Users/user/mne/MNE-2.7.4-3420-MacOSX-x86_64/lib/lqt_mjpeg.so
Reason: Incompatible library version: lqt_mjpeg.so requires version 13.0.0 or later, but libjpeg.8.dylib provides version 10.0.0 ERROR: lqt_find_video_codec failed to find codecs!

A more up to date version does not seem to be available on Mac Ports.

On the official website of libjpeg I downloaded the source for version 8d and followed the install instructions. This would install everything to /usr/local. I am not familiar with makefiles and don't know what I have to alter to install everything correctly to /opt/local.

So how do I install libjpeg 8 version 13.0.0 or greater to /opt/local?

P.S.: Homebrew does not seem applicable since it does not install to /opt/local (and it is not recommended to change it to /opt/local) and libjpeg 9 seems to be the only version available.

回答1:

If you don't use command-line build tools much, or you have recently upgraded macOS, you will probably need to download the Xcode command-line tools before you start. It won't do any harm if you already have them. The command is:

xcode-select --install

Then the following should work, though I have not tested it, so you may like to copy and paste one line at a time into your Terminal:

curl -O -J -L http://www.ijg.org/files/jpegsrc.v8.tar.gz
tar xvfz jpeg*tar.gz                 # Unzip and untar what you downloaded
cd jpeg-8                            # Change directory to wherever it unpacked to
./configure --prefix="/opt/local"    # Configure with the necessary prefix
make
make install

You may need to prefix the last line with sudo.