Blame INSTALL.md

Packit Service 679f35
Packit Service 679f35
# OpenJPEG installation
Packit Service 679f35
Packit Service 679f35
The build method maintained by OpenJPEG is [CMake](https://cmake.org/).
Packit Service 679f35
Packit Service 679f35
## UNIX/LINUX - MacOS (terminal) - WINDOWS (cygwin, MinGW)
Packit Service 679f35
Packit Service 679f35
To build the library, type from source tree directory:
Packit Service 679f35
```
Packit Service 679f35
mkdir build
Packit Service 679f35
cd build
Packit Service 679f35
cmake .. -DCMAKE_BUILD_TYPE=Release
Packit Service 679f35
make
Packit Service 679f35
```
Packit Service 679f35
Binaries are then located in the 'bin' directory.
Packit Service 679f35
Packit Service 679f35
To install the library, type with root privileges:
Packit Service 679f35
```
Packit Service 679f35
make install
Packit Service 679f35
make clean
Packit Service 679f35
```
Packit Service 679f35
Packit Service 679f35
To build the html documentation, you need doxygen to be installed on your system.
Packit Service 679f35
It will create an "html" directory in TOP\_LEVEL/build/doc)
Packit Service 679f35
```
Packit Service 679f35
make doc
Packit Service 679f35
```
Packit Service 679f35
Packit Service 679f35
Main available cmake flags:
Packit Service 679f35
  * To specify the install path: '-DCMAKE\_INSTALL\_PREFIX=/path'
Packit Service 679f35
  * To build the shared libraries and links the executables against it: '-DBUILD\_SHARED\_LIBS:bool=on' (default: 'ON')
Packit Service 679f35
> Note: when using this option, static libraries are not built and executables are dynamically linked.
Packit Service 679f35
  * PKG_CONFIG files are by default built for Unix compile, you can force to build on other platforms by adding: '-DBUILD_PKGCONFIG_FILES=on'
Packit Service 679f35
  * To build the CODEC executables: '-DBUILD\_CODEC:bool=on' (default: 'ON')
Packit Service 679f35
  * To build opjstyle (internal version of astyle) for OpenJPEG development: '-DWITH_ASTYLE=ON'
Packit Service 679f35
  * [OBSOLETE] To build the MJ2 executables: '-DBUILD\_MJ2:bool=on' (default: 'OFF')
Packit Service 679f35
  * [OBSOLETE] To build the JPWL executables and JPWL library: '-DBUILD\_JPWL:bool=on' (default: 'OFF')
Packit Service 679f35
  * [OBSOLETE] To build the JPIP client (java compiler recommended) library and executables: '-DBUILD\_JPIP:bool=on' (default: 'OFF')
Packit Service 679f35
  * [OBSOLETE] To build the JPIP server (need fcgi) library and executables: '-DBUILD\_JPIP\_SERVER:bool=on' (default: 'OFF')
