ImportError: libjasper.so.1: cannot open shared object file: No such file or directory
When you Google the error message, the most common solution given is to install libjasper-dev. Unfortunately, libjasper-dev is not available on Ubuntu Bionic
$ apt-cache search libjasper
libjasperreports-java - Java reporting generator library
Background
libjasper-dev was available on Ubuntu Xenial 16.04, so why has it been removed? Jasper was intentionally removed from Ubuntu and Debian from this Debian bug report.------------------- Reason -------------------
RoQA; dead upstrem, replaced by openjpeg
----------------------------------------------
Some further explanation on the bug report
Due to lack of time, I'm looking for a new maintainer for this package. There was no upstream release since 2007. Although you can contact the original author, he doesn't seem to be actively working on jasper releases. There are alternative libraries in Debian, and maybe jasper should be completely replaced by other libraries since there were several security bugs in Debian due to jasper upstream code, and it's hard to work on them without upstream.
At the time of the bug report, there was no update to Jasper for 9 years. The Debian maintainer of the package decided to remove this package.
Ubuntu is built on top of Debian, therefore Jasper has been unavailable in Ubuntu since 17.04.
Jasper is still a needed dependency for OpenCV. Here are the options.
OpenCV's bundled Jasper
3rd-party dependency build issues is common enough that OpenCV bundles most dependencies, including Jasper. Use the bundled version of Jasper 1.900.1 with the CMake flag WITH_JASPER.Here is an example
cd opencv-3.4.9/
mkdir build
cd build/
cmake -DWITH_JASPER=ON ..
cmake will report the build options once it has completed building. You should be able to see that the JPEG_2000 feature is enabled with version 1.900.1
-- OpenCV modules:
-- To be built: calib3d core dnn features2d flann highgui imgcodecs imgproc ml objdetect photo shape stitching superres ts video videoio videostab
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java js python2 python3 viz
-- Applications: tests perf_tests apps
-- Documentation: NO
-- Non-free algorithms: NO
--
-- GUI:
-- GTK+: NO
-- VTK support: NO
--
-- Media I/O:
-- ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
-- JPEG: libjpeg-turbo (ver 2.0.2-62)
-- WEBP: build (ver encoder: 0x020e)
-- PNG: build (ver 1.6.37)
-- TIFF: build (ver 42 - 4.0.10)
-- JPEG 2000: build (ver 1.900.1)
-- OpenEXR: build (ver 2.3.0)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
--
-- Video I/O:
-- DC1394: NO
-- FFMPEG: NO
-- avcodec: NO
-- avformat: NO
-- avutil: NO
-- swscale: NO
-- avresample: NO
-- GStreamer: NO
-- libv4l/libv4l2: NO
-- v4l/v4l2: linux/videodev2.h
If this version of Jasper is too old, you can use your own Jasper.
Compile Jasper from Source
Since Jasper is an open source project and is available on Github, you can download the latest release and compile it.
wget https://github.com/mdadams/jasper/archive/version-2.0.16.tar.gz -O jasper-version-2.0.16.tar.gz
tar xvf cd jasper-version-2.0.16.tar.gz
cd jasper-version-2.0.16/
Let's first install all the required build tools
sudo apt-get install build-essential cmake
Now we can start building jasper
mkdir build
export SOURCE_DIR=~/jasper-version-2.0.16
export BUILD_DIR=~/jasper-version-2.0.16/build
cd $BUILD_DIR
cmake -G "Unix Makefiles" -H$SOURCE_DIR -B$BUILD_DIR
cd $BUILD_DIR
make clean all
make test
The binaries are now built here
~/jasper-version-2.0.16/build$ ls src/appl/
CMakeFiles CTestTestfile.cmake imginfo jiv
cmake_install.cmake imgcmp jasper Makefile
The libraries are available at
$ ls src/libjasper/CMakeFiles include libjasper.so.4.0.0
cmake_install.cmake libjasper.so Makefile
CTestTestfile.cmake libjasper.so.4
Note that if you want to install all the files into Ubuntu's standard path, you will need to have root or sudo permission. This is not recommended, as those files are installed without going through Ubuntu's package manager (apt / apt-get / aptitude), and you risk losing track of what applications and which versions have been installed. But if you are sure you know what you are doing
sudo make install
libjasper-dev from Ubuntu Xenial
Another alternative is to install libjasper-dev from an older release of Ubuntu, libjasper-dev 1.900.1 from Ubuntu Xenial 16.04.Add the Xenial repository
echo “deb http://security.ubuntu.com/ubuntu xenial-security main” | sudo tee /etc/apt/sources.list.d/xenial.list
Install Jasper
sudo apt update
sudo apt install libjasper1 libjasper-dev
After installation of Jasper, remember to remove the Xenial repository to prevent conflicts and errors
sudo rm /etc/apt/sources.list.d/xenial.list
sudo apt update
Note that this version of Jasper is very old, 1.900 released before 2016.
No comments:
Post a Comment