2 © OpenShot Studios, LLC
4 SPDX-License-Identifier: LGPL-3.0-or-later
7 # Building libopenshot for Windows
11 The best way to get started with libopenshot, is to learn about our build system, obtain all the
12 source code, install a development IDE and tools, and better understand our dependencies. So,
13 please read through the following sections, and follow the instructions. And keep in mind,
14 that your computer is likely different than the one used when writing these instructions.
15 Your file paths and versions of applications might be slightly different, so keep an eye out
16 for subtle file path differences in the commands you type.
20 CMake is the backbone of our build system. It is a cross-platform build system, which
21 checks for dependencies, locates header files and libraries, generates makefiles, and
22 supports the cross-platform compiling of libopenshot and libopenshot-audio. CMake uses
23 an out-of-source build concept, where all temporary build files, such as makefiles,
24 object files, and even the final binaries, are created outside of the source code
25 folder, inside a /build/ sub-folder. This prevents the build process from cluttering
26 up the source code. These instructions have only been tested with the GNU compiler
27 (including MSYS2/MinGW for Windows).
31 The following libraries are required to build libopenshot. Instructions on how to
32 install these dependencies vary for each operating system. Libraries and Executables
33 have been labeled in the list below to help distinguish between them.
35 ### FFmpeg (libavformat, libavcodec, libavutil, libavdevice, libavresample, libswscale)
36 * http://www.ffmpeg.org/ `(Library)`
37 * This library is used to decode and encode video, audio, and image files. It is also used to obtain information about media files, such as frame rate, sample rate, aspect ratio, and other common attributes.
39 ### ImageMagick++ (libMagick++, libMagickWand, libMagickCore)
40 * http://www.imagemagick.org/script/magick++.php `(Library)`
41 * This library is **optional**, and used to decode and encode images.
43 ### OpenShot Audio Library (libopenshot-audio)
44 * https://github.com/OpenShot/libopenshot-audio/ `(Library)`
45 * This library is used to mix, resample, host plug-ins, and play audio. It is based on the JUCE project, which is an outstanding audio library used by many different applications
48 * http://www.qt.io/qt5/ `(Library)`
49 * Qt5 is used to display video, store image data, composite images, apply image effects, and many other utility functions, such as file system manipulation, high resolution timers, etc...
52 * http://www.cmake.org/ `(Executable)`
53 * This executable is used to automate the generation of Makefiles, check for dependencies, and is the backbone of libopenshot’s cross-platform build process.
56 * http://www.swig.org/ `(Executable)`
57 * This executable is used to generate the Python and Ruby bindings for libopenshot. It is a simple and powerful wrapper for C++ libraries, and supports many languages.
59 ### Python 3 (libpython)
60 * http://www.python.org/ `(Executable and Library)`
61 * This library is used by swig to create the Python (version 3+) bindings for libopenshot. This is also the official language used by OpenShot Video Editor (a graphical interface to libopenshot).
64 * http://www.stack.nl/~dimitri/doxygen/ `(Executable)`
65 * This executable is used to auto-generate the documentation used by libopenshot.
67 ### UnitTest++ (libunittest++)
68 * https://github.com/unittest-cpp/ `(Library)`
69 * This library is used to execute unit tests for libopenshot. It contains many macros used to keep our unit testing code very clean and simple.
72 * http://zeromq.org/ `(Library)`
73 * This library is used to communicate between libopenshot and other applications (publisher / subscriber). Primarily used to send debug data from libopenshot.
76 * http://openmp.org/wp/ `(Compiler Flag)`
77 * If your compiler supports this flag (GCC, Clang, and most other compilers), it provides libopenshot with easy methods of using parallel programming techniques to improve performance and take advantage of multi-core processors.
79 ## CMake Flags (Optional)
80 There are many different build flags that can be passed to cmake to adjust how libopenshot
81 is compiled. Some of these flags might be required when compiling on certain OSes, just
82 depending on how your build environment is setup. To add a build flag, follow this general
83 syntax: `cmake -DMAGICKCORE_HDRI_ENABLE=1 -DENABLE_TESTS=1 ../`
85 * MAGICKCORE_HDRI_ENABLE (default 0)
86 * MAGICKCORE_QUANTUM_DEPTH (default 0)
87 * OPENSHOT_IMAGEMAGICK_COMPATIBILITY (default 0)
88 * DISABLE_TESTS (default 0)
89 * CMAKE_PREFIX_PATH (`/location/to/missing/library/`)
90 * PYTHON_INCLUDE_DIR (`/location/to/python/include/`)
91 * PYTHON_LIBRARY (`/location/to/python/lib.a`)
92 * PYTHON_FRAMEWORKS (`/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/`)
93 * CMAKE_CXX_COMPILER (`/location/to/mingw/g++`)
94 * CMAKE_C_COMPILER (`/location/to/mingw/gcc`)
96 ## Environment Variables
98 Many environment variables will need to be set during this Windows installation guide.
99 The command line will need to be closed and re-launched after any changes to your environment
100 variables. Also, dependency libraries will not be found during linking or execution without
101 being found in the PATH environment variable. So, if you get errors related to missing
102 commands or libraries, double check the PATH variable.
104 The following environment variables need to be added to your “System Variables”. Be sure to
105 check each folder path for accuracy, as your paths will likely be different than this list.
107 ### Example Variables
109 * DL_DIR (`C:\libdl`)
110 * DXSDK_DIR (`C:\Program Files\Microsoft DirectX SDK (June 2010)\`)
111 * FFMPEGDIR (`C:\ffmpeg-git-95f163b-win32-dev`)
112 * FREETYPE_DIR (`C:\Program Files\GnuWin32`)
113 * HOME (`C:\msys\1.0\home`)
114 * LIBOPENSHOT_AUDIO_DIR (`C:\Program Files\libopenshot-audio`)
116 * SNDFILE_DIR (`C:\Program Files\libsndfile`)
117 * UNITTEST_DIR (`C:\UnitTest++`)
118 * ZMQDIR (`C:\msys2\usr\local\`)
119 * PATH (`The following paths are an example`)
120 * `C:\Qt5\bin; C:\Qt5\MinGW\bin\; C:\msys\1.0\local\lib; C:\Program Files\CMake 2.8\bin; C:\UnitTest++\build; C:\libopenshot\build\src; C:\Program Files\doxygen\bin; C:\ffmpeg-git-95f163b-win32-dev\lib; C:\swigwin-2.0.4; C:\Python33; C:\Program Files\Project\lib; C:\msys2\usr\local\`
126 ## Obtaining Source Code
128 The first step in installing libopenshot is to obtain the most recent source code. The source code
129 is available on [GitHub](https://github.com/OpenShot/libopenshot). Use the following command to
130 obtain the latest libopenshot source code.
133 git clone https://github.com/OpenShot/libopenshot.git
134 git clone https://github.com/OpenShot/libopenshot-audio.git
137 ## Folder Structure (libopenshot)
139 The source code is divided up into the following folders.
142 * This folder needs to be manually created, and is used by cmake to store the temporary
143 build files, such as makefiles, as well as the final binaries (library and test executables).
146 * This folder contains custom modules not included by default in cmake, used to find
147 dependency libraries and headers and determine if these libraries are installed.
150 * This folder contains documentation and related files, such as logos and images
151 required by the doxygen auto-generated documentation.
154 * This folder contains all headers (*.h) used by libopenshot.
157 * This folder contains all source code (*.cpp) used by libopenshot.
160 * This folder contains all unit test code. Each class has it’s own test file (*.cpp), and
161 uses UnitTest++ macros to keep the test code simple and manageable.
164 * This folder contains code not written by the OpenShot team. For example, jsoncpp, an
165 open-source JSON parser.
167 ## Install MSYS2 Dependencies
169 Most Windows dependencies needed for libopenshot-audio, libopenshot, and openshot-qt
170 can be installed easily with MSYS2 and the pacman package manager. Follow these
171 directions to setup a Windows build environment for OpenShot.
173 1) Install MSYS2: http://www.msys2.org/
175 2) Run MSYS2 command prompt (for example: `C:\msys64\msys2_shell.cmd`)
177 3) Append PATH (so MSYS2 can find executables and libraries):
180 PATH=$PATH:/c/msys64/mingw64/bin:/c/msys64/mingw64/lib (64-bit PATH)
182 PATH=$PATH:/c/msys32/mingw32/bin:/c/msys32/mingw32/lib (32-bit PATH)
185 4) Update and upgrade all packages
191 5a) Install the following packages (**64-Bit**)
194 pacman -S --needed base-devel mingw-w64-x86_64-toolchain
195 pacman -S mingw64/mingw-w64-x86_64-ffmpeg
196 pacman -S mingw64/mingw-w64-x86_64-qt5
197 pacman -S mingw64/mingw-w64-x86_64-python3-pyqt5
198 pacman -S mingw64/mingw-w64-x86_64-swig
199 pacman -S mingw64/mingw-w64-x86_64-cmake
200 pacman -S mingw64/mingw-w64-x86_64-doxygen
201 pacman -S mingw64/mingw-w64-x86_64-python3-pip
202 pacman -S mingw32/mingw-w64-i686-zeromq
203 pacman -S mingw64/mingw-w64-x86_64-python3-pyzmq
204 pacman -S mingw64/mingw-w64-x86_64-python3-cx_Freeze
205 pacman -S mingw64/mingw-w64-x86_64-ninja
206 pacman -S mingw64/mingw-w64-x86_64-catch
207 pacman -S mingw-w64-x86_64-python3-pyopengl
208 pacman -S mingw-w64-clang-x86_64-python-pyopengl-accelerate
209 pacman -S mingw-w64-x86_64-python-pyopengl-accelerate
210 pacman -S mingw-w64-x86_64-python-pywin32
213 # Install ImageMagick if needed (OPTIONAL and NOT NEEDED)
214 pacman -S mingw64/mingw-w64-x86_64-imagemagick
217 5b) **Or** Install the following packages (**32-Bit**)
220 pacman -S --needed base-devel mingw32/mingw-w64-i686-toolchain
221 pacman -S mingw32/mingw-w64-i686-ffmpeg
222 pacman -S mingw32/mingw-w64-i686-qt5
223 pacman -S mingw32/mingw-w64-i686-python3-pyqt5
224 pacman -S mingw32/mingw-w64-i686-swig
225 pacman -S mingw32/mingw-w64-i686-cmake
226 pacman -S mingw32/mingw-w64-i686-doxygen
227 pacman -S mingw32/mingw-w64-i686-python3-pip
228 pacman -S mingw32/mingw-w64-i686-zeromq
229 pacman -S mingw32/mingw-w64-i686-python3-pyzmq
230 pacman -S mingw32/mingw-w64-i686-python3-cx_Freeze
231 pacman -S mingw32/mingw-w64-i686-ninja
232 pacman -S mingw32/mingw-w64-i686-catch
233 pacman -S mingw-w64-i686-python-pyopengl
234 pacman -S mingw-w64-i686-python-pyopengl-accelerate
235 pacman -S mingw-w64-i686-python-pywin32
238 # Install ImageMagick if needed (OPTIONAL and NOT NEEDED)
239 pacman -S mingw32/mingw-w32-x86_32-imagemagick
242 6) Install Python PIP Dependencies
245 pip3 install httplib2
248 pip3 install github3.py
249 pip3 install requests
251 pip3 install PyOpenGL
252 pip3 install PyOpenGL-accelerate
255 7) Download Unittest++ (https://github.com/unittest-cpp/unittest-cpp) into /MSYS2/[USER]/unittest-cpp-master/
258 cmake -G "MSYS Makefiles" ../ -DCMAKE_MAKE_PROGRAM=mingw32-make -DCMAKE_INSTALL_PREFIX:PATH=/usr
262 8) Install babl pixel encoding and color space conversion engine (https://gegl.org/babl/)
265 git clone https://gitlab.gnome.org/GNOME/babl.git
267 meson build --prefix=C:/msys64/mingw64 (or `--prefix=C:/msys64/mingw32` for a 32 bit build)
272 9) Install opencv (used for AI and computer vision effects)
274 Note: Had to edit 1 header file and add a missing typedef: `typedef unsigned int uint;`
277 git clone https://github.com/opencv/opencv
281 git clone https://github.com/opencv/opencv_contrib
288 cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_TBB=OFF -D WITH_QT=ON -D WITH_OPENGL=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -D OPENCV_GENERATE_PKGCONFIG=ON -D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=ON -G "MSYS Makefiles" ..
289 make -j4 -i (-i ignores errors on MSYS2 which happens for some reason)
293 10) Install ReSVG (SVG rasterizing)
296 git clone https://github.com/RazrFalcon/resvg
298 QT_DIR="C:\\msys64\\mingw64\\" cargo build --verbose --release
300 QT_DIR="C:\\msys64\\mingw32\\" cargo build --verbose --release
304 # copy all required files into the system directories
305 cp target/release/resvg.dll /usr/lib/
306 mkdir -p /usr/include/resvg/
307 cp c-api/*.h /usr/include/resvg/
310 11) ZMQ++ Header (This might not be needed anymore)
311 NOTE: Download and copy zmq.hpp into the /c/msys64/mingw64/include/ folder
313 ## Manual Dependencies
316 * https://github.com/dlfcn-win32/dlfcn-win32
317 * Download and Extract the Win32 Static (.tar.bz2) archive to a local folder: `C:\libdl\`
318 * Create an environment variable called DL_DIR and set the value to `C:\libdl\`. This environment variable will be used by CMake to find the binary and header file.
320 ### DirectX SDK / Windows SDK
321 * Windows 7: (DirectX SDK) http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=6812
322 * Windows 8: (Windows SDK)
323 * https://msdn.microsoft.com/en-us/windows/desktop/aa904949
324 * Download and Install the SDK Setup program. This is needed for the JUCE library to play audio on Windows.
325 Create an environment variable called DXSDK_DIR and set the value to `C:\Program Files\Microsoft DirectX SDK (June 2010)\` (your path might be different). This environment variable will be used by CMake to find the binaries and header files.
328 * http://www.mega-nerd.com/libsndfile/#Download
329 * Download and Install the Win32 Setup program.
330 * Create an environment variable called SNDFILE_DIR and set the value to `C:\Program Files\libsndfile`. This environment variable will be used by CMake to find the binary and header files.
333 * http://zeromq.org/intro:get-the-software
334 * Download source code (zip)
335 * Follow their instructions, and build with mingw
336 * Create an environment variable called ZMQDIR and set the value to `C:\libzmq\build\` (the location of the compiled version). This environment variable will be used by CMake to find the binary and header files.
338 ## Windows Build Instructions (libopenshot-audio)
339 In order to compile libopenshot-audio, launch a command prompt and enter the following commands. This does not require the MSYS2 prompt, but it should work in both the Windows command prompt and the MSYS2 prompt.
342 cd [libopenshot-audio repo folder]
345 cmake -G “MinGW Makefiles” ../
348 openshot-audio-test-sound (This should play a test sound)
351 ## Windows Build Instructions (libopenshot)
352 Run the following commands to build libopenshot:
355 cd [libopenshot repo folder]
358 cmake -G "MinGW Makefiles" -DPYTHON_INCLUDE_DIR="C:/Python34/include/" -DPYTHON_LIBRARY="C:/Python34/libs/libpython34.a" ../
362 If you are missing any dependencies for libopenshot, you will receive error messages at this point.
363 Just install the missing dependencies, and run the above commands again. Repeat until no error
364 messages are displayed and the build process completes.
366 Also, if you are having trouble building, please see the CMake Flags section above, as
367 it might provide a solution for finding a missing folder path, missing Python 3 library, etc...
369 To run all unit tests (and verify everything is working correctly), launch a terminal, and enter:
375 To auto-generate the documentation for libopenshot, launch a terminal, and enter:
381 This will use doxygen to generate a folder of HTML files, with all classes and methods
382 documented. The folder is located at build/doc/html/. Once libopenshot has been successfully
383 built, we need to install it (i.e. copy it to the correct folder, so other libraries can find it).
389 This should copy the binary files to `C:\Program Files\openshot\lib\`, and the header
390 files to `C:\Program Files\openshot\include\...` This is where other projects will
391 look for the libopenshot files when building.. Python 3 bindings are also installed
392 at this point. let's verify the python bindings work:
399 If no errors are displayed, you have successfully compiled and installed libopenshot on
400 your system. Congratulations and be sure to read our wiki on [Becoming an OpenShot Developer](https://github.com/OpenShot/openshot-qt/wiki/Become-a-Developer)!
401 Welcome to the OpenShot developer community! We look forward to meeting you!