Packit Service 679f35
  * To enable testing (and automatic result upload to http://my.cdash.org/index.php?project=OPENJPEG):
Packit Service 679f35
```
Packit Service 679f35
cmake . -DBUILD_TESTING:BOOL=ON -DOPJ_DATA_ROOT:PATH='path/to/the/data/directory' -DBUILDNAME:STRING='name_of_the_build'
Packit Service 679f35
make
Packit Service 679f35
make Experimental
Packit Service 679f35
```
Packit Service 679f35
Note : test data is available on the following github repo: https://github.com/uclouvain/openjpeg-data
Packit Service 679f35
Packit Service 679f35
If '-DOPJ\_DATA\_ROOT:PATH' option is omitted, test files will be automatically searched in '${CMAKE\_SOURCE\_DIR}/../data'.
Packit Service 679f35
Packit Service 679f35
Note 2 : to execute the encoding test suite, kakadu binaries are needed to decode encoded image and compare it to the baseline. Kakadu binaries are freely available for non-commercial purposes at http://www.kakadusoftware.com. kdu\_expand will need to be in your PATH for cmake to find it.
Packit Service 679f35
Packit Service 679f35
Note 3 : OpenJPEG encoder and decoder (not the library itself !) depends on several libraries: png, tiff, lcms, z. If these libraries are not found on the system, they are automatically built from the versions available in the source tree. You can force the use of these embedded version with BUILD\_THIRDPARTY:BOOL=ON. On a Debian-like system you can also simply install these libraries with:
Packit Service 679f35
```
Packit Service 679f35
sudo apt-get install liblcms2-dev  libtiff-dev libpng-dev libz-dev
Packit Service 679f35
```
Packit Service 679f35
Packit Service 679f35
Note 4 : On MacOS, if it does not work, try adding the following flag to the cmake command :
Packit Service 679f35
```
Packit Service 679f35
-DCMAKE_OSX_ARCHITECTURES:STRING=i386
Packit Service 679f35
```
Packit Service 679f35
Packit Service 679f35
## MacOS (XCode) - WINDOWS (VisualStudio, etc)
Packit Service 679f35
Packit Service 679f35
You can use cmake to generate the project files for the IDE you are using (VC2010, XCode, etc).
Packit Service 679f35
Type `cmake --help` for available generators on your platform.
Packit Service 679f35
Packit Service 679f35
Examples for Windows with Visual Studio C++ compiler:
Packit Service 679f35
Packit Service 679f35
If using directly the cl compiler:
Packit Service 679f35
Packit Service 679f35
```
Packit Service 679f35
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="%USERPROFILE%" -DCMAKE_LIBRARY_PATH:path="%USERPROFILE%" -DCMAKE_INCLUDE_PATH:path="%USERPROFILE%\include" ..
Packit Service 679f35
```
Packit Service 679f35
Packit Service 679f35
To compile a 64-bit application, open 64-Bit Visual C\+\+ toolset on the command line and run cmake. For further information, please refer to: [How to: Enable a 64-Bit Visual C\+\+ Toolset on the Command Line](https://msdn.microsoft.com/en-us/library/x4d2c09s.aspx).
Packit Service 679f35
Packit Service 679f35
Packit Service 679f35
If you do not want directly use the cl compiler, you could use:
Packit Service 679f35
Packit Service 679f35
```
Packit Service 679f35
cmake -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="%USERPROFILE%" -DCMAKE_LIBRARY_PATH:path="%USERPROFILE%" -DCMAKE_INCLUDE_PATH:path="%USERPROFILE%\include" ..
Packit Service 679f35
```
Packit Service 679f35
Packit Service 679f35
To create Visual Studio solution (.sln) and project files (.vcproj / .vcxproj):
Packit Service 679f35
```
Packit Service 679f35
cmake -G "Visual Studio 14 2015" -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="%USERPROFILE%" -DCMAKE_LIBRARY_PATH:path="%USERPROFILE%" -DCMAKE_INCLUDE_PATH:path="%USERPROFILE%\include" ..
Packit Service 679f35
```
Packit Service 679f35
Packit Service 679f35
64-bit application:
Packit Service 679f35
```
Packit Service 679f35
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="%USERPROFILE%" -DCMAKE_LIBRARY_PATH:path="%USERPROFILE%" -DCMAKE_INCLUDE_PATH:path="%USERPROFILE%\include" ..
Packit Service 679f35
```
Packit Service 679f35
Packit Service 679f35
Packit Service 679f35
# Enabling CPU specific optimizations
Packit Service 679f35
Packit Service 679f35
For Intel/AMD processors, OpenJPEG implements optimizations using the SSE4.1
Packit Service 679f35
instruction set (for example, for the 9x7 inverse MCT transform) and the AVX2
Packit Service 679f35
instruction set (for example, for the 5x3 inverse discrete wavelet transform).
Packit Service 679f35
Currently, those optimizations are only available if OpenJPEG is built to
Packit Service 679f35
use those instruction sets (and the resulting binary will only run on compatible
Packit Service 679f35
CPUs)
Packit Service 679f35
Packit Service 679f35
With gcc/clang, it is possible to enable those instruction sets with the following :
Packit Service 679f35
Packit Service 679f35
```
Packit Service 679f35
cmake -DCMAKE_C_FLAGS="-O3 -msse4.1 -DNDEBUG" ..
Packit Service 679f35
```
Packit Service 679f35
Packit Service 679f35
```
Packit Service 679f35
cmake -DCMAKE_C_FLAGS="-O3 -mavx2 -DNDEBUG" ..
Packit Service 679f35
```
Packit Service 679f35
Packit Service 679f35
(AVX2 implies SSE4.1)
Packit Service 679f35
Packit Service 679f35
Or if the binary is dedicated to run on the machine where it has
Packit Service 679f35
been compiled :
Packit Service 679f35
Packit Service 679f35
```
Packit Service 679f35
cmake -DCMAKE_C_FLAGS="-O3 -march=native -DNDEBUG" ..
Packit Service 679f35
```
Packit Service 679f35
Packit Service 679f35
# Modifying OpenJPEG
Packit Service 679f35
Packit Service 679f35
Before committing changes, run:
Packit Service 679f35
```scripts/prepare-commit.sh```
Packit Service 679f35
Packit Service 679f35
# Using OpenJPEG
Packit Service 679f35
Packit Service 679f35
To use openjpeg exported cmake file, simply create your application doing:
Packit Service 679f35
Packit Service 679f35
```
Packit Service 679f35
$ cat CMakeLists.txt
Packit Service 679f35
find_package(OpenJPEG REQUIRED)
Packit Service 679f35
include_directories(${OPENJPEG_INCLUDE_DIRS})
Packit Service 679f35
add_executable(myapp myapp.c)
Packit Service 679f35
target_link_libraries(myapp ${OPENJPEG_LIBRARIES})
Packit Service 679f35
```