Compilation with Visual Studio is quite a tedious process, as support of Visual Studio among most of the third-party libraries is limited. I recommend to use MinGW/MSYS, therefore I will not document compilation with Visual Studio any further, with two exceptions:
Open a Visual Studio command shell, go to ...graphicsmagick_dir\VisualMagick\lib or lib64 and enter:
lib.exe /out:CORE_RL_magick_comb.lib CORE_RL_bzlib_.lib CORE_RL_coders_.lib CORE_RL_filters_.lib CORE_RL_jbig_.lib CORE_RL_jp2_.lib CORE_RL_jpeg_.lib CORE_RL_lcms_.lib CORE_RL_libxml_.lib CORE_RL_magick_.lib CORE_RL_png_.lib CORE_RL_tiff_.lib CORE_RL_ttf_.lib CORE_RL_wmf_.lib CORE_RL_xlib_.lib CORE_RL_zlib_.lib /REMOVE:..\Release\CORE_bzlib\bzlib.res /REMOVE:..\Release\CORE_jbig\jbig.res /REMOVE:..\Release\CORE_jpeg\jpeg.res /REMOVE:..\Release\CORE_png\png.res /REMOVE:..\Release\CORE_tiff\tiff.res /REMOVE:..\Release\CORE_ttf\ttf.res /REMOVE:..\Release\CORE_zlib\zlib.res
lib.exe /out:CORE_DB_magick_comb.lib CORE_DB_bzlib_.lib CORE_DB_coders_.lib CORE_DB_filters_.lib CORE_DB_jbig_.lib CORE_DB_jp2_.lib CORE_DB_jpeg_.lib CORE_DB_lcms_.lib CORE_DB_libxml_.lib CORE_DB_magick_.lib CORE_DB_png_.lib CORE_DB_tiff_.lib CORE_DB_ttf_.lib CORE_DB_wmf_.lib CORE_DB_xlib_.lib CORE_DB_zlib_.lib /REMOVE:..\Debug\CORE_bzlib\bzlib.res /REMOVE:..\Debug\CORE_jbig\jbig.res /REMOVE:..\Debug\CORE_jpeg\jpeg.res /REMOVE:..\Debug\CORE_png\png.res /REMOVE:..\Debug\CORE_tiff\tiff.res /REMOVE:..\Debug\CORE_ttf\ttf.res /REMOVE:..\Debug\CORE_zlib\zlib.res
Then, link to CORE_RL_magick_comb.lib, CORE_RL_wand_.lib and CORE_RL_Magick++_.lib.
I recommend the MinGW-distribution called TDM-GCC, downloadable from here. I used 4.7.1 because with 4.8.1 OpenCV did not compile with it (memory exhausted). Install MSYS (for example from the MinGW-Builds Project) as explained here in the chapter "After Installing You Should ...".
The following lists the commands I use to configure the individual third-party libraries. You can use these commands as hints for your own build experiments, but I do not provide support for them. I only list the configure commands, "make" and "make install" usually follow them.
export PATH=$PATH:/your_path_to_cmake/bin
export LIBSDIR=/your_path_to_installation/libs
export BUILDTOOLDIR=your_name_for_compiler, for example mingw64tdm_471
ZLIB:
cd $LIBSDIR/$BUILDTOOLDIR
mkdir zlib
cd zlib
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX=$LIBSDIR/$BUILDTOOLDIR/install your_path_to/zlib-1.2.8
LZMA (xz):
tar -xf xz-5.0.5.tar.xz
cd xz-5.0.5
./configure --prefix=$LIBSDIR/$BUILDTOOLDIR/install --build=x86_64-w64-mingw32 CFLAGS="-march=x86-64 -mtune=generic -O2"
or
./configure --prefix=$LIBSDIR/$BUILDTOOLDIR/install --build=i486-pc-mingw32 CFLAGS="-march=i486 -mtune=generic -O2"
BZIP2:
tar -xf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
Remove all chmods from the Makefile
make
make install PREFIX=$LIBSDIR/$BUILDTOOLDIR/install
JPEG:
tar -xf jpegsrc.v9a.tar.gz
cd jpeg-9a
autoheader
configure --prefix=$LIBSDIR/$BUILDTOOLDIR/install CFLAGS='-O2'
PNG:
mkdir png
cd png
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release" -DZLIB_ROOT=$LIBSDIR/$BUILDTOOLDIR/install -DCMAKE_INSTALL_PREFIX=$LIBSDIR/$BUILDTOOLDIR/install /your_path_to/libpng-1.6.10
JASPER/JPEG-2000:
unzip jasper-1.900.1.zip
cd jasper-1.900.1/
./configure --prefix=$LIBSDIR/$BUILDTOOLDIR/install CPPFLAGS=-I$LIBSDIR/$BUILDTOOLDIR/install/include LDFLAGS=-L$LIBSDIR/$BUILDTOOLDIR/install/lib
JBIG:
tar -xf /f/Download/Development/jbigkit-2.1.tar.gz
cd jbigkit-2.1
make
cp -p pbmtools/*.exe $LIBSDIR/$BUILDTOOLDIR/install/bin
cp -p libjbig/*.a $LIBSDIR/$BUILDTOOLDIR/install/lib
cp -p libjbig/*.h $LIBSDIR/$BUILDTOOLDIR/install/include
TIFF:
unzip tiff-4.0.3.zip
cd tiff-4.0.3
./configure --prefix=$LIBSDIR/$BUILDTOOLDIR/install --with-lzma-include-dir=$LIBSDIR/$BUILDTOOLDIR/install/include --with-lzma-lib-dir=$LIBSDIR/$BUILDTOOLDIR/install/lib --with-zlib-include-dir=$LIBSDIR/$BUILDTOOLDIR/install/include --with-zlib-lib-dir=$LIBSDIR/$BUILDTOOLDIR/install/lib --with-jpeg-include-dir=$LIBSDIR/$BUILDTOOLDIR/install/include --with-jpeg-lib-dir=$LIBSDIR/$BUILDTOOLDIR/install/lib
LCMS2:
tar -xf lcms2-2.6.tar.gz
cd lcms2-2.6
configure --prefix=$LIBSDIR/$BUILDTOOLDIR/install CPPFLAGS="-I$LIBSDIR/$BUILDTOOLDIR/install/include" LDFLAGS="-L$LIBSDIR/$BUILDTOOLDIR/install/lib" LIBS="-llzma -ljbig"
WebP:
tar -xf libwebp-0.4.0.tar.gz
cd libwebp-0.4.0
./configure --prefix=$LIBSDIR/$BUILDTOOLDIR/install CPPFLAGS=-I$LIBSDIR/$BUILDTOOLDIR/install/include LDFLAGS=-L$LIBSDIR/$BUILDTOOLDIR/install/lib
OpenJPEG:
tar -xf openjpeg-2.0.0.tar.gz
cd openjpeg-2.0.0
Adapt in openjpeg-2.0.0\src\bin\jp2\CMakeLists.txt:
target_link_libraries(${exe} ${OPENJPEG_LIBRARY_NAME}
${PNG_LIBNAME} ${TIFF_LIBNAME} ${LCMS_LIBNAME}
jpeg jbig lzma) <=== Add this
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release" -DBUILD_SHARED_LIBS=OFF -DZLIB_ROOT=$LIBSDIR/$BUILDTOOLDIR/install -DCMAKE_INSTALL_PREFIX=$LIBSDIR/$BUILDTOOLDIR/install -DBUILD_VIEWER=OFF -DBUILD_TESTING=OFF -DCMAKE_EXE_LINKER_FLAGS="-L$LIBSDIR/$BUILDTOOLDIR/install/lib" .
GraphicMagick:
tar -xf GraphicsMagick-1.3.19.tar.gz
cd GraphicsMagick-1.3.19
./configure --prefix=$LIBSDIR/$BUILDTOOLDIR/install --disable-installed --with-quantum-depth=16 --without-modules --disable-shared --disable-openmp CPPFLAGS="-I$LIBSDIR/$BUILDTOOLDIR/install/include" LDFLAGS=-L$LIBSDIR/$BUILDTOOLDIR/install/lib LIBS="-llzma -ljbig -ljpeg -liconv"
After installation copy headers studio.h, static.h and nt_base.h to installation path install/include/GraphicsMagick/magick/
wxWidgets:
mkdir wxWidgets-3.0.0
cd wxWidgets-3.0.0
7za x wxWidgets-3.0.0.7z
./configure CFLAGS=-Os CXXFLAGS=-Os --disable-debug --disable-shared --disable-compat28 --with-opengl --with-libjpeg=sys --with-libpng=sys --with-libtiff=sys --prefix=$LIBSDIR/$BUILDTOOLDIR/install CPPFLAGS="-I$LIBSDIR/$BUILDTOOLDIR/install/include" LDFLAGS="-L$LIBSDIR/$BUILDTOOLDIR/install/lib" LIBS=" -llzma -ljbig -ljpeg "
OpenCV:
mkdir opencv-2.4.8
cd opencv-2.4.8
Adjust modules/highgui/src/grfmt_jpeg.cpp:
//#include "precomp.hpp"
#include "cvconfig.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/internal.hpp"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <ctype.h>
#include <assert.h>
...
#if defined WIN32 && defined __GNUC__
//typedef unsigned char boolean;
//#define HAVE_BOOLEAN
#endif
//#undef FALSE
//#undef TRUE
Adjust in cmake/OpenCVCompilerOptions.cmake:
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} jbig lzma)
#set(OPENCV_EXTRA_FLAGS "-fPIC ${OPENCV_EXTRA_FLAGS}")
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release" -DENABLE_PRECOMPILED_HEADERS=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DWITH_WIN32UI=OFF -DWITH_QT=OFF -DWITH_CUDA=OFF -DWITH_CUFFT=OFF -DBUILD_ZLIB=OFF -DBUILD_PNG=OFF -DBUILD_JPEG=OFF -DBUILD_TIFF=OFF -DBUILD_JASPER=OFF -DBUILD_OPENEXR=OFF -DWITH_OPENEXR=OFF -DWITH_OPENGL=OFF -DWITH_NVCUVID=OFF -DWITH_CUBLAS=OFF -DWITH_OPENNI=OFF -DWITH_OPENMP=OFF -DEIGEN_INCLUDE_PATH=$LIBSDIR/eigen-3.2.1 -DZLIB_ROOT=$LIBSDIR/$BUILDTOOLDIR/install -DWITH_TBB=OFF -DPNG_PNG_INCLUDE_DIR=$LIBSDIR/$BUILDTOOLDIR/install/include -DPNG_LIBRARY=$LIBSDIR/$BUILDTOOLDIR/install/lib/libpng16.a -DTIFF_INCLUDE_DIR=$LIBSDIR/$BUILDTOOLDIR/install/include -DTIFF_LIBRARY=$LIBSDIR/$BUILDTOOLDIR/install/lib/libtiff.a -DJPEG_INCLUDE_DIR=$LIBSDIR/$BUILDTOOLDIR/install/include -DJPEG_LIBRARY=$LIBSDIR/$BUILDTOOLDIR/install/lib/libjpeg.a -DJASPER_INCLUDE_DIR=$LIBSDIR/$BUILDTOOLDIR/install/include -DJASPER_LIBRARIES=$LIBSDIR/$BUILDTOOLDIR/install/lib/libjasper.a -DCMAKE_INSTALL_PREFIX=$LIBSDIR/$BUILDTOOLDIR/install -DCMAKE_EXE_LINKER_FLAGS="-L$LIBSDIR/$BUILDTOOLDIR/install/lib -ljbig -llzma" $LIBSDIR/opencv/opencv-2.4.8
ABIC:
The build script for ABIC looks similar to this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|