2 # OpenJPEG installation
4 The build method maintained by OpenJPEG is [CMake](https://cmake.org/).
6 ## UNIX/LINUX - MacOS (terminal) - WINDOWS (cygwin, MinGW)
8 To build the library, type from source tree directory:
12 cmake .. -DCMAKE_BUILD_TYPE=Release
15 Binaries are then located in the 'bin' directory.
17 To install the library, type with root privileges:
23 To build the html documentation, you need doxygen to be installed on your system.
24 It will create an "html" directory in TOP\_LEVEL/build/doc)
29 Main available cmake flags:
30 * To specify the install path: '-DCMAKE\_INSTALL\_PREFIX=/path'
31 * To build the shared libraries and links the executables against it: '-DBUILD\_SHARED\_LIBS:bool=on' (default: 'ON')
32 > Note: when using this option, static libraries are not built and executables are dynamically linked.
33 * To build the CODEC executables: '-DBUILD\_CODEC:bool=on' (default: 'ON')
34 * To build opjstyle (internal version of astyle) for OpenJPEG development: '-DWITH_ASTYLE=ON'
35 * [OBSOLETE] To build the MJ2 executables: '-DBUILD\_MJ2:bool=on' (default: 'OFF')
36 * [OBSOLETE] To build the JPWL executables and JPWL library: '-DBUILD\_JPWL:bool=on' (default: 'OFF')
37 * [OBSOLETE] To build the JPIP client (java compiler recommended) library and executables: '-DBUILD\_JPIP:bool=on' (default: 'OFF')
38 * [OBSOLETE] To build the JPIP server (need fcgi) library and executables: '-DBUILD\_JPIP\_SERVER:bool=on' (default: 'OFF')
39 * To enable testing (and automatic result upload to http://my.cdash.org/index.php?project=OPENJPEG):
41 cmake . -DBUILD_TESTING:BOOL=ON -DOPJ_DATA_ROOT:PATH='path/to/the/data/directory' -DBUILDNAME:STRING='name_of_the_build'
45 Note : test data is available on the following github repo: https://github.com/uclouvain/openjpeg-data
47 If '-DOPJ\_DATA\_ROOT:PATH' option is omitted, test files will be automatically searched in '${CMAKE\_SOURCE\_DIR}/../data'.
49 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.
51 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:
53 sudo apt-get install liblcms2-dev libtiff-dev libpng-dev libz-dev
56 Note 4 : On MacOS, if it does not work, try adding the following flag to the cmake command :
58 -DCMAKE_OSX_ARCHITECTURES:STRING=i386
61 ## MacOS (XCode) - WINDOWS (VisualStudio, etc)
63 You can use cmake to generate the project files for the IDE you are using (VC2010, XCode, etc).
64 Type 'cmake --help' for available generators on your platform.
66 Examples for Windows with Visual Studio C++ compiler:
68 If using directly the cl compiler:
71 cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="C:/Users/Public" -DCMAKE_LIBRARY_PATH:path="C:/Users/Public" -DCMAKE_INCLUDE_PATH:path="C:/Users/Public/include" ..
74 If you do not want directly use the cl compiler, you could use:
77 cmake -DCMAKE_BUILD_TYPE:string="Release" -DBUILD_SHARED_LIBS:bool=on -DCMAKE_INSTALL_PREFIX:path="C:/Users/Public" -DCMAKE_LIBRARY_PATH:path="C:/Users/Public" -DCMAKE_INCLUDE_PATH:path="C:/Users/Public/include" ..
80 # Enabling CPU specific optimizations
82 For Intel/AMD processors, OpenJPEG implements optimizations using the SSE4.1
83 instruction set (for example, for the 9x7 inverse MCT transform) and the AVX2
84 instruction set (for example, for the 5x3 inverse discrete wavelet transform).
85 Currently, those optimizations are only available if OpenJPEG is built to
86 use those instruction sets (and the resulting binary will only run on compatible
89 With gcc/clang, it is possible to enable those instruction sets with the following :
91 cmake -DCMAKE_C_FLAGS="-O3 -msse4.1 -DNDEBUG" ..
93 cmake -DCMAKE_C_FLAGS="-O3 -mavx2 -DNDEBUG" ..
97 Or if the binary is dedicated to run on the machine where it has
100 cmake -DCMAKE_C_FLAGS="-O3 -march=native -DNDEBUG" ..
104 Before committing changes, run:
105 scripts/prepare-commit.sh
109 To use openjpeg exported cmake file, simply create your application doing:
113 find_package(OpenJPEG REQUIRED)
114 include_directories(${OPENJPEG_INCLUDE_DIRS})
115 add_executable(myapp myapp.c)
116 target_link_libraries(myapp ${OPENJPEG_LIBRARIES})