本文首发于个人博客https://kezunlin.me/post/9f626e7a/,欢迎阅读!
compile and use libjpeg-turbo on ubuntu 16.04
Series
Guide
build requirements
- autoconf 2.56 or later
- automake 1.7 or later
- libtool 1.4 or later
- NASM 2.13 x86-64
- libjpeg-turbo latest
install tools
sudo apt-get install autoconf automake libtool
compile nasm
wget http://www.nasm.us/pub/nasm/releasebuilds/2.13.03/nasm-2.13.03.tar.gz
cd nasm
./configure
make -j8
sudo make install
this will install nasm
to /usr/local/bin/nasm
which nasm
/usr/local/bin/nasm
compile libjpeg
We can not use cmake to build libjpeg on linux.
Platform not supported by this build system. Use autotools instead.
git clone https://github.com/libjpeg-turbo/libjpeg-turbo.git
cd libjpeg-turob
# generate configure
autoreconf -fiv
# exec-prefix=/usr/local/ for /bin and /lib
# prefix=/usr/local/include/libjpegturbo for /include
./configure --exec-prefix=/usr/local --prefix=/usr/local/include/libjpegturbo --with-jpeg8 --disable-static
make -j8
make test
sudo make install
libjpegturbo-config.cmake
# - Try to find LIBJPEGTURBO
#
# The following variables are optionally searched for defaults
# LIBJPEGTURBO_ROOT_DIR: Base directory where all LIBJPEGTURBO components are found
#
# The following are set after configuration is done:
# LIBJPEGTURBO_FOUND
# LIBJPEGTURBO_INCLUDE_DIRS
# LIBJPEGTURBO_LIBRARIES
# LIBJPEGTURBO_LIBRARYRARY_DIRS
include(FindPackageHandleStandardArgs)
set(LIBJPEGTURBO_ROOT_DIR "" CACHE PATH "Folder contains mysqlcppconn")
if(WIN32)
find_path(LIBJPEGTURBO_INCLUDE_DIR turbojpeg.h
PATHS ${LIBJPEGTURBO_ROOT_DIR})
else()
find_path(LIBJPEGTURBO_INCLUDE_DIR turbojpeg.h
PATHS ${LIBJPEGTURBO_ROOT_DIR})
endif()
if(MSVC)
find_library(LIBJPEGTURBO_LIBRARY_RELEASE turbojpeg
PATHS ${LIBJPEGTURBO_ROOT_DIR}
PATH_SUFFIXES Release)
find_library(LIBJPEGTURBO_LIBRARY_DEBUG turbojpeg
PATHS ${LIBJPEGTURBO_ROOT_DIR}
PATH_SUFFIXES Debug)
set(LIBJPEGTURBO_LIBRARY optimized ${LIBJPEGTURBO_LIBRARY_RELEASE} debug ${LIBJPEGTURBO_LIBRARY_DEBUG})
else()
find_library(LIBJPEGTURBO_LIBRARY turbojpeg
PATHS ${LIBJPEGTURBO_ROOT_DIR}
PATH_SUFFIXES lib lib64)
endif()
find_package_handle_standard_args(LIBJPEGTURBO DEFAULT_MSG LIBJPEGTURBO_INCLUDE_DIR LIBJPEGTURBO_LIBRARY)
if(LIBJPEGTURBO_FOUND)
set(LIBJPEGTURBO_INCLUDE_DIRS ${LIBJPEGTURBO_INCLUDE_DIR})
set(LIBJPEGTURBO_LIBRARIES ${LIBJPEGTURBO_LIBRARY})
message(STATUS "Found mysqlcppconn (include: ${LIBJPEGTURBO_INCLUDE_DIR}, library: ${LIBJPEGTURBO_LIBRARY})")
mark_as_advanced(LIBJPEGTURBO_ROOT_DIR LIBJPEGTURBO_LIBRARY_RELEASE LIBJPEGTURBO_LIBRARY_DEBUG
LIBJPEGTURBO_LIBRARY LIBJPEGTURBO_INCLUDE_DIR)
endif()
copy libjpegturbo-config.cmake
to /usr/local/lib/cmake/libjpegturbo/
sudo mkdir -p /usr/local/lib/cmake/libjpegturbo/
sudo cp libjpegturbo-config.cmake /usr/local/lib/cmake/libjpegturbo/
CMakeLists.txt
find_package(LIBJPEGTURBO REQUIRED)
include_directories(${LIBJPEGTURBO_INCLUDE_DIRS})
target_link_libraries (example_jpeg ${LIBJPEGTURBO_LIBRARIES})
Reference
History
- 20180223: created.
Copyright
- Post author: kezunlin
- Post link: https://kezunlin.me/post/9f626e7a/
- Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.