• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H21-Oct-2021-1,2741,088

ci/H21-Oct-2021-303232

cmake/H03-May-2022-3,8803,111

contrib/H21-Oct-2021-17,28616,487

doc/H03-May-2022-6,2375,253

fuzz/H03-May-2022-593529

include/exiv2/H03-May-2022-13,4814,146

man/man1/H21-Oct-2021-813783

po/H03-May-2022-526,918417,214

releasenotes/H03-May-2022-

samples/H03-May-2022-8,2755,949

src/H03-May-2022-74,17656,870

test/H03-May-2022-17,94616,726

tests/H03-May-2022-15,02512,053

unitTests/H03-May-2022-2,0751,303

xmpsdk/H03-May-2022-27,04915,209

.clang-format.optionalH A D21-Oct-2021540 2924

.gitignoreH A D21-Oct-2021268 2626

.gitlab-ci.ymlH A D21-Oct-20212.4 KiB10087

.mergify.ymlH A D21-Oct-2021485 2421

.travis.ymlH A D21-Oct-20212.3 KiB11094

AUTHORSH A D21-Oct-202171 21

CODING_GUIDELINES.mdH A D21-Oct-20214.4 KiB6045

CONTRIBUTING.mdH A D21-Oct-20217.8 KiB14693

COPYINGH A D21-Oct-202117.6 KiB341281

GIT_GUIDELINES.mdH A D21-Oct-202110.1 KiB275223

README-CONAN.mdH A D21-Oct-202122.9 KiB577438

README-SAMPLES.mdH A D21-Oct-202121.5 KiB659441

README.mdH A D21-Oct-202149.6 KiB1,263917

SECURITY.mdH A D21-Oct-20212.8 KiB4027

WORK-IN-PROGRESSH A D21-Oct-202116.2 KiB346269

appveyor.ymlH A D21-Oct-20213.3 KiB8780

appveyor_mingw_cygwin.ymlH A D21-Oct-20213 KiB6558

codecov.ymlH A D21-Oct-202168 32

conanfile.pyH A D21-Oct-20212.2 KiB5643

README-CONAN.md

1| Travis        | AppVeyor      | GitLab| Codecov| Repology| Chat |
2|:-------------:|:-------------:|:-----:|:------:|:-------:|:----:|
3| [![Build Status](https://travis-ci.org/Exiv2/exiv2.svg?branch=0.27-maintenance)](https://travis-ci.org/Exiv2/exiv2) | [![Build status](https://ci.appveyor.com/api/projects/status/d6vxf2n0cp3v88al/branch/0.27-maintenance?svg=true)](https://ci.appveyor.com/project/piponazo/exiv2-wutfp/branch/0.27-maintenance) | [![pipeline status](https://gitlab.com/D4N/exiv2/badges/0.27-maintenance/pipeline.svg)](https://gitlab.com/D4N/exiv2/commits/0.27-maintenance) | [![codecov](https://codecov.io/gh/Exiv2/exiv2/branch/0.27-maintenance/graph/badge.svg)](https://codecov.io/gh/Exiv2/exiv2) | [![Packaging status](https://repology.org/badge/tiny-repos/exiv2.svg)](https://repology.org/metapackage/exiv2/versions) | [![#exiv2-chat on matrix.org](matrix-standard-vector-logo-xs.png)](https://matrix.to/#/#exiv2-chat:matrix.org) |
4
5![Exiv2](exiv2.png)
6
7# Building Exiv2 and dependencies with conan
8
9Conan is a portable package manager for C/C++ libraries. It can be used to create all  dependencies needed to build Exiv2, without needing to install system packages.
10
11This document provides a step-by-step guide to show you the basic usage of conan. For more details about the tool,
12please visit the [Conan documentation website](http://docs.conan.io/en/latest/).
13
14Although we provide step-by-step instructions to enable you to build Exiv2 with conan, we recommend that you read conan's documentation to understand the main concepts: [Getting started with Conan](http://docs.conan.io/en/latest/getting_started.html)
15
16To build Exiv2 with conan, you will also need to install CMake.  https://cmake.org/download/
17
18_**We do not recommend using conan on MinGW, Cygwin, Unix or to cross compile from Linux to those platforms.**<br>
19The build procedures for those platforms are discussed here: See [README.md](README.md)_
20
21<name id="TOC"></a>
22----
23### TABLE OF CONTENTS
24
251. [Step by Step Guide](#1)
26    1. [Install conan](#1-1)
27    2. [Test conan installation](#1-2)
28    3. [Create a build directory](#1-3)
29    4. [Build dependencies, create build environment, build and test](#1-4)
302. [Platform Notes](#2)
31    1. [Linux Notes](#2-1)
32    2. [Visual Studio Notes](#2-2)
333. [Conan Architecture](#3)
34    1. [conanfile.py](#3-1)
35    2. [Conan Recipes](#3-2)
36    3. [Conan server search path](#3-3)
37    4. [Configuring conan on your machine](#3-4)
384. [Building Exiv2 with Adobe XMPsdk 2016](#4)
39    1. [Add a remote directory to conan's recipe search path](#4-1)
40    2. [Build dependencies and install conan artefacts in your build directory](#4-2)
41    3. [Execute cmake to generate build files for your environment](#4-3)
42    4. [Build Exiv2 and link Adobe XMPsdk library](#4-4)
435. [Webready Support](#5)
44
45<name id="1"></a>
46----
47
48# 1 Step by Step Guide
49
50<name id="1-1"></a>
51##### 1.1) </a>Install conan:
52
53```bash
54$ pip install conan
55```
56For other installation methods (brew, installers, from sources), visit this [link]([install
57conan](http://docs.conan.io/en/latest/installation.html)).
58
59To upgrade the version of conan:
60
61```bash
62$ pip install conan --upgrade
63```
64
65<name id="1-2"></a>
66##### 1.2) Test conan installation
67
68```bash
69$ conan --version
70Conan version 1.23.0
71```
72
73<name id="1-3"></a>
74##### 1.3) Create a build directory<name id="1-3"></a>
75
76Create a build directory and run the conan commands:
77
78```bash
79$ mkdir build
80$ cd build
81$ conan profile list
82```
83_**Visual Studio Users**_
84
85_The profile msvc2019Release96 in `%USERPROFILE%\.conan\profiles\msvc2019Release64` is:_
86
87```ini
88[build_requires]
89[settings]
90arch=x86_64
91build_type=Release
92compiler=Visual Studio
93compiler.runtime=MD
94compiler.version=16
95os=Windows
96arch_build=x86_64
97os_build=Windows
98[options]
99[env]
100```
101
102_Profiles for Visual Studio are discussed in detail here: [Visual Studio Notes](#2-2)__
103
104<name id="1-4"></a>
105##### 1.4) Build dependencies, create build environment, build and test</a>
106
107
108|         | Build Steps   | Linux and macOS                | Visual Studio |
109|:--      |:--------------|--------------------------------|------------------------------|
110| _**1**_ | Get conan to fetch dependencies<br><br>The output can be quite<br>long as conan downloads and/or builds<br>zlib, expat, curl and other dependencies.| $ conan install ..<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--build missing       | c:\\..\\build> conan install .. --build missing<br>&nbsp;&nbsp;&nbsp;&nbsp;--profile msvc2019Release64 |
111| _**2**_ | Get cmake to generate<br>makefiles or sln/vcxproj | $ cmake ..  | c:\\..\\build> cmake&nbsp;..&nbsp;-G&nbsp;"Visual Studio 16 2019"
112| _**3**_ | Build                                             | $ cmake --build .       | c:\\..\\build>&nbsp;cmake&nbsp;--build&nbsp;.&nbsp;--config&nbsp;Release<br>You may prefer to open exiv2.sln and build using the IDE. |
113| _**4**_ | Optionally Run Test Suite                         | $ make tests            | c:\\..\\build>&nbsp;cmake&nbsp;--build&nbsp;.&nbsp;--config&nbsp;Release --target tests<br/>[README.md](README.md) |
114
115
116
117[TOC](#TOC)
118<name id="2"></a>
119## 2) Platform Notes
120
121<name id="2-1"></a>
122### 2.1) Linux Notes
123
124##### Default Profile
125
126When you run conan install for the first time, it will detect and write the default profile ~/.conan/profile/default.  On my Ubuntu system with GCC 4.9, this is:
127
128```ini
129[settings]
130os=Linux
131os_build=Linux
132arch=x86_64
133arch_build=x86_64
134compiler=gcc
135compiler.version=4.9
136compiler.libcxx=libstdc++
137build_type=Release
138[options]
139[build_requires]
140[env]
141```
142
143##### Changing profile settings
144
145One of the most important **profile** settings to be adjusted in your conan profile when working on Linux is the field:
146
147```bash
148compiler.libcxx=libstdc++11  # Possible values: libstdc++, libstdc++11, libc++
149```
150With the arrival of the c++11 standard, and the growing popularity of the *clang* compiler, it is increasingly important which version of the standard library to use (corresponds to the `-stdlib` compiler flag).
151
152Recommended **libcxx**
153settings works with conan and different compilers:
154
155```bash
156compiler.libcxx=libstdc++11  # will use -stdlib=libstdc++ and define _GLIBCXX_USE_CXX11_ABI=1
157compiler.libcxx=libstdc++    # will use -stdlib=libstdc++ and define _GLIBCXX_USE_CXX11_ABI=0
158compiler.libcxx=libc++       # will use -stdlib=libc++
159```
160
161As a rule of thumb, set `compiler.libcxx=libstdc++11` when using a version of gcc >= 5.1.
162
163More information about the standard library and GCC [dual ABI in gcc](https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html) with GCC works.
164
165Please, be aware that normally when using gcc >= 5.1, \_GLIBCXX\_USE\_CXX11\_ABI is set to 1 by default. However some linux
166distributions might set that definition to 0 by default. In case you get linking errors about standard c++ containers or
167algorithms when bringing the Exiv2 dependencies with conan, this might indicate a mismatch between the value set in
168**compiler.libcxx** and the default values used in your distribution.
169
170[TOC](#TOC)
171<name id="2-2"></a>
172### 2.2) Visual Studio Notes
173
174We recommend that you install python as discussed here:  [https://github.com/Exiv2/exiv2/pull/1403#issuecomment-731836146](https://github.com/Exiv2/exiv2/pull/1403#issuecomment-731836146)
175
176### Profiles for Visual Studio
177
178Exiv2 v0.27 can be built with VS 2008, 2010, 2012, 2013, 2015 , 2017 and 2019.
179
180Exiv2 v0.28 is being "modernised" to C++11 and will not support C++98.
181We don't expect Exiv2 v0.28 to build with VS versions earlier than VS 2015.
182
183You create profiles in %HOMEPATH%\.conan\profiles with a text editor.  For your convenience, you'll find profiles in `<exiv2dir>\cmake\msvc_conan_profiles`.
184
185```
186Profile :=    msvc{Edition}{Type}{Bits}
187Edition :=  { 2019    | 2017  |  2015  }
188Type    :=  { Release | Debug }
189Bits    :=  { 64      | 32    }
190Examples:     msvc2019Release64 msvc2017Release32  msvc2015Debug32
191```
192
193The profile msvc2019Release64 is as follows:
194
195```ini
196[build_requires]
197[settings]
198arch=x86_64
199build_type=Release
200compiler=Visual Studio
201compiler.runtime=MD
202compiler.version=16
203os=Windows
204arch_build=x86_64
205os_build=Windows
206[options]
207[env]
208```
209
210### Tools for Visual Studio 2019
211
212You will need cmake version 3.14 (and up) and conan 1.14 (and up).
213
214Additionally, when I upgraded to conan 1.14.3, I had to manually update the file `settings.yml` as follows. For me: `%USERPROFILE% == C:\Users\rmills`:
215
216```bat
217copy/y %USERPROFILE%\.conan\settings.yml.new %USERPROFILE%\.conan\settings.yml
218```
219
220### CMake Generators for Visual Studio
221
222In the step-by-step guide, the command `$ cmake ..` uses
223the default CMake generator.  Always use the generator for your version of Visual Studio.  For example:
224
225```bat
226c:\..\build> conan install .. --build missing --profile msvc2019Release64
227c:\..\build> cmake         .. -G "Visual Studio 16 2019" -A x64
228c:\..\build> cmake --build .  --config Release
229```
230
231CMake provides Generators for different editions of Visual Studio.  The 64 and 32 bit Generators have different names:
232
233| Architecture | Visual Studio 2019 | Visual Studio 2017 | Visual Studio 2015 |
234|:---------    |--------------------|--------------------|--------------------|--------------------|
235| 64 bit       | -G "Visual Studio 16 2019" -A x64          | -G "Visual Studio 15 2017 Win64" | -G "Visual Studio 14 2015 Win64"     |
236| 32 bit       | -G "Visual Studio 16 2019" -A Win32        | -G "Visual Studio 15 2017"       | -G "Visual Studio 14 2015"           |
237
238### Recommended settings for Visual Studio
239
240##### 64 bit Release Build
241
242| | Visual Studio 2019 | Visual Studio 2017 | Visual Studio 2015|
243|:---------|--------------------|--------------------|--------------|
244| _**conan install .. --profile**_ | msvc2019Release64 | msvc2017Release64 | msvc2015Release64 |
245| _**cmake**_                   |  -G "Visual Studio 16 2019" -A x64   |  -G "Visual Studio 15 2017 Win64"    | -G "Visual Studio 14 2015 Win64" |
246| _**profile**_<br><br><br><br><br><br><br>_ | arch=x86\_64<br>arch\_build=x86\_64<br>build\_type=Release<br>compiler.runtime=MD<br>compiler.version=16<br>compiler=Visual Studio<br>os=Windows<br>os\_build=Windows  | arch=x86\_64<br>arch\_build=x86\_64<br>build\_type=Release<br>compiler.runtime=MD<br>compiler.version=15<br>compiler=Visual Studio<br>os=Windows<br>os\_build=Windows  | arch=x86\_64<br>arch\_build=x86\_64<br>build\_type=Release<br>compiler.runtime=MD<br>compiler.version=14 <br>compiler=Visual Studio<br>os=Windows<br>os\_build=Windows |
247
248##### Debug Builds
249
250|| Visual Studio 2019 | Visual Studio 2017 | Visual Studio 2015 |
251|:-------|-------|------|--------------|
252| _**conan install .. --profile**_ | msvc2019Debug64 | msvc2017Debug64 | msvc2015Debug64 |
253| _**profile**_<br>_ | build\_type=Debug<br>compiler.runtime=MDd | build\_type=Debug<br>compiler.runtime=MDd | build_type=Debug<br>compiler.runtime=MDd |
254
255##### 32bit Builds
256
257|| Visual Studio 2019 | Visual Studio 2017 | Visual Studio 2015 |
258|:-----------|--------------------|--------------------|--------------------|
259| _**conan install .. --profile**_ | msvc2019Release32 | msvc2017Release32 | msvc2015Release32 |
260| _**cmake**_ | -G "Visual Studio 16 2019" -A Win32 | -G "Visual Studio 15 2017" | -G "Visual Studio 14 2015" |
261| _**profile**_<br>_ | arch=x86<br>arch\_build=x86 | arch=x86<br>arch\_build=x86 | arch=x86<br>arch\_build=x86 |
262
263##### Static Builds
264
265The default builds of Exiv2 and sample applications build and use DLLs.
266
267To build static libraries, use the cmake option `-DBUILD_SHARED_LIBS=Off`.  You will probably also want to use the static run-time.  The default is to use the dynamic run-time library.
268
269```bash
270$ cmake .. -DBUILD_SHARED_LIBS=Off -DEXIV2_ENABLE_DYNAMIC_RUNTIME=Off
271```
272
273If you wish to use the static C run-time library, use the following option in the conan profile.
274
275|                      | Static Release      | Static Debug |
276|:---                  |:---------           |:-------------------|
277| **profile setting**  | compiler.runtime=MT | compiler.runtime=MTd |
278
279If you receive a linker warning concerning `LIBCMT`, it is because you are attempting to link libraries which have been built with different run-time libraries.
280You should link everything with the dynamic or static run-time. You can link a static library with the dynamic run-time if you wish.
281
282### Changing profile settings with the conan command
283
284It is recommended that you use profiles provided in `<exiv2dir>\cmake\msvc_conan_profiles`.
285
286You can modify profile settings on the command line.
287The following example demonstrates making substantial changes to profile settings by performing a 32 bit build using Visual Studio 2015 with a 2017 profile!  This example is not considered good practice, it is an illustration of some conan flexibility which may be useful when your build environment is automated.
288
289```bash
290$ conan install .. --profile msvc2017Release64 -s arch_build=x86 -s arch=x86 -s compiler.version=14
291$ cmake         .. -G "Visual Studio 2015"
292$ cmake --build .  --config Release
293```
294
295[TOC](#TOC)
296<name id="3">
297## 3 Conan Architecture
298
299<name id="3-1">
300##### 3.1) conanfile.py
301
302In the root level of the **Exiv2** repository, the file `conanfile.py` defines C/C++ dependencies with the syntax: `Library/version@user/channel`
303
304For example, **zlib**:
305
306```python
307self.requires('self.requires('zlib/1.2.11@conan/stable')')
308```
309
310[TOC](#TOC)
311<name id="3-2">
312##### 3.2) Conan _**Recipes**_
313
314Conan searches remote servers for a _**recipe**_ to build a dependency.
315
316A _**recipe**_ is a python file which indicates how to build a library from sources. The recipe
317understands configurations: Platform/Compiler/Settings.  If the remote server has a pre-compiled package for
318your configuration, it will be downloaded.  Otherwise, conan will compile the libraries on your machine using instructions in the recipe.
319
320To illustrate, here is list of packages that returned by the command `$ conan search`
321
322```bash
323$ conan search --remote conan-center zlib/1.2.11@conan/stable
324```
325
326The output should be:
327
328```bash
329Existing packages for recipe zlib/1.2.11@conan/stable:
330
331    Package_ID: 0000193ac313953e78a4f8e82528100030ca70ee
332        [options]
333            shared: False
334        [settings]
335            arch: x86_64
336            build_type: Debug
337            compiler: gcc
338            compiler.version: 4.9
339            os: Linux
340        Outdated from recipe: False
341
342    Package_ID: 014be746b283391f79d11e4e8af3154344b58223
343        [options]
344            shared: False
345        [settings]
346            arch: x86_64
347            build_type: Debug
348            compiler: gcc
349            compiler.exception: seh
350            compiler.threads: posix
351            compiler.version: 5
352            os: Windows
353        Outdated from recipe: False
354
355... deleted ....
356
357```
358
359[TOC](#TOC)
360<name id="3-3">
361##### 3.3) Conan server search path
362
363Conan searches remote servers for a _**recipe**_ to build the dependency.  You can list them with the command:
364
365```bash
366$ conan remote list
367```
368
369You can add servers to the conan server search path:
370
371```bash
372$ conan remote add conan-piponazo https://api.bintray.com/conan/piponazo/piponazo
373```
374
375[TOC](#TOC)
376<name id="3-4">
377##### 3.4) Configuring conan on your machine
378
379Conan stores its configuration and local builds in the directory ~/.conan (%HOMEPATH%\\.conan on Windows).
380
381Conan installs several files and two directories:
382
383```bash
384$HOME/.conan/profiles   Configuration files for compilers/platforms
385$HOME/.conan/data       Dependencies are built/stored in this directory
386```
387
388[TOC](#TOC)
389<name id="3-5">
390##### 3.5) Running `conan install` for the first time
391
392The first time you run `$ conan install`, it will auto-detect your configuration and store a default profile in the file
393$HOME/.conan/profiles/default
394
395Normally you will want to define new profiles for choosing different compilers (msvc, gcc, clang), different
396build_type (Release, Debug), runtimes (MD, MT, MDd, MTd)
397
398The expected output should be something like this, in case it's the first time you run conan:
399
400```bash
401$ conan install ..  --build missing
402Expat/2.2.5@pix4d/stable: Retrieving from predefined remote 'conan-center'
403Expat/2.2.5@pix4d/stable: Trying with 'conan-center'...
404Downloading conanmanifest.txt
405[==================================================] 220B/220B
406Downloading conanfile.py
407[==================================================] 1.7KB/1.7KB
408zlib/1.2.11@conan/stable: Retrieving from predefined remote 'conan-center'
409zlib/1.2.11@conan/stable: Trying with 'conan-center'...
410Downloading conanmanifest.txt
411[==================================================] 121B/121B
412Downloading conanfile.py
413[==================================================] 5.7KB/5.7KB
414libcurl/7.56.1@bincrafters/stable: Retrieving from predefined remote 'bincrafters'
415libcurl/7.56.1@bincrafters/stable: Trying with 'bincrafters'...
416Downloading conanmanifest.txt
417...
418PROJECT: Installing D:\Dev\Windows\projects\exiv2\conanfile.py
419Requirements
420    Expat/2.2.5@pix4d/stable from 'conan-center'
421    OpenSSL/1.0.2n@conan/stable from 'conan-center'
422    gtest/1.8.0@bincrafters/stable from 'conan-center'
423    libcurl/7.56.1@bincrafters/stable from 'bincrafters'
424    zlib/1.2.11@conan/stable from 'conan-center'
425Packages
426    Expat/2.2.5@pix4d/stable:6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7
427    OpenSSL/1.0.2n@conan/stable:606fdb601e335c2001bdf31d478826b644747077
428    gtest/1.8.0@bincrafters/stable:a35f8fa327837a5f1466eaf165e1b6347f6e1e51
429    libcurl/7.56.1@bincrafters/stable:e37838f02fd790447943465f1c9317fd1c59b95c
430    zlib/1.2.11@conan/stable:6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7
431
432PROJECT: Retrieving package 6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7
433Expat/2.2.5@pix4d/stable: Looking for package 6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7 in remote 'conan-center'
434Downloading conanmanifest.txt
435[==================================================] 323B/323B
436Downloading conaninfo.txt
437[==================================================] 438B/438B
438Downloading conan_package.tgz
439[==================================================] 133.6KB/133.6KB
440Expat/2.2.5@pix4d/stable: Package installed 6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7
441PROJECT: Retrieving package a35f8fa327837a5f1466eaf165e1b6347f6e1e51
442gtest/1.8.0@bincrafters/stable: Looking for package a35f8fa327837a5f1466eaf165e1b6347f6e1e51 in remote 'conan-center'
443Downloading conanmanifest.txt
444[==================================================] 3.5KB/3.5KB
445Downloading conaninfo.txt
446[==================================================] 478B/478B
447Downloading conan_package.tgz
448[==================================================] 1001.1KB/1001.1KB
449gtest/1.8.0@bincrafters/stable: Package installed a35f8fa327837a5f1466eaf165e1b6347f6e1e51
450PROJECT: Retrieving package 6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7
451...
452PROJECT: Generator cmake created conanbuildinfo.cmake
453PROJECT: Generator txt created conanbuildinfo.txt
454PROJECT: Generated conaninfo.txt
455PROJECT imports(): Copied 5 '.dll' files
456(conan)
457```
458
459Note that it first downloads the recipes, and then the binary packages. When everything goes well, conan found
460the recipes in the remotes, and it also found packages for our configuration (msvc2017, Release, MD).
461
462However, if you use other configuration for which there are no packages in the remotes, you will get an error such as:
463
464```bash
465    PROJECT: WARN: Can't find a 'zlib/1.2.11@conan/stable' package for the specified options and settings:
466    - Settings: arch=x86_64, build_type=Release, compiler=clang, compiler.version=3.9, os=Macos
467    - Options: shared=False
468
469    ERROR: Missing prebuilt package for 'zlib/1.2.11@conan/stable'
470    Try to build it from sources with "--build zlib"
471    Or read "http://docs.conan.io/en/latest/faq/troubleshooting.html#error-missing-prebuilt-package"
472```
473
474In that case, we can tell conan to build the library:
475
476```bash
477$ conan install .. --profile MyEsotericProfile --build missing
478```
479
480Once the command succeeds, we will have the libraries in our system (you can find the recipes and packages in
481`$HOME/.conan/data`). When you execute the command `conan install` with the same profile, the following output is typical:
482
483```bash
484$ conan install ..
485PROJECT: Installing D:\Dev\Windows\projects\exiv2\conanfile.py
486Requirements
487    Expat/2.2.5@pix4d/stable from 'conan-center'
488    OpenSSL/1.0.2n@conan/stable from 'conan-center'
489    gtest/1.8.0@bincrafters/stable from 'conan-center'
490    libcurl/7.56.1@bincrafters/stable from 'bincrafters'
491    zlib/1.2.11@conan/stable from 'conan-center'
492Packages
493    Expat/2.2.5@pix4d/stable:6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7
494    OpenSSL/1.0.2n@conan/stable:606fdb601e335c2001bdf31d478826b644747077
495    gtest/1.8.0@bincrafters/stable:a35f8fa327837a5f1466eaf165e1b6347f6e1e51
496    libcurl/7.56.1@bincrafters/stable:e37838f02fd790447943465f1c9317fd1c59b95c
497    zlib/1.2.11@conan/stable:6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7
498
499Expat/2.2.5@pix4d/stable: Already installed!
500gtest/1.8.0@bincrafters/stable: Already installed!
501zlib/1.2.11@conan/stable: Already installed!
502OpenSSL/1.0.2n@conan/stable: Already installed!
503libcurl/7.56.1@bincrafters/stable: Already installed!
504PROJECT: Generator cmake created conanbuildinfo.cmake
505PROJECT: Generator txt created conanbuildinfo.txt
506PROJECT: Generated conaninfo.txt
507PROJECT imports(): Copied 5 '.dll' files
508```
509
510Indicating that the packages were found in the local cache.
511
512[TOC](#TOC)
513<name id="4">
514## 4 Building Exiv2 with Adobe XMPsdk 2016
515
516With Exiv2 v0.27, you can build Exiv2 with Adobe XMPsdk 2016 on Linux/GCC, Mac/clang and Visual Studio 2017.
517Other platforms such as Cygwin are not supported by Adobe.  Adobe/XMPsdk is built as a external library.
518Applications which wish use the Adobe XMPsdk directly should build Exiv2 in this configuration and the
519library can be used by the application and Exiv2.  The Adobe XMPsdk can be built as a static or shared library (.DLL)
520
521To build Exiv2 with Adobe XMPsdk 2016, perform steps 1.1, 1.2 and 1.3 described above, then perform the following:
522
523<name id="4-1">
524##### 4.1) Add a remote directory to conan's recipe search path
525
526By default, conan knows about several public conan repositories. Exiv2 requires
527the **piponazo** repository to find the XmpSdk dependency which is not available from **conan-center** repository.
528
529```bash
530$ conan remote add conan-piponazo https://api.bintray.com/conan/piponazo/piponazo
531```
532
533<name id="4-2">
534##### 4.2) Build dependencies and install conan artefacts in your build directory
535
536```bash
537$ conan install .. --options xmp=True --build missing
538```
539
540<name id="4-3">
541##### 4.3) Execute cmake to generate build files for your environment:
542
543You must tell CMake to link Adobe's library:
544
545```bash
546$ cmake .. -DEXIV2_ENABLE_EXTERNAL_XMP=On # -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release
547```
548**macOS** users should use the cmake _**Xcode**_ Generator
549
550```bash
551$ cmake .. -DEXIV2_ENABLE_EXTERNAL_XMP=On -G Xcode
552```
553
554<name id="4-4">
555##### 4.4) Build Exiv2 and link Adobe XMPsdk library
556
557```bash
558$ cmake --build . --config Release
559```
560
561[TOC](#TOC)
562<name id="5">
563## 5 Webready Support
564
565Exiv2 can perform I/O using internet protocols such as http, https and ftp.
566
567The feature is disabled by default.  You will need to instruct conan to build/download necessary libraries (curl, openssl and libssh) and tell CMake to link to the libraries.
568
569```bash
570$ conan install .. --options webready=True
571$ cmake -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_ENABLE_CURL=ON -DEXIV2_ENABLE_SSH=ON ..
572```
573
574[TOC](#TOC)
575
576Written by Robin Mills<br>robin@clanmills.com<br>Updated: 2021-03-18
577

README-SAMPLES.md

1| Travis        | AppVeyor      | GitLab| Codecov| Repology| Chat |
2|:-------------:|:-------------:|:-----:|:------:|:-------:|:----:|
3| [![Build Status](https://travis-ci.org/Exiv2/exiv2.svg?branch=0.27-maintenance)](https://travis-ci.org/Exiv2/exiv2) | [![Build status](https://ci.appveyor.com/api/projects/status/d6vxf2n0cp3v88al/branch/0.27-maintenance?svg=true)](https://ci.appveyor.com/project/piponazo/exiv2-wutfp/branch/0.27-maintenance) | [![pipeline status](https://gitlab.com/D4N/exiv2/badges/0.27-maintenance/pipeline.svg)](https://gitlab.com/D4N/exiv2/commits/0.27-maintenance) | [![codecov](https://codecov.io/gh/Exiv2/exiv2/branch/0.27-maintenance/graph/badge.svg)](https://codecov.io/gh/Exiv2/exiv2) | [![Packaging status](https://repology.org/badge/tiny-repos/exiv2.svg)](https://repology.org/metapackage/exiv2/versions) | [![#exiv2-chat on matrix.org](matrix-standard-vector-logo-xs.png)](https://matrix.to/#/#exiv2-chat:matrix.org) |
4
5![Exiv2](exiv2.png)
6
7# Exiv2 Sample Applications
8
9Exiv2 is a C++ library and a command line utility to read, write, delete and modify Exif, IPTC, XMP and ICC image metadata.  Exiv2 also features a collection of sample and test command-line programs.  Please be aware that while the program _**exiv2**_ enjoys full support from Team Exiv2, the other programs have been written for test, documentation or development purposes.  You are expected to read the code to discover the specification of programs other than _**exiv2**_.
10
11[Sample](#TOC1) Programs [Test](#TOC2) Programs
12
13<div id="TOC1">
14
15### Sample Programs
16
17The following programs are build and installed in /usr/local/bin.
18
19| Name | Purpose | More information | Code |
20|:---  |:---  |:---              |:-- |
21| _**addmoddel**_   | Demonstrates Exiv2 library APIs to add, modify or delete metadata | [addmoddel](#addmoddel) | [addmoddel.cpp](samples/addmoddel.cpp) |
22| _**exifcomment**_ | Set Exif.Photo.UserComment in an image  | [exifcomment](#exifcomment) | [exifcomment.cpp](samples/exifcomment.cpp) |
23| _**exifdata**_    | Prints _**Exif**_ metadata in different formats in an image | [exifdata](#exifdata) | [exifdata.cpp](samples/exifdata.cpp) |
24| _**exifprint**_   | Print _**Exif**_ metadata in images<br>Miscelleous other features | [exifprint](#exifprint)| [exifprint.cpp](samples/exifprint.cpp) |
25| _**exifvalue**_   | Prints the value of a single _**Exif**_ tag in a file | [exifvalue](#exifvalue) | [exifvalue.cpp](samples/exifvalue.cpp) |
26| _**exiv2**_       | Command line utility to read, write, delete and modify Exif, IPTC, XMP and ICC image metadata.<br>This is the primary test tool used by Team Exiv2 and can exercise almost all code in the library.  Due to the extensive capability of this utility, the APIs used are usually less obvious for casual code inspection. | [https://exiv2.org/manpage.html](https://exiv2.org/manpage.html)<br>[https://exiv2.org/sample.html](https://exiv2.org/sample.html) | |
27| _**exiv2json**_   | Extracts data from image in JSON format.<br>This program also contains a parser to recursively parse Xmp metadata into vectors and objects. | [exiv2json](#exiv2json) | [exiv2json.cpp](samples/exiv2json.cpp) |
28| _**geotag**_      | Reads GPX data and updates images with GPS Tags | [geotag](#geotag) | [geotag.cpp](samples/geotag.cpp) |
29| _**iptceasy**_    | Demonstrates read, set or modify IPTC metadata | [iptceasy](#iptceasy) | [iptceasy.cpp](samples/iptceasy.cpp) |
30| _**iptcprint**_   | Demonstrates Exiv2 library APIs to print Iptc data | [iptceasy](#iptceasy) | [iptcprint.cpp](samples/iptcprint.cpp) |
31| _**metacopy**_    | Demonstrates copying metadata from one image to another | [metacopy](#metacopy) | [metacopy.cpp](samples/metacopy.cpp) |
32| _**mrwthumb**_    | Sample program to extract a Minolta thumbnail from the makernote | [mrwthumb](#mrwthumb) | [mrwthumb.cpp](samples/mrwthumb.cpp) |
33| _**taglist**_     | Print a simple comma separated list of tags defined in Exiv2 | [taglist](#taglist) |
34| _**xmpdump**_     | Sample program to dump the XMP packet of an image | [xmpdump](#xmpdump) |
35| _**xmpparse**_    | Read an XMP packet from a file, parse it and print all (known) properties. | [xmpparse](#xmpparse) | [xmpparse.cpp](samples/xmpparse.cpp) |
36| _**xmpprint**_    | Read an XMP from a file, parse it and print all (known) properties.. | [xmpprint](#xmpprint) | [xmpprint.cpp](samples/xmpprint.cpp) |
37| _**xmpsample**_   | Demonstrates Exiv2 library high level XMP classes | [xmpsample](#xmpsample) | [xmpsample.cpp](samples/exmpsample.cpp) |
38
39[Sample](#TOC1) Programs [Test](#TOC2) Programs
40
41<div id="TOC2">
42
43### Test Programs
44
45As Exiv2 is open source, we publish all our materials.  The following programs are actively used in our test harness.  Some were written during feature development of features and their on-going use may be limited, or even obsolete.  In general these programs are published as source and Team Exiv2 will not provide support to users.
46
47| Name | Kind | More information |
48|:---  |:---  |:---              |
49| _**conntest**_ | Test http/https/ftp/ssh/sftp connection | [conntest](#conntest) |
50| _**convert-test**_ | Conversion test driver | [convert-test](#convert-test) |
51| _**easyaccess-test**_ | Sample program using high-level metadata access functions | [easyaccess-test](#easyaccess-test) |
52| _**getopt-test**_ | Sample program to test getopt() | [getopt-test](#getopt-test) |
53| _**ini-test**_ | Shows simple usage of the INIReader class | [ini-test](#ini-test) |
54| _**iotest**_ | Test programs for BasicIo functions. | [iotest](#iotest) |
55| _**iptctest**_ | Sample program test Iptc reading and writing. | [iptctest](#iptctest) |
56| _**key-test**_ | Key unit tests | [key-test](#key-test) |
57| _**largeiptc-test**_ | Test for large (>65535 bytes) IPTC buffer | [largeiptc-test](#largeiptc-test) |
58| _**mmap-test**_ | Simple mmap tests | [mmap-test](#mmap-test) |
59| _**path-test**_ | Test path IO | [path-test](#path-test) |
60| _**prevtest**_ | Test access to preview images | [prevtest](#prevtest) |
61| _**remotetest**_ | Tester application for testing remote i/o. | [remotetest](#remotetest) |
62| _**stringto-test**_ | Test conversions from string to long, float and Rational types. | [stringto-test](#stringto-test) |
63| _**tiff-test**_ | Simple TIFF write test | [tiff-test](#tiff-test) |
64| _**werror-test**_ | Simple tests for the wide-string error class WError | [werror-test](#werror-test) |
65| _**write-test**_ | ExifData write unit tests | [write-test](#write-test) |
66| _**write2-test**_ | ExifData write unit tests for Exif data created from scratch | [write2-test](#write2-test) |
67| _**xmpparser-test**_ | Read an XMP packet from a file, parse and re-serialize it. | [xmpparser-test](#xmpparser-test)|
68
69[Sample](#TOC1) Programs [Test](#TOC2) Programs
70
71## 2 Sample Program Descriptions
72
73<div id="addmoddel">
74
75#### addmoddel
76
77```
78Usage: addmoddel file
79```
80
81Demonstrates Exiv2 library APIs to add, modify or delete metadata.  _Code: [addmoddel.cpp](samples/addmoddel.cpp)_
82
83[Sample](#TOC1) Programs [Test](#TOC2) Programs
84
85<div id="exifcomment">
86
87#### exifcomment
88
89```
90Usage: exifcomment file
91```
92
93This is a simple program that demonstrates how to set _**Exif.Photo.UserComment**_ in an image. _Code: [exifcomment.cpp](samples/exifcomment.cpp)_
94
95[Sample](#TOC1) Programs [Test](#TOC2) Programs
96
97<div id="exifdata">
98
99### exifdata
100
101```
102Usage: exifdata file format
103formats: csv | json | wolf | xml
104```
105
106This is a simple program to demonstrate dumping _**Exif**_ metadata in common formats.  _Code: [exifdata.cpp](samples/exifdata.cpp)_
107
108[Sample](#TOC1) Programs [Test](#TOC2) Programs
109
110<div id="exifprint">
111
112#### exifprint
113
114```
115Usage: exifprint [ path | --version | --version-test ]
116```
117
118| Arguments | Description |
119|:--        |:---  |
120| path    | Path to image |
121| --version     | Print version information from build |
122| --version-test   | Tests Exiv2 VERSION API |
123
124This program demonstrates how to print _**Exif**_ metadata in an image.  This program is also discussed in the platform ReadMe.txt file included in a build bundle.  The option **--version** was added to enable the user to build a test application which dumps the build information.  The option **--version-test** was added to test the macro EXIV2\_TEST\_VERSION() in **include/exiv2/version.hpp**.
125
126There is one other unique feature of this program.  It is the only test/sample program which can use the EXV\_UNICODE\_PATH build feature of Exiv2 on Windows.
127
128_Code: [exifprint.cpp](samples/exifprint.cpp)_
129
130[Sample](#TOC1) Programs [Test](#TOC2) Programs
131
132<div id="exifvalue">
133
134#### exifvalue
135
136```
137Usage: exifvalue file tag
138```
139Prints the value of a single _**Exif**_ tag in a file. _Code: [exifvalue.cpp](samples/exifvalue.cpp)_
140
141[Sample](#TOC1) Programs [Test](#TOC2) Programs
142
143<div id="exiv2json">
144
145#### exiv2json
146
147```
148Usage: exiv2json [-option] file
149Option: all | exif | iptc | xmp | filesystem
150```
151| Arguments | Description |
152|:--        |:---  |
153| all      | All metadata |
154| filesystem    | Filesystem metadata |
155| exif     | Exif metadata |
156| iptc     | Iptc metadata |
157| xmp      | Xmp metadata |
158| file   | path to image |
159
160This program dumps metadata from an image in JSON format. _Code: [exiv2json.cpp](samples/exiv2json.cpp)_
161
162exiv2json has a recursive parser to encode XMP into Vectors and Objects.  XMP data is XMP and can contain XMP `Bag` and `Seq` which are converted to JSON Objects and Arrays.  Exiv2 presents data in the format:  Family.Group.Tag.  For XMP, results in "flat" output such such as:
163
164```
165$ exiv2 -px ~/Stonehenge.jpg
166Xmp.xmp.Rating                               XmpText     1  0
167Xmp.xmp.ModifyDate                           XmpText    25  2015-07-16T20:25:28+01:00
168Xmp.dc.description                           LangAlt     1  lang="x-default" Classic View
169```
170
171exiv2json parses the Exiv2 'Family.Group.Tag' data and restores the structure of the original data in JSON.  _Code: [exiv2json.cpp](samples/exiv2json.cpp)_
172
173```
174$ exiv2json -xmp http://clanmills.com/Stonehenge.jpg
175{
176  "Xmp": {
177    "xmp": {
178      "Rating": "0",
179      "ModifyDate": "2015-07-16T20:25:28+01:00"
180    },
181    "dc": {
182      "description": {
183        "lang": {
184          "x-default": "Classic View"
185        }
186      }
187    },
188    "xmlns": {
189      "dc": "http:\/\/purl.org\/dc\/elements\/1.1\/",
190      "xmp": "http:\/\/ns.adobe.com\/xap\/1.0\/"
191    }
192  }
193}
194$
195```
196
197[Sample](#TOC1) Programs [Test](#TOC2) Programs
198
199<div id="geotag">
200
201#### geotag
202
203```
204Usage: geotag {-help|-version|-dst|-dryrun|-ascii|-verbose|-adjust value|-tz value|-delta value}+ path+
205```
206
207Geotag reads one or more GPX files and adds GPS Tages to images.  _Code: [geotag.cpp](samples/geotag.cpp)_
208
209If the path is a directory, geotag will read all the files in the directory.  It constructs a time dictionary of position data, then updates every image with GPS Tags.
210
211| Arguments | Description |
212|:--        |:---  |
213| -help     | print usage statement |
214| -version  | prints data and time of compiling geotag.cpp |
215| -dst      | Apply 1 hour adjustment for daylight saving time. |
216| -dryrun   | Read arguments and print report.  Does not modify images. |
217| -ascii    | Output in ascii (not UTF8).  Prints `deg` instead of &deg;. |
218| -verbose  | Report progress. |
219| -adjust  value | Add/subtract time from image data. |
220| -tz      value | Specify time zone. For example PST = -8:00 |
221| -delta   value | Correction between Image DataTime and GPS time. |
222| path+ | One or more directories, image paths or gpx paths.  Directories are searched for gpx and images |
223
224I use this program frequently.  I have a little Canon camera which I take when I run.  My Samsung Galaxy Watch uploads my runs to Strava and I download the GPX.  If I'm in another time-zone and have forgotten to change the time setting in the camera, I use `-adjust` to alter the images.  The GPX time is always correct, however the camera is normally off by seconds or minutes.  This option enables you to correct for inaccuracy in the setting of the camera time.
225
226[Sample](#TOC1) Programs [Test](#TOC2) Programs
227
228<div id="iptceasy">
229
230#### iptceasy
231
232```
233Usage: iptceasy file
234Reads and writes raw metadata. Use -h option for help.
235```
236
237Demonstrates read, set or modify IPTC metadata. _Code: [iptceasy.cpp](samples/iptceasy.cpp)_
238
239[Sample](#TOC1) Programs [Test](#TOC2) Programs
240
241<div id="iptcprint">
242
243#### iptcprint
244
245```
246Usage: iptcprint file
247Reads and writes raw metadata. Use -h option for help.
248```
249
250Demonstrates Exiv2 library APIs to print Iptc data. _Code: [iptcprint.cpp](samples/iptcprint.cpp)_
251
252[Sample](#TOC1) Programs [Test](#TOC2) Programs
253
254<div id="metacopy">
255
256#### metacopy
257
258```
259Usage: metacopy [-iecxaph] readfile writefile
260Reads and writes raw metadata. Use -h option for help.
261```
262
263Metacopy is used to copy a complete metadata block from one file to another.  _Code: [metacopy.cpp](samples/metacopy.cpp)_
264
265Please note that some metadata such as Exif.Photo.PixelXDimension is considered to be part of the image and will not be copied.
266
267[Sample](#TOC1) Programs [Test](#TOC2) Programs
268
269<div id="mrwthumb">
270
271#### mrwthumb
272
273```
274Usage: mrwthumb file
275```
276
277Sample program to extract a Minolta thumbnail from the makernote. _Code: [mrwthumb.cpp](samples/mrwthumb.cpp)_
278
279[Sample](#TOC1) Programs [Test](#TOC2) Programs
280
281<div id="xmpparse">
282
283#### xmpparse
284
285```
286Usage: xmpparse file
287```
288
289Read an XMP packet from a file, parse it and print all (known) properties.  _Code: [xmpparse.cpp](samples/xmpparse.cpp)_
290
291
292[Sample](#TOC1) Programs [Test](#TOC2) Programs
293
294<div id="xmpprint">
295
296#### xmpprint
297
298```
299Usage: xmpprint file
300```
301
302Read an XMP from a file, parse it and print all (known) properties. _Code: [xmpprint.cpp](samples/xmpprint.cpp)_
303
304[Sample](#TOC1) Programs [Test](#TOC2) Programs
305
306<div id="xmpsample">
307
308#### xmpsample
309
310```
311Usage: xmpsample file
312```
313
314Demonstrates Exiv2 library high level XMP classes.  _Code: [xmpsample.cpp](samples/xmpsample.cpp)_
315
316[Sample](#TOC1) Programs [Test](#TOC2) Programs
317
318## 3 Test Program Descriptions
319
320<div id="conntest">
321
322#### conntest
323
324```
325Usage: conntest url {-http1_0}
326```
327
328Test http/https/ftp/ssh/sftp connection
329
330[Sample](#TOC1) Programs [Test](#TOC2) Programs
331
332<div id="convert-test">
333
334#### convert-test
335
336```
337Usage: convert-test file
338```
339
340Conversion test driver
341
342[Sample](#TOC1) Programs [Test](#TOC2) Programs
343
344<div id="easyaccess-test">
345
346#### easyaccess-test
347
348```
349Usage: easyaccess-test file
350```
351
352Sample program using high-level metadata access functions
353
354[Sample](#TOC1) Programs [Test](#TOC2) Programs
355
356<div id="getopt-test">
357
358#### getopt-test
359
360```
361Usage: getopt-test
362```
363This program is used to test the function **getopt()**.  Prior to Exiv2 v0.27, the sample programs used the platform's C Runtime Library function **getopt()**.  Visual Studio builds used code in src/getopt.cpp.  Due to differences in the platform **getopt()**, the code in src/getopt.cpp was modified and adopted on every platforms.  This test program was added for test and debug purpose.  Please note that src/getopt.cpp is compiled and linked into the sample application and is not part of the Exiv2 library.
364
365[Sample](#TOC1) Programs [Test](#TOC2) Programs
366
367<div id="ini-test">
368
369#### ini-test
370
371```
372Usage: ini-test
373```
374
375This program is used to test reading the file ini-test.  This program was added in Exiv2 v0.26 when the ~/.exiv2 file was added to the Exiv2 architecture.
376
377[Sample](#TOC1) Programs [Test](#TOC2) Programs
378
379<div id="iotest">
380
381#### iotest
382
383```
384Usage: iotest filein fileout1 fileout2 [remote [blocksize]]
385copy filein to fileout1 and copy filein to fileout2
386fileout1 and fileout2 are overwritten and should match filein exactly
387
388You may optionally provide the URL of a remote file to be copied to filein
389If you use `remote`, you may optionally provide a blocksize for the copy buffer (default 10k)
390```
391
392Test programs for BasicIo functions.
393
394[Sample](#TOC1) Programs [Test](#TOC2) Programs
395
396<div id="iptctest">
397
398#### iptctest
399
400```
401Usage: iptctest image
402Commands read from stdin.
403```
404
405Sample program test Iptc reading and writing.
406
407[Sample](#TOC1) Programs [Test](#TOC2) Programs
408
409<div id="key-test">
410
411#### key-test
412
413```
414Usage: key-test
415```
416
417Key unit tests
418
419[Sample](#TOC1) Programs [Test](#TOC2) Programs
420
421<div id="largeiptc-test">
422
423#### largeiptc-test
424
425```
426Usage: largeiptc-test image datafile
427```
428
429Test for large (>65535 bytes) IPTC buffer
430
431[Sample](#TOC1) Programs [Test](#TOC2) Programs
432
433<div id="mmap-test">
434
435#### mmap-test
436
437```
438Usage: mmap-test file
439```
440
441Simple mmap tests
442
443[Sample](#TOC1) Programs [Test](#TOC2) Programs
444
445<div id="path-test">
446
447#### path-test
448
449```
450Usage: path-test file
451```
452
453Test path IO
454
455[Sample](#TOC1) Programs [Test](#TOC2) Programs
456
457<div id="prevtest">
458
459#### prevtest
460
461```
462Usage: prevtest file
463```
464
465Test access to preview images
466
467[Sample](#TOC1) Programs [Test](#TOC2) Programs
468
469<div id="remotetest">
470
471#### remotetest
472
473```
474Usage: remotetest remotetest file {--nocurl | --curl}
475```
476
477Tester application for testing remote i/o.
478
479[Sample](#TOC1) Programs [Test](#TOC2) Programs
480
481<div id="stringto-test">
482
483#### stringto-test
484
485```
486Usage: stringto-test
487```
488
489Test conversions from string to long, float and Rational types.
490
491[Sample](#TOC1) Programs [Test](#TOC2) Programs
492
493<div id="taglist">
494
495#### taglist
496
497```
498$ taglist --help
499Usage: taglist [--help]
500           [--group name|
501            Groups|Exif|Canon|CanonCs|CanonSi|CanonCf|Fujifilm|Minolta|Nikon1|Nikon2|Nikon3|Olympus|
502            Panasonic|Pentax|Sigma|Sony|Iptc|
503            dc|xmp|xmpRights|xmpMM|xmpBJ|xmpTPg|xmpDM|pdf|photoshop|crs|tiff|exif|aux|iptc|all|ALL
504           ]
505Print Exif tags, MakerNote tags, or Iptc datasets
506```
507
508Print a simple comma separated list of tags defined in Exiv2
509
510This program encodes the library's tag definitions in ascii.
511The data from this program is formatted as HTML on the web-site.  https://exiv2.org/metadata.html
512
513For example, to show the binary definition of Group `Nikon3`:
514
515```
516$ taglist Nikon3
517Version,    1,  0x0001, Nikon3, Exif.Nikon3.Version,    Undefined,  Nikon Makernote version
518ISOSpeed,   2,  0x0002, Nikon3, Exif.Nikon3.ISOSpeed,   Short,  ISO speed setting
519ColorMode,  3,  0x0003, Nikon3, Exif.Nikon3.ColorMode,  Ascii,  Color mode
520Quality,    4,  0x0004, Nikon3, Exif.Nikon3.Quality,    Ascii,  Image quality setting
521WhiteBalance,   5,  0x0005, Nikon3, Exif.Nikon3.WhiteBalance,   Ascii,  White balance
522Sharpening, 6,  0x0006, Nikon3, Exif.Nikon3.Sharpening, Ascii,  Image sharpening setting
523Focus,  7,  0x0007, Nikon3, Exif.Nikon3.Focus,  Ascii,  Focus mode
524FlashSetting,   8,  0x0008, Nikon3, Exif.Nikon3.FlashSetting,   Ascii,  Flash setting
525FlashDevice,    9,  0x0009, Nikon3, Exif.Nikon3.FlashDevice,    Ascii,  Flash device
526...
527```
528
529We can see those tags being used:
530
531```
532$ exiv2 -pa --grep Nikon3 http://clanmills.com/Stonehenge.jpg
533Exif.Nikon3.Version                          Undefined   4  2.11
534Exif.Nikon3.ISOSpeed                         Short       2  200
535...
536```
537
538This information is formatted (search Nikon (format 3) MakerNote Tags): [https://exiv2.org/tags-nikon.html](https://exiv2.org/tags-nikon.html)
539
540#### taglist all
541
542These options are provided to list every Exif tag known to Exiv2.  The option `all` prints Group.Name for every tag.  The option `ALL` print Group.Name followed by the TagInfo for that tag.  For example:
543
544```bash
545$ taglist all | grep ISOSpeed$
546Photo.ISOSpeed
547PanasonicRaw.ISOSpeed
548CanonCs.ISOSpeed
549CanonSi.ISOSpeed
550Casio2.ISOSpeed
551MinoltaCs5D.ISOSpeed
552MinoltaCs7D.ISOSpeed
553Nikon1.ISOSpeed
554Nikon2.ISOSpeed
555Nikon3.ISOSpeed
556Olympus.ISOSpeed
557Olympus2.ISOSpeed
558```
559
560```bash
561$ taglist ALL | grep ISOSpeed,
562Photo.ISOSpeed,	34867,	0x8833,	Photo,	Exif.Photo.ISOSpeed,	Long,	This tag indicates the ISO speed value of a camera or input device that is defined in ISO 12232. When recording this tag, the PhotographicSensitivity and SensitivityType tags shall also be recorded.
563PanasonicRaw.ISOSpeed,	23,	0x0017,	PanasonicRaw,	Exif.PanasonicRaw.ISOSpeed,	Short,	ISO speed setting
564CanonCs.ISOSpeed,	16,	0x0010,	CanonCs,	Exif.CanonCs.ISOSpeed,	SShort,	ISO speed setting
565CanonSi.ISOSpeed,	2,	0x0002,	CanonSi,	Exif.CanonSi.ISOSpeed,	Short,	ISO speed used
566Casio2.ISOSpeed,	20,	0x0014,	Casio2,	Exif.Casio2.ISOSpeed,	Short,	ISO Speed
567MinoltaCs5D.ISOSpeed,	38,	0x0026,	MinoltaCs5D,	Exif.MinoltaCs5D.ISOSpeed,	Short,	ISO speed setting
568MinoltaCs7D.ISOSpeed,	28,	0x001c,	MinoltaCs7D,	Exif.MinoltaCs7D.ISOSpeed,	Short,	ISO speed setting
569Nikon1.ISOSpeed,	2,	0x0002,	Nikon1,	Exif.Nikon1.ISOSpeed,	Short,	ISO speed setting
570Nikon2.ISOSpeed,	6,	0x0006,	Nikon2,	Exif.Nikon2.ISOSpeed,	Short,	ISO speed setting
571Nikon3.ISOSpeed,	2,	0x0002,	Nikon3,	Exif.Nikon3.ISOSpeed,	Short,	ISO speed setting
572Olympus.ISOSpeed,	4097,	0x1001,	Olympus,	Exif.Olympus.ISOSpeed,	SRational,	ISO speed value
573Olympus2.ISOSpeed,	4097,	0x1001,	Olympus,	Exif.Olympus.ISOSpeed,	SRational,	ISO speed value
574Sony1MltCs7D.ISOSpeed,	28,	0x001c,	MinoltaCs7D,	Exif.MinoltaCs7D.ISOSpeed,	Short,	ISO speed setting
575```
576
577
578
579[Sample](#TOC1) Programs [Test](#TOC2) Programs
580
581<div id="tiff-test">
582
583#### tiff-test
584
585```
586Usage: tiff-test file
587```
588
589Simple TIFF write test
590
591[Sample](#TOC1) Programs [Test](#TOC2) Programs
592
593
594<div id="werror-test">
595
596#### werror-test
597
598```
599Usage: werror-test
600```
601
602Simple tests for the wide-string error class WError
603
604[Sample](#TOC1) Programs [Test](#TOC2) Programs
605
606<div id="write-test">
607
608#### write-test
609
610```
611Usage: write-test file case
612where case is an integer between 1 and 11
613```
614
615ExifData write unit tests
616
617[Sample](#TOC1) Programs [Test](#TOC2) Programs
618
619<div id="write2-test">
620
621#### write2-test
622
623```
624Usage: write2-test file
625```
626
627ExifData write unit tests for Exif data created from scratch
628
629[Sample](#TOC1) Programs [Test](#TOC2) Programs
630
631<div id="xmpdump">
632
633#### xmpdump
634
635```
636Usage: xmpdump file
637```
638
639Sample program to dump the XMP packet of an image
640
641[Sample](#TOC1) Programs [Test](#TOC2) Programs
642
643<div id="xmpparser-test">
644
645#### xmpparser-test
646
647```
648Usage: xmpparser-test file
649```
650
651Read an XMP packet from a file, parse and re-serialize it.
652
653[Sample](#TOC1) Programs [Test](#TOC2) Programs
654
655
656
657Robin Mills<br>
658robin@clanmills.com<br>
659Revised: 2020-11-20

README.md

1| Travis        | AppVeyor      | GitLab| Codecov| Repology| Chat |
2|:-------------:|:-------------:|:-----:|:------:|:-------:|:----:|
3| [![Build Status](https://travis-ci.org/Exiv2/exiv2.svg?branch=0.27-maintenance)](https://travis-ci.org/Exiv2/exiv2) | [![Build status](https://ci.appveyor.com/api/projects/status/d6vxf2n0cp3v88al/branch/0.27-maintenance?svg=true)](https://ci.appveyor.com/project/piponazo/exiv2-wutfp/branch/0.27-maintenance) | [![pipeline status](https://gitlab.com/D4N/exiv2/badges/0.27-maintenance/pipeline.svg)](https://gitlab.com/D4N/exiv2/commits/0.27-maintenance) | [![codecov](https://codecov.io/gh/Exiv2/exiv2/branch/0.27-maintenance/graph/badge.svg)](https://codecov.io/gh/Exiv2/exiv2) | [![Packaging status](https://repology.org/badge/tiny-repos/exiv2.svg)](https://repology.org/metapackage/exiv2/versions) | [![#exiv2-chat on matrix.org](matrix-standard-vector-logo-xs.png)](https://matrix.to/#/#exiv2-chat:matrix.org) |
4
5<div id="1">
6# Welcome to Exiv2
7
8Exiv2 is a C++ library and a command-line utility to read,
9write, delete and modify Exif, IPTC, XMP and ICC image metadata.
10
11| Exiv2 Resource | Location |
12|:----------     |:------    |
13| Releases and Documentation<br>Prereleases:<br>Project Resources<br>License (GPLv2)<br>CMake Downloads  | [https://exiv2.org](https://exiv2.org)<br>[https://pre-release.exiv2.org](https://pre-release.exiv2.org)<br>[https://github.com/Exiv2/exiv2](https://github.com/Exiv2/exiv2)<br>[COPYING](COPYING)<br>[https://cmake.org/download/](https://cmake.org/download/) |
14| README.md<br>README-CONAN.md<br>README-SAMPLES.md | User Manual. _This document_<br>Conan User Manual _[click here](README-CONAN.md)_<br>Sample Code Manual. _[click here](README-SAMPLES.md)_ |
15
16The file ReadMe.txt in a build bundle describes how to install the library on the platform.  ReadMe.txt also documents how to compile and link code on the platform.
17
18<div id="TOC">
19### TABLE  OF  CONTENTS
20![Exiv2](exiv2.png)
21
221. [Welcome to Exiv2](#1)
232. [Building, Installing, Using and Uninstalling Exiv2](#2)
24    1. [Build, Install, Use and Uninstall Exiv2 on a UNIX-like system](#2-1)
25    2. [Build and Install Exiv2 with Visual Studio](#2-2)
26    3. [Build Options](#2-3)
27    4. [Dependencies](#2-4)
28    5. [Building and linking your code with Exiv2](#2-5)
29    6. [Consuming Exiv2 with CMake](#2-6)
30    7. [Using pkg-config to compile and link your code with Exiv2](#2-7)
31    8. [Localisation](#2-8)
32    9. [Building Exiv2 Documentation](#2-9)
33   10. [Building Exiv2 Packages](#2-10)
34   11. [Debugging Exiv2](#2-11)
35   12. [Building  Exiv2 with Clang and other build chains](#2-12)
36   13. [Building  Exiv2 with ccache](#2-13)
37   14. [Thread Safety](#2-14)
38   15. [Library Initialisation and Cleanup](#2-15)
39   16. [Cross Platform Build and Test on Linux for MinGW](#2-16)
40   17. [Building with C++11 and other compilers](#2-17)
41   18. [Static and Shared Libraries](#2-18)
42   19. [Support for bmff files (CR3, HEIF, HEIC, and AVIF)](#2-19)
433. [License and Support](#3)
44    1. [License](#3-1)
45    2. [Support](#3-2)
464. [Test Suit](#4)
47    1. [Running tests on a UNIX-like system](#4-1)
48    2. [Running tests on Visual Studio builds](#4-2)
49    3. [Unit tests](#4-3)
50    4. [Python tests](#4-4)
51    5. [Test Summary](#4-5)
525. [Platform Notes](#5)
53    1. [Linux](#5-1)
54    2. [macOS](#5-2)
55    3. [MinGW/msys2](#5-3)
56    4. [Cygwin](#5-4)
57    5. [Visual Studio](#5-5)
58    6. [Unix](#5-6)
59
60[TOC](#TOC)
61<div id="2">
62## 2 Building, Installing, Using and Uninstalling Exiv2
63
64You need [CMake](https://cmake.org/download/) to configure the Exiv2 project and the GCC or Clang compiler and associated tool chain.
65
66<div id="2-1">
67### 2.1 Build, Install, Use Exiv2 on a UNIX-like system
68
69```bash
70$ cd ~/gnu/github/exiv2  # location of the project code
71$ mkdir build && cd build
72$ cmake .. -DCMAKE_BUILD_TYPE=Release
73$ cmake --build .
74$ make tests
75$ sudo make install
76```
77
78This will install the library into the "standard locations".  The library will be installed in `/usr/local/lib`, executables (including the exiv2 command-line program) in `/usr/local/bin/` and header files in `/usr/local/include/exiv2`
79
80cmake generates files in the build directory.  cmake generates the project/solution/makefiles required to build the exiv2 library and sample applications.  cmake also creates the files exv\_conf.h and exiv2lib\_export which contain compiler directives about the build options you have chosen and the availability of libraries on your machine.
81
82#### Using the exiv2 command-line program
83
84To execute the exiv2 command line program, you should update your path to search /usr/local/bin/
85
86```bash
87$ export PATH="/usr/local/bin:$PATH"
88```
89
90You will also need to locate libexiv2 at run time:
91
92```bash
93$ export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"      # Linux, Cygwin, MinGW/msys2
94$ export DYLD_LIBRARY_PATH="/usr/local/lib:$DYLD_LIBRARY_PATH"  # macOS
95```
96
97#### Uninstall
98
99I don't know why anybody would uninstall Exiv2.
100
101```bash
102$ cd ~/gnu/github/exiv2  # location of the project code
103$ cd build
104$ sudo make uninstall
105```
106
107These commands will remove the exiv2 executables, library, header files and man page from the standard locations.
108
109[TOC](#TOC)
110<div id="2-2">
111### 2.2 Build and Install Exiv2 with Visual Studio
112
113We recommend that you use conan to download the Exiv2 external dependencies on Windows.  On other platforms (maxOS, Ubuntu and others), you should use the platform package manger.  These are discussed: [Platform Notes](#5) The options to configure and compile the project using Visual Studio are similar to UNIX like systems.
114See [README-CONAN](README-CONAN.md) for more information about Conan.
115
116When you build, you may install with the following command.
117
118```cmd
119> cmake --build . --target install
120```
121This will create and copy the exiv2 build artefacts to C:\Program Files (x86)\exiv2\.  You should modify your path to include C:\Program Files (x86)\exiv2\bin.
122
123[TOC](#TOC)
124<div id="2-3">
125### 2.3 Build options
126
127There are two groups of CMake options.  There are many options defined by CMake.  Here are some particularly useful options:
128
129| Options       | Purpose (_default_)       |
130|:------------- |:------------- |
131| CMAKE\_INSTALL\_PREFIX<br/>CMAKE\_BUILD\_TYPE<br/>BUILD\_SHARED\_LIBS | Where to install on your computer _**(/usr/local)**_<br/>Type of build _**(Release)**_ See: [Debugging Exiv2](#2-11) <br/>Build exiv2lib as shared or static _**(On)**_ |
132
133Options defined by <exiv2>/CMakeLists.txt include:
134
135```bash
136576 rmills@rmillsmm:~/gnu/github/exiv2/exiv2 $ grep ^option CMakeLists.txt
137option( BUILD_SHARED_LIBS          "Build exiv2lib as a shared library"      ON )
138option( EXIV2_ENABLE_XMP           "Build with XMP metadata support"         ON )
139option( EXIV2_ENABLE_EXTERNAL_XMP  "Use external version of XMP"            OFF )
140option( EXIV2_ENABLE_PNG           "Build with png support (requires libz)"  ON )
141...
142option( EXIV2_ENABLE_BMFF          "Build with BMFF support"                 OFF)
143577 rmills@rmillsmm:~/gnu/github/exiv2/exiv2 $
144```
145
146Options are defined on the CMake command-line:
147
148```bash
149$ cmake -DBUILD_SHARED_LIBS=On -DEXIV2_ENABLE_NLS=Off
150```
151
152It is planned to set the default -DEXIV2\_ENABLE\_BMFF=On for Exiv2 v1.00.  BMFF support is disabled by default in v0.27.
153
154
155[TOC](#TOC)
156<div id="2-4">
157### 2.4 Dependencies
158
159The following Exiv2 features require external libraries:
160
161| Feature                     | Package   |  Default | To change default              | Availability |
162|:--------------------------  |:--------  |:--------:| :----------------------------  |:-----------  |
163| PNG image support           | zlib      | ON       | -DEXIV2\_ENABLE\_PNG=Off       | [http://zlib.net/](http://zlib.net/) |
164| XMP support                 | expat     | ON       | -DEXIV2\_ENABLE\_XMP=Off       | [http://expat.sourceforge.net](http://expat.sourceforge.net)/<br/>Use _**Expat 2.2.6**_ and later |
165| Natural language system     | gettext   | OFF      | -DEXIV2\_ENABLE\_NLS=On        | [http://www.gnu.org/software/gettext/](http://www.gnu.org/software/gettext/) |
166| Character set conversion    | libiconv  |          | Disabled for Visual Studio.<br>Linked when installed on UNIX like platforms.                              | [https://www.gnu.org/software/libiconv/](https://www.gnu.org/software/libiconv/) |
167| Unit test framework         | gtest     | OFF      | -DEXIV2\_BUILD\_UNIT\_TESTS=On | [https://github.com/google/googletest/archive/](https://github.com/google/googletest/archive/release-1.8.0.tar.gz)<br/>Use _**release-1.8.0.tar.gz**_ |
168
169On UNIX systems, you may install the dependencies using the distribution's package management system. Install the
170development package of a dependency to install the header files and libraries required to build Exiv2. The script
171`ci/install_dependencies.sh` is used to setup CI images on which we build and test Exiv2 on many platforms when we modify code.  You may find that helpful in setting up your platform dependencies.
172
173Natural language system is discussed in more detail here: [Localisation](#2-8)
174
175Notes about different platforms are included here: [Platform Notes](#5)
176
177You may choose to install dependences with conan.  This is supported on all platforms and is especially useful for users of Visual Studio.
178See [README-CONAN](README-CONAN.md) for more information.
179
180### Libiconv
181
182The library libiconv is used to perform character set encoding in the tags Exif.Photo.UserComment, Exif.GPSInfo.GPSProcessingMethod and Exif.GPSInfo.GPSAreaInformation.  This is documented in the exiv2 man page.
183
184CMake will detect libiconv of all UNIX like systems including Linux, macOS, UNIX, Cygwin64 and MinGW/msys2.  If you have installed libiconv on your machine, Exiv2 will link and use it.
185
186The library libiconv is a GNU library and we do not recommend using libiconv with Exiv2 when building with Visual Studio.
187
188Exiv2 includes the file cmake/FindIconv.cmake which contains a guard to prevent CMake from finding libiconv when you build with Visual Studio.  This was added because of issues reported when Visual Studio attempted to link libconv libraries installed by Cygwin, or MinGW or gnuwin32. [https://github.com/Exiv2/exiv2/issues/1250](https://github.com/Exiv2/exiv2/issues/1250)
189
190There are build instructions about Visual Studio in libiconv-1.16/INSTALL.window require you to install Cygwin.  There is an article here about building libiconv with Visual Studio. [https://www.codeproject.com/Articles/302012/How-to-Build-libiconv-with-Microsoft-Visual-Studio](https://www.codeproject.com/Articles/302012/How-to-Build-libiconv-with-Microsoft-Visual-Studio).
191
192If you wish to use libiconv with Visual Studio you will have to build libiconv and remove the "guard" in cmake/FindIconv.cmake.  Team Exiv2 will not provide support concerning libiconv and Visual Studio.
193
194[TOC](#TOC)
195<div id="2-5">
196### 2.5 Building and linking your code with Exiv2
197
198There are detailed platform notes about compiling and linking in `releasenotes/{platform}/ReadMe.txt`
199
200where `platform: { CYGWIN | Darwin | Linux | MinGW | msvc | Unix }`
201
202In general you need to do the following:
203
2041) Application code should be written in C++98 and include exiv2 headers:
205
206```cpp
207#include <exiv2/exiv2.hpp>
208```
209
2102) Compile your C++ code with the directive: **`-I/usr/local/include`**
211
2123) Link your code with libexiv2 using the linker options: **`-lexiv2`** and **`-L/usr/local/lib`**
213
214The following is a typical command to build and link with libexiv2:
215
216```bash
217$ g++ -std=c++98 myprog.cpp -o myprog -I/usr/local/include -L/usr/local/lib -lexiv2
218```
219
220[TOC](#TOC)
221<div id="2-6">
222### 2.6 Consuming Exiv2 with CMake
223
224When exiv2 is installed, the files required to consume Exiv2 are installed in `${CMAKE_INSTALL_PREFIX}/lib/cmake/exiv2`
225
226You can build samples/exifprint.cpp as follows:
227
228```bash
229$ cd <exiv2dir>
230$ mkdir exifprint
231$ cd    exifprint
232$ cat - > CMakeLists.txt <<EOF
233cmake_minimum_required(VERSION 3.8)
234project(exifprint VERSION 0.0.1 LANGUAGES CXX)
235
236set(CMAKE_CXX_STANDARD 98)
237set(CMAKE_CXX_EXTENSIONS OFF)
238
239find_package(exiv2 REQUIRED CONFIG NAMES exiv2)    # search ${CMAKE_INSTALL_PREFIX}/lib/cmake/exiv2/
240add_executable(exifprint ../samples/exifprint.cpp) # compile this
241target_link_libraries(exifprint exiv2lib)          # link exiv2lib
242EOF
243$ cmake .                                          # generate the makefile
244$ make                                             # build the code
245$ ./exifprint                                      # test your executable
246Usage: bin/exifprint [ path | --version | --version-test ]
247$
248```
249
250[TOC](#TOC)
251<div id="2-7">
252### 2.7 Using pkg-config to compile and link your code with Exiv2
253
254When exiv2 is installed, the file exiv2.pc used by pkg-config is installed in `${CMAKE_INSTALL_PREFIX}/lib/pkgconfig`  You will need to set the following in your environment:
255
256```bash
257$ export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
258```
259
260To compile and link using exiv2.pc, you usually add the following to your Makefile.
261
262```bash
263PKGCONFIG=pkg-config
264CPPFLAGS := `pkg-config exiv2 --cflags`
265LDFLAGS := `pkg-config exiv2 --libs`
266```
267
268If you are not using make, you can use pkg-config as follows:
269
270```bash
271g++ -std=c++98 myprogram.cpp -o myprogram $(pkg-config exiv2 --libs --cflags)
272```
273
274[TOC](#TOC)
275<div id="2-8">
276### 2.8 Localisation
277
278Localisation is supported on a UNIX-like platform:  Linux, macOS, Cygwin and MinGW/msys2.  Localisation is not supported for Visual Studio builds.
279
280Crowdin have provided Exiv2 with a free open-source license to use their services.  The Exiv2 localisation project is located at [https://crowdin.com/project/exiv2](https://crowdin.com/project/exiv2).  You will also need to register to have a free user account on Crowdin.  The Crowdin setup is discussed here: [https://github.com/Exiv2/exiv2/issues/1510](https://github.com/Exiv2/exiv2/issues/1510).  It is recommended that you coordinate with Leonardo before contributing localisation changes on Crowdin.  You can contact Leonardo by via GitHub.
281
282To build localisation support, use the CMake option `-DEXIV2_ENABLE_NLS=On`.  You must install the `gettext` package with your package manager or from source.  The `gettext` package is available from [http://www.gnu.org/software/gettext/](http://www.gnu.org/software/gettext/) and includes the library `libintl` and utilities to build localisation files.  If CMake produces error messages which mention libintl or gettext, you should verify that the package `gettext` has been correctly built and installed.
283
284You must install the build to test localisation.  This ensures that the localisation message files can be found at run-time.  You cannot test localisation in the directory `build\bin`.
285
2861) Running exiv2 in another language
287
288```bash
289$ env LANG=fr_FR exiv2    # env LANGUAGE=fr_FR exiv2 on Linux!
290exiv2: Une action doit être spécifié
291exiv2: Au moins un fichier est nécessaire
292Utilisation : exiv2  [ options ] [ action ] fichier ...
293
294Manipulation des métadonnées EXIF issues des images.
295$
296```
297
2982) Adding additional languages to exiv2
299
300To support a new language which we'll designate 'xy' for this discussion:
301
3022.1) Generate a po file from the po template:
303
304```bash
305$ cd <exiv2dir>
306$ mkdir -p po/xy
307$ msginit --input=po/exiv2.pot --locale=xy --output=po/xy.po
308```
3092.2) Edit/Translate the strings in po/xy.po
310
311I edited the following:
312
313```bash
314#: src/exiv2.cpp:237
315msgid "Manipulate the Exif metadata of images.\n"
316msgstr ""
317```
318to:
319
320```bash
321#: src/exiv2.cpp:237
322msgid "Manipulate the Exif metadata of images.\n"
323msgstr "Manipulate image metadata.\n"
324```
325
3262.3) Generate the messages file:
327
328```bash
329$ mkdir -p             po/xy/LC_MESSAGES
330$ msgfmt --output-file=po/xy/LC_MESSAGES/exiv2.mo po/xy.po
331```
332
3332.4) Install and test your messages:
334
335You have to install your messages to test them.  It's not possible to test a messages file by executing build/bin/exiv2.
336
337```bash
338$ sudo mkdir -p                          /usr/local/share/locale/xy/LC_MESSAGES
339$ sudo cp -R  po/xy/LC_MESSAGES/exiv2.mo /usr/local/share/locale/xy/LC_MESSAGES
340$ env LANG=xy exiv2                      # env LANGUAGE=xy on Linux!
341exiv2: An action must be specified
342exiv2: At least one file is required
343Usage: exiv2 [ options ] [ action ] file ...
344
345Manipulate image metadata.   <--------- Edited message!
346$
347```
348
3492.5) Submitting your new language file for inclusion in future versions of Exiv2:
350
351You may submit a PR which contains po/xy.po AND a modification to po/CMakeLists.txt
352
353Or, open a new issue on https://github.com/exiv2/exiv2 and attach the file xy.po.zip which can be created as follows:
354
355```
356$ zip xy.po.zip po/xy.po
357  adding: po/xy.po (deflated 78%)
358ls -l xy.po.zip
359-rw-r--r--+ 1 rmills  staff  130417 25 Jun 10:15 xy.po.zip
360$
361```
362
363[TOC](#TOC)
364<div id="2-9">
365### 2.9 Building Exiv2 Documentation
366
367Building documentation requires installing special tools.  You will probably prefer to
368read the documentation on-line from the project website: https://exiv2.org
369
370To build documentation, use the CMake option **`-DEXIV2_BUILD_DOC=On`**.
371Additionally, you will require an additional build step to actually build the documentation.
372
373```bash
374$ cmake ..options.. -DEXIV2_BUILD_DOC=On
375$ make doc
376```
377
378To build the documentation, you must install the following products:
379
380| Product      | Availability |
381|:------------ |:------------ |
382| doxygen<br/>graphviz<br/>python<br/>xsltproc<br/>md5sum  | [http://www.doxygen.org/](http://www.doxygen.org/)<br/>[http://www.graphviz.org/](http://www.graphviz.org/)<br/>[http://www.python.org/](http://www.python.org/)<br/>[http://xmlsoft.org/XSLT/](http://xmlsoft.org/XSLT/)<br/>[http://www.microbrew.org/tools/md5sha1sum/](http://www.microbrew.org/tools/md5sha1sum/) |
383
384[TOC](#TOC)
385<div id="2-10">
386### 2.10 Building Exiv2 Packages
387
388To enable the building of Exiv2 packages, use the CMake option `-DEXIV2_TEAM_PACKAGING=On`.
389
390You should not build Exiv2 Packages.  This feature is intended for use by Team Exiv2 to create Platform and Source Packages on the buildserver.
391
392There are two types of Exiv2 packages which are generated by cpack from the cmake command-line.
393
3941) Platform Package (header files, binary library and samples.  Some documentation and release notes)
395
396Create and build exiv2 for your platform.
397
398```bash
399$ git clone https://github.com/exiv2/exiv2
400$ mkdir -p exiv2/build
401$ cd       exiv2/build
402$ cmake .. -G "Unix Makefiles" -DEXIV2_TEAM_PACKAGING=On
403...
404-- Build files have been written to: .../build
405$ cmake --build . --config Release
406...
407[100%] Built target addmoddel
408$ make package
409...
410CPack: - package: /path/to/exiv2/build/exiv2-0.27.1-Linux.tar.gz generated.
411```
412
4132) Source Package
414
415```bash
416$ make package_source
417Run CPack packaging tool for source...
418...
419CPack: - package: /path/to/exiv2/build/exiv2-0.27.1-Source.tar.gz generated.
420```
421
422You may prefer to run `$ cmake --build . --config Release --target package_source`
423
424
425[TOC](#TOC)
426<div id="2-11">
427### 2.11 Debugging Exiv2
428
4291) Generating and installing a debug library
430
431In general to generate a debug library, you should use the option *cmake* option `-DCMAKE_RELEASE_TYPE=Debug` and build in the usual way.
432
433```bash
434$ cd <exiv2dir>
435$ mkdir build
436$ cd build
437$ cmake .. -G "Unix Makefiles" "-DCMAKE_BUILD_TYPE=Debug"
438$ make
439
440```
441
442You must install the library to ensure that your code is linked to the debug library.
443
444You can check that you have generated a debug build with the command:
445
446```bash
447$ exiv2 -vVg debug
448exiv2 0.27.1
449debug=1
450$
451```
452
453[TOC](#TOC)
454
4552) About preprocessor symbols `NDEBUG` and `EXIV2_DEBUG_MESSAGES`
456
457Exiv2 respects the symbol `NDEBUG` which is set only for Release builds. There are sequences of code which are defined within:
458
459```cpp
460#ifdef EXIV2_DEBUG_MESSAGES
461....
462#endif
463```
464
465Those blocks of code are not compiled unless you define `EXIV2_DEBUG_MESSAGES`. They are provided for additional debugging information. For example, if you are interested in additional output from webpimage.cpp, you can update your build as follows:
466
467```bash
468$ cd <exiv2dir>
469$ touch src/webpimage.cpp
470$ make CXXFLAGS=-DEXIV2_DEBUG_MESSAGES
471$ bin/exiv2 ...
472-- or --
473$ sudo make install
474$ exiv2     ...
475```
476
477If you are debugging library code, it is recommended that you use the exiv2 command-line program as your test harness as Team Exiv2 is very familiar with this tool and able to give support.
478
479[TOC](#TOC)
480
4813) Starting the debugger
482
483This is platform specific.  On Linux:
484
485```bash
486$ gdb exiv2
487```
488
489[TOC](#TOC)
490
4914) Using Debugger IDEs such as Xcode, CLion, Visual Studio, Eclipse or QtCreator
492
493I have used all those IDEs to debug the Exiv2 library and applications.  All of them work.  You may find it takes initial effort, however I assure you that they all work well.
494
495I work on macOS and use Xcode to develop Exiv2.  For a couple of years, Team Exiv2 had free
496open-source licences from JetBrains for CLion.  I really liked CLion as it is cross platform
497and runs on Windows, Mac and Linux.  It has excellent integration with CMake and will automatically
498add **`-DCMAKE_BUILD_TYPE=Debug`** to the cmake command.  It keeps build types in separate directories
499such as **`<exiv2dir>/cmake-build-debug`**.
500
501[TOC](#TOC)
502
5035) cmake --build . options **`--config Release|Debug`** and **`--target install`**
504
505Visual Studio and Xcode can build debug or release builds without using the option **`-DCMAKE_BUILD_TYPE`** because the generated project files can build multiple types.  The option **`--config Debug`** can be specified on the cmake command-line to specify the build type.  Alternatively, if you prefer to build in the IDE, the UI provides options to select the configuration and target.
506
507With the Unix Makefile generator, the targets can be listed:
508
509```bash
510$ make help
511The following are some of the valid targets for this Makefile:
512... all (the default if no target is provided)
513... clean
514... depend
515... install/local
516.........
517```
518
519[TOC](#TOC)
520<div id="2-12">
521### 2.12 Building Exiv2 with **clang** and other build chains
522
5231) On Linux
524
525```bash
526$ cd <exiv2dir>
527$ rm -rf build ; mkdir build ; cd build
528$ cmake .. -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++)
529$ cmake --build .
530```
531
532**_OR_**
533
534```bash
535$ export CC=$(which clang)
536$ export CXX=$(which clang++)
537$ cd <exiv2dir>
538$ rm -rf build ; mkdir build ; cd build
539$ cmake ..
540$ cmake --build .
541```
542
5432) On macOS
544
545Apple provide clang with Xcode.  GCC has not been supported by Apple since 2013.  The _"normal unix build"_ uses Clang.
546
5473) On Cygwin, MinGW/msys2, Windows (using clang-cl) and Visual Studio.
548
549I have been unable to get clang to work on any of those platforms.
550
551[TOC](#TOC)
552<div id="2-13">
553### 2.13 Building Exiv2 with ccache
554
555To speed up compilation, the utility ccache can be installed to cache the output of the compiler.  This greatly speeds up the build when you frequently built code that has not been modified.
556
557Installing and using ccache (and other similar utilities), is platform dependent.  On Ubuntu:
558
559```bash
560$ sudo apt install --yes ccache
561```
562
563To build with ccache, use the cmake option **-DBUILD\_WITH\_CCACHE=On**
564
565```bash
566$ cd <exiv2dir>
567$ mkdir build ; cd build ; cd build
568$ cmake .. -G "Unix Makefiles" -DBUILD_WITH_CCACHE=On
569$ make
570# Build again to appreciate the performance gain
571$ make clean
572$ make
573```
574
575Due to the way in which ccache is installed in Fedora (and other Linux distros), ccache effectively replaces the compiler.  A default build or **-DBUILD\_WITH\_CCACHE=Off** is not effective and the environment variable CCACHE_DISABLE is required to disable ccache. [https://github.com/Exiv2/exiv2/issues/361](https://github.com/Exiv2/exiv2/issues/361)
576
577[TOC](#TOC)
578<div id="2-14">
579### 2.14 Thread Safety
580
581Exiv2 heavily relies on standard C++ containers. Static or global variables are used read-only, with the exception of the XMP namespace registration function (see below). Thus Exiv2 is thread safe in the same sense as C++ containers:
582Different instances of the same class can safely be used concurrently in multiple threads.
583
584In order to use the same instance of a class concurrently in multiple threads the application must serialize all write access to the object.
585
586The level of thread safety within Exiv2 varies depending on the type of metadata: The Exif and IPTC code is reentrant. The XMP code uses the Adobe XMP toolkit (XMP SDK), which according to its documentation is thread-safe. It actually uses mutexes to serialize critical sections. However, the XMP SDK initialisation function is not mutex protected, thus Exiv2::XmpParser::initialize is not thread-safe. In addition, Exiv2::XmpProperties::registerNs writes to a static class variable, and is also not thread-safe.
587
588Therefore, multi-threaded applications need to ensure that these two XMP functions are serialized, e.g., by calling them from an initialization section which is run before any threads are started.  All exiv2 sample applications begin with:
589
590```cpp
591#include <exiv2/exiv2.hpp>
592int main(int argc, const char* argv[])
593{
594    Exiv2::XmpParser::initialize();
595    ::atexit(Exiv2::XmpParser::terminate);
596#ifdef EXV_ENABLE_BMFF
597    Exiv2::enableBMFF(true);
598#endif
599    ...
600}
601```
602The use of the _**thread unsafe function**_ Exiv2::enableBMFF(true) is discussed in [2.19 Support for bmff files](#2-19)
603
604[TOC](#TOC)
605<div id="2-15">
606### 2.15 Library Initialisation and Cleanup
607
608As discussed in the section on Thread Safety, Exiv2 classes for Exif and IPTC metadata are fully reentrant and require no initialisation or cleanup.
609
610Adobe's XMPsdk is generally thread-safe, however it has to be initialized and terminated before and after starting any threads to access XMP metadata. The Exiv2 library will initialize this if necessary, however it does not terminate the XMPsdk.
611
612The exiv2 command-line program and sample applications call the following at the outset:
613
614```cpp
615    Exiv2::XmpParser::initialize();
616    ::atexit(Exiv2::XmpParser::terminate);
617#ifdef EXV_ENABLE_BMFF
618    Exiv2::enableBMFF(true);
619#endif
620```
621
622[TOC](#TOC)
623<div id="2-16">
624### 2.16 Cross Platform Build and Test on Linux for MinGW
625
626You can cross compile Exiv2 on Linux for MinGW.  We have used the following method on **Fedora** and believe this is also possible on Ubuntu and other distros.  Detailed instructions are provided here for **Fedora**.
627
628### Cross Build and Test On Fedora
629
630####1 Install the cross platform build tools
631
632```bash
633$ sudo dnf install mingw64-gcc-c++ mingw64-filesystem mingw64-expat mingw64-zlib cmake make
634```
635
636####2 Install Dependancies
637
638You will need to install x86_64 libraries to support the options you wish to use.  By default, you will need libz and expat.  Your `dnf` command above has installed them for you.  If you wish to use features such as `webready` you should install openssl and libcurl as follows:
639
640```bash
641[rmills@rmillsmm-fedora 0.27-maintenance]$ sudo yum install libcurl.x86_64 openssl.x86_64
642Last metadata expiration check: 0:00:18 ago on Fri 10 Apr 2020 10:50:30 AM BST.
643Dependencies resolved.
644=========================
645Package                          Architecture                                        Version                                                      Repository                       Size
646=========================
647Installing:
648...
649```
650
651####3 Get the code and build
652
653```bash
654$ git clone://github.com/exiv2/exiv2 --branch 0.27-maintenance exiv2
655$ cd exiv2
656$ mkdir build_mingw_fedora
657$ mingw64-cmake ..
658$ make
659```
660
661Note, you may wish to choose to build with optional features and/or build static libraries.  To do this, request appropriately on the mingw64-cmake command:
662
663```bash
664$ mingw64-cmake .. -DEXIV2_TEAM_EXTRA_WARNINGS=On \
665                   -DEXIV2_ENABLE_VIDEO=On        \
666                   -DEXIV2_ENABLE_WEBREADY=On     \
667                   -DEXIV2_ENABLE_WIN_UNICODE=On  \
668                   -DBUILD_SHARED_LIBS=Off
669```
670The options available for cross-compiling are the same as provided for all builds.  See: [Build Options](#2-3)
671
672
673####4 Copy "system dlls" in the bin directory
674
675These DLLs are required to execute the cross-platform build in the bin from Windows
676
677```bash
678for i in libexpat-1.dll libgcc_s_seh-1.dll libstdc++-6.dll libwinpthread-1.dll zlib1.dll ; do
679    cp -v /usr/x86_64-w64-mingw32/sys-root/mingw/bin/$i bin
680done
681```
682
683####5 Executing exiv2 in wine
684
685You may wish to use wine to execute exiv2 from the command prompt.  To do this:
686
687```bash
688[rmills@rmillsmm-fedora build_mingw_fedora]$ wine cmd
689Microsoft Windows 6.1.7601
690
691Z:\Home\gnu\github\exiv2\0.27-maintenance\build_mingw_fedora>bin\exiv2
692exiv2: An action must be specified
693exiv2: At least one file is required
694Usage: exiv2 [ options ] [ action ] file ...
695
696Manipulate the Exif metadata of images.
697
698Z:\Home\gnu\github\exiv2\0.27-maintenance\build_mingw_fedora>
699```
700
701If you have not installed wine, Fedora will offer to install it for you.
702
703####6 Running the test suite
704
705On a default wine installation, you are in the MSDOS/cmd.exe prompt.  You cannot execute the exiv2 test suite in this environment as you require python3 and MSYS/bash to run the suite.
706
707You should mount the your Fedora exiv2/ directory on a Windows machine on which you have installed MinGW/msys2.  You will need python3 and make.
708
709My build machines is a MacMini with VMs for Windows, Fedora and other platforms.  On Fedora, I build in a Mac directory which is shared to all VMs.
710
711```bash
712[rmills@rmillsmm-fedora 0.27-maintenance]$ pwd
713/media/psf/Home/gnu/github/exiv2/0.27-maintenance
714[rmills@rmillsmm-fedora 0.27-maintenance]$ ls -l build_mingw_fedora/bin/exiv2.exe
715-rwxrwxr-x. 1 rmills rmills 754944 Apr 10 07:44 build_mingw_fedora/bin/exiv2.exe
716[rmills@rmillsmm-fedora 0.27-maintenance]$
717```
718
719On MinGW/msys2, I can directly access the share:
720
721```bash
722$ cd //Mac/Home/gnu/github/exiv2/0.27/maintenance/build_mingw_fedora
723$ export EXIV2_BINDIR=$pwd/bin
724$ cd ../test
725$ make tests
726```
727
728You will find that 3 tests fail at the end of the test suite.  It is safe to ignore those minor exceptions.
729
730[TOC](#TOC)
731<div id="2-17">
732### 2.17 Building with C++11 and other compilers
733
734Exiv2 uses the default compiler for your system.  Exiv2 v0.27 was written to the C++ 1998 standard and uses auto\_ptr.  The C++11 and C++14 compilers will issue deprecation warnings about auto\_ptr.  As _auto\_ptr support has been removed from C++17, you cannot build Exiv2 v0.27 with C++17 or later compilers._  Exiv2 v1.00 and later do not use auto\_ptr and will build with all modern C++ Standard Compilers.
735
736To build with C++11:
737
738```bash
739$ cd <exiv2dir>
740$ mkdir build ; cd build
741$ cmake .. -DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_FLAGS=-Wno-deprecated
742$ make
743```
744
745The option -DCMAKE\_CXX\_STANDARD=11 specifies the C++ Language Standard.  Possible values are 98, 11 or 14.
746
747The option -DCMAKE\_CXX\_FLAGS=-Wno-deprecated suppresses warnings from C++11 concerning auto\_ptr.  The compiler will issue deprecation warnings about video, eps and ssh code in Exiv2 v0.27.  This is intentional.  These features of Exiv2 will not be available in Exiv2 v1.00.
748
749**Caution:** Visual Studio users should not use -DCMAKE\_CXX\_FLAGS=-Wno-deprecated.
750
751[TOC](#TOC)
752<div id="2-18">
753### 2.18 Static and Shared Libraries
754
755You can build either static or shared libraries.  Both can be linked with either static or shared run-time libraries.  You specify the shared/static with the option `-BUILD_SHARED_LIBS=On|Off` You specify the run-time with the option `-DEXIV2_ENABLE_DYNAMIC_RUNTIME=On|Off`.  The default for both options default is On.  So you build shared and use the shared libraries which are `.dll` on Windows (msvc, Cygwin and MinGW/msys), `.dylib` on macOS and `.so` on Linux and UNIX.
756
757CMake creates your build artefacts in the directories `bin` and `lib`.  The `bin` directory contains your executables and .dlls.  The `lib` directory contains your static libraries.  When you install exiv2, the build artefacts are copied to your system's prefix directory which by default is `/usr/local/`.  If you wish to test and use your build without installing, you will have to set you PATH appropriately.  Linux/Unix users should also set `LD_LIBRARY_PATH` and macOS users should set `DYLD_LIBRARY_PATH`.
758
759The default build is SHARED/DYNAMIC and this arrangement treats all executables and shared libraries in a uniform manner.
760
761**Caution:** _The following discussion only applies if you are linking to a static version of the exiv2 library._  You may get the following error from CMake:
762
763```bash
764CMake Error at src/CMakeLists.txt:30 (add_library):
765Target "my-app-or-library" links to target "Iconv::Iconv" but the target was
766not found. Perhaps a find_package() call is missing for an IMPORTED
767target, or an ALIAS target is missing?
768```
769
770Be aware that the warning concerning `src/CMakeLists.txt:30 (add_library)` refers to your file src/CMakeLists.txt.  Although exiv2 has statically linked `Iconv()`, your code also needs to link.  You achieve that in your src/CMakeLists.txt with the code:
771
772```cmake
773find_package(Iconv)
774if( ICONV_FOUND )
775    target_link_libraries( my-app-or-library PRIVATE Iconv::Iconv )
776endif()
777```
778
779This is discussed: [https://github.com/Exiv2/exiv2/issues/1230](https://github.com/Exiv2/exiv2/issues/1230)
780
781[TOC](#TOC)
782<div id="2-19">
783### 2.19 Support for bmff files (CR3, HEIF, HEIC, and AVIF)
784
785**Attention is drawn to the possibility that bmff support may be the subject of patent rights. _Exiv2 shall not be held responsible for identifying any or all such patent rights.  Exiv2 shall not be held responsible for the legal consequences of the use of this code_.**
786
787Access to the bmff code is guarded in two ways.  Firstly, you have to build the library with the cmake option: `-DEXIV2_ENABLE_BMFF=On`.  Secondly, the application must enable bmff support at run-time by calling the following function.
788
789```cpp
790EXIV2API bool enableBMFF(bool enable);
791```
792
793The return value from `enableBMFF()` is true if the library has been build with bmff support (cmake option -DEXIV2_ANABLE_BMFF=On).
794
795Applications may wish to provide a preference setting to enable bmff support and thereby place the responsibility for the use of this code with the user of the application.
796
797[TOC](#TOC)
798<div id="3">
799## 3 License and Support
800
801All project resources are accessible from the project website.
802    https://github.com/Exiv2/exiv2
803
804<div id="3-1">
805### 3.1 License
806
807Copyright (C) 2004-2021 Exiv2 authors.
808You should have received a copy of the file [COPYING](COPYING) which details the GPLv2 license.
809
810Exiv2 is free software; you can redistribute it and/or modify
811it under the terms of the GNU General Public License as published by
812the Free Software Foundation; either version 2 of the License, or
813(at your option) any later version.
814
815Exiv2 program is distributed in the hope that it will be useful,
816but WITHOUT ANY WARRANTY; without even the implied warranty of
817MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
818GNU General Public License for more details.
819
820You should have received a copy of the GNU General Public License along
821with this program; if not, write to the Free Software Foundation, Inc.,
82251 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
823
824
825[TOC](#TOC)
826<div id="3-2">
827### 3.2 Support
828
829For new bug reports, feature requests and support:  Please open an issue in Github.  [https://github.com/exiv2/exiv2](https://github.com/exiv2/exiv2)
830
831[TOC](#TOC)
832<div id="4">
833## 4 Running the test suite
834
835#### Different kinds of tests:
836
837| Description        | Language  | Location       | Command<br>_(in build directory)_ | CMake Option to Build |
838|:--                 |:--        |:--             |:--                     |:--   |
839| Run all tests      |           |                                   | $ make tests                             |  |
840| Run all tests      |           | **Visual Studio Users**           | > cmake --build . --target tests         |  |
841| Bash tests         | python    | tests/bash\_tests       | $ make bash_tests    | -DEXIV2\_BUILD\_SAMPLES=On     |
842| Python tests       | python    | tests                   | $ make python_tests  | -DEXIV2\_BUILD\_SAMPLES=On     |
843| Unit tests         | C++       | unitTests               | $ make unit_test     | -DEXIV2\_BUILD\_UNIT\_TESTS=On |
844| Version test       | C++       | src/version.cpp         | $ make version_test  | Always in library              |
845
846The term _**bash scripts**_ is historical.  The implementation of the tests in this collection originally required bash.  These
847scripts have been rewritten in python.  Visual Studio Users will appreciate the python implementation as it avoids the
848installation of mingw/cygwin and special PATH settings.
849
850#### Environment Variables used by the test suite:
851
852If you build the code in the directory \<exiv2dir\>build, tests will run using the default values of Environment Variables.
853
854| Variable           | Default                    | Platforms     | Purpose |
855|:--                 |:--                         |:--            |:--      |
856| EXIV2_BINDIR       | **\<exiv2dir\>/build/bin** | All Platforms | Path of built binaries (exiv2.exe) |
857| EXIV2_PORT         | **12762**<br>**12671**<br>**12760**  | Cygwin<br>MinGW/msys2<br>Other Platforms | Test TCP/IP Port   |
858| EXIV2_HTTP         | **http://localhost**       | All Platforms | Test http server   |
859| EXIV2_ECHO         | _**not set**_              | All Platforms | For debugging bash scripts |
860| VALGRIND           | _**not set**_              | All Platforms | For debugging bash scripts |
861| VERBOSE            | _**not set**_              | All Platforms | Causes make to report its actions |
862| PATH<br>DYLD\_LIBRARY\_PATH<br>LD\_LIBRARY\_PATH    | $EXIV2\_BINDIR/../lib | Windows<br>macOS<br>Other platforms | Path of dynamic libraries |
863
864The Variable EXIV2\_PORT or EXIV2\_HTTP can be set to None to skip http tests.  The http server is started with the command `python3 -m http.server $port`.  On Windows, you will need to run this manually _**once**_ to authorise the firewall to permit python to use the port.
865
866[TOC](#TOC)
867<div id="4-1">
868### 4.1 Running tests on a UNIX-like system
869
870You can run tests directly from the build:
871
872```bash
873$ cmake .. -G "Unix Makefiles" -DEXIV2_BUILD_UNIT_TESTS=On
874$ make
875... lots of output ...
876$ make tests
877... lots of output ...
878$
879```
880
881You can run individual tests in the `test` directory.  **Caution:** If you build in a directory other than \<exiv2dir\>/build, you must set EXIV2\_BINDIR to run tests from the `test` directory.
882
883```bash
884$ cd <exiv2dir>/build
885$ make bash_tests
886addmoddel_test (testcases.TestCases) ... ok
887....
888Ran 176 tests in 9.526s
889OK (skipped=6)
890
891$ make python_tests
892... lots of output ...
893test_run (tiff_test.test_tiff_test_program.TestTiffTestProg) ... ok
894----------------------------------------------------------------------
895Ran 176 tests in 9.526s
896OK (skipped=6)
897$
898```
899
900[TOC](#TOC)
901<div id="4-2">
902### 4.2 Running tests on Visual Studio builds from cmd.exe
903
904**Caution:** _The python3 interpreter must be on the PATH, build for DOS, and called python3.exe.  I copied the python.exe program:
905
906```cmd
907> copy c:\Python37\python.exe c:\Python37\python3.exe
908> set "PATH=c:\Python37;%PATH%
909```
910
911You can execute the test suite as described for UNIX-like systems.
912The main difference is that you must use cmake to initiate the test
913as make is not a system utility on Windows.
914
915```bash
916> cd <exiv2dir>/build
917> cmake --build . --target tests
918> cmake --build . --target python_tests
919```
920
921##### Running tests from cmd.exe
922
923You can build with Visual Studio using Conan.  The is described in detail in [README-CONAN.md](README-CONAN.md)
924
925As a summary, the procedure is:
926
927```
928c:\...\exiv2>mkdir build
929c:\...\exiv2>cd build
930c:\...\exiv2\build>conan install .. --build missing --profile msvc2019Release
931c:\...\exiv2\build>cmake .. -DEXIV2_BUILD_UNIT_TESTS=On -G "Visual Studio 16 2019"
932c:\...\exiv2\build>cmake --build . --config Release
933... lots of output from compiler and linker ...
934c:\...\exiv2\build>
935```
936
937If you wish to use an environment variables, use set:
938
939```
940set VERBOSE=1
941cmake --build . --config Release --target tests
942set VERBOSE=
943```
944
945[TOC](#TOC)
946<div id="4-3">
947### 4.3 Unit tests
948
949The code for the unit tests is in `<exiv2dir>/unitTests`.  To include unit tests in the build, use the *cmake* option `-DEXIV2_BUILD_UNIT_TESTS=On`.
950
951There is a discussion on the web about installing GTest: [https://github.com/Exiv2/exiv2/issues/575](https://github.com/Exiv2/exiv2/issues/575)
952
953```bash
954$ pushd /tmp
955$ curl -LO https://github.com/google/googletest/archive/release-1.8.0.tar.gz
956$ tar xzf   release-1.8.0.tar.gz
957$ mkdir -p  googletest-release-1.8.0/build
958$ pushd     googletest-release-1.8.0/build
959$ cmake .. ; make ; make install
960$ popd
961$ popd
962```
963
964[TOC](#TOC)
965<div id="4-4">
966### 4.4 Python tests
967
968You can run the python tests from the build directory:
969
970```bash
971$ cd <exiv2dir>/build
972$ make python_tests
973```
974
975If you wish to run in verbose mode:
976
977```bash
978$ cd <exiv2dir>/build
979$ make python_tests VERBOSE=1
980```
981
982The python tests are stored in the directory tests and you can run them all with the command:
983
984```bash
985$ cd <exiv2dir>/tests
986$ export LD_LIBRARY_PATH="$PWD/../build/lib:$LD_LIBRARY_PATH"
987$ python3 runner.py
988```
989
990You can run them individually with the commands such as:
991
992```bash
993$ cd <exiv2dir>/tests
994$ python3 runner.py --verbose bugfixes/redmine/test_issue_841.py  # or $(find . -name "*841*.py")
995```
996
997You may wish to get a brief summary of failures with commands such as:
998
999```bash
1000$ cd <exiv2dir>/build
1001$ make python_tests 2>&1 | grep FAIL
1002```
1003
1004[TOC](#TOC)
1005<div id="4-5">
1006### 4.5 Test Summary
1007
1008| *Tests*      | Unix Style Platforms _(bash)_      | Visual Studio _(cmd.exe)_             |
1009|:--           |:---                                |:--                                    |
1010|              | $ cd \<exiv2dir\>/build            |  \> cd \<exiv2dir\>/build             |
1011| tests        | $ make tests                       | \> cmake --build . --config Release --target tests |
1012| bash_tests   | $ make bash_tests                  | \> cmake --build . --config Release --target bash_tests |
1013| python_tests | $ make python_tests                | \> cmake --build . --config Release --target python_tests |
1014| unit_test    | $ make unit_test                   | \> cmake --build . --config Release --target unit_test |
1015| version_test | $ make version_test                | \> cmake --build . --config Release --target version_test |
1016
1017The name **bash_tests** is historical.  They are implemented in python.
1018
1019[TOC](#TOC)
1020<div id="5">
1021## 5 Platform Notes
1022
1023There are many ways to set up and configure your platform.  The following notes are provided as a guide.
1024
1025<div id="5-1">
1026### 5.1 Linux
1027
1028Update your system and install the build tools and dependencies (zlib, expat, gtest and others)
1029
1030```bash
1031$ sudo apt --yes update
1032$ sudo apt install --yes build-essential git clang ccache python3 libxml2-utils cmake python3 libexpat1-dev libz-dev zlib1g-dev libssh-dev libcurl4-openssl-dev libgtest-dev google-mock
1033```
1034
1035For users of other platforms, the script <exiv2dir>/ci/install_dependencies.sh has code used to configure many platforms.  The code in that file is a useful guide to configuring your platform.
1036
1037Get the code from GitHub and build
1038
1039```bash
1040$ mkdir -p ~/gnu/github/exiv2
1041$ cd ~/gnu/github/exiv2
1042$ git clone https://github.com/exiv2/exiv2
1043$ cd exiv2
1044$ mkdir build ; cd build ;
1045$ cmake .. -G "Unix Makefiles"
1046$ make
1047```
1048
1049[TOC](#TOC)
1050<div id="5-2">
1051### 5.2 macOS
1052
1053You will need to install Xcode and the Xcode command-line tools to build on macOS.
1054
1055You should build and install libexpat and zlib.  You may use brew, macports, build from source, or use conan.
1056
1057I recommend that you build and install CMake from source.
1058
1059[TOC](#TOC)
1060<div id="5-3">
1061### 5.3 MinGW/msys2
1062
1063Please note that the platform MinGW/msys2 32 is obsolete and superceded by MinGW/msys2 64.
1064
1065#### MinGW/msys2 64 bit
1066Install: [https://repo.msys2.org/distrib/x86\_64/msys2-x86\_64-20200903.exe](https://repo.msys2.org/distrib/x86_64/msys2-x86_64-20200903.exe)
1067
1068The file `appveyor_mingw_cygwin.yml` has instructions to configure the AppVeyor CI to configures itself to build Exiv2 on MinGW/msys2 and Cygwin/64.
1069
1070I use the following batch file to start the MinGW/msys2 64 bit bash shell from the Dos Command Prompt (cmd.exe)
1071
1072```bat
1073@echo off
1074setlocal
1075set "PATH=c:\msys64\mingw64\bin;c:\msys64\usr\bin;c:\msys64\usr\local\bin;"
1076set "PS1=\! MSYS \u@\h:\w \$ "
1077set "HOME=c:\msys64\home\rmills"
1078if NOT EXIST %HOME% mkdir %HOME%
1079cd  %HOME%
1080color 1f
1081c:\msys64\usr\bin\bash.exe -norc
1082endlocal
1083
1084```
1085
1086#### Install MinGW Dependencies
1087
1088Install tools and dependencies:
1089
1090```bash
1091for i in base-devel git coreutils dos2unix tar diffutils make                     \
1092    mingw-w64-x86_64-toolchain mingw-w64-x86_64-gcc      mingw-w64-x86_64-gdb     \
1093    mingw-w64-x86_64-cmake     mingw-w64-x86_64-gettext  mingw-w64-x86_64-python3 \
1094    mingw-w64-x86_64-libexpat  mingw-w64-x86_64-libiconv mingw-w64-x86_64-zlib    \
1095    mingw-w64-x86_64-gtest
1096do (echo y | pacman -S $i) ; done
1097```
1098
1099#### Download exiv2 from github and build
1100
1101```bash
1102$ mkdir -p ~/gnu/github/exiv2
1103$ cd       ~/gnu/github/exiv2
1104$ git clone https://github.com/exiv2/exiv2
1105$ cd exiv2
1106$ mkdir build ; cd build ;
1107$ cmake .. -G "Unix Makefiles"   # or "MSYS Makefiles"
1108$ make
1109```
1110
1111#### MinGW and Regex
1112
1113The exiv2 command-line program provides an option **`--grep`** to filter output.  The implementation requires the header file **`<regex.h>`** and supporting library to be available during the build.  When not available, the option **`--grep`** degrades to a substring match.  Because there are several versions of **`<regex.h>`** available on the MinGW platform, detection of regex is always disabled on this platform and uses substring match.  The following command reveals if regex is included in your build:
1114
1115```bash
1116$ exiv2 -vVg regex
1117exiv2 0.27.1
1118have_regex=1
1119$
1120```
1121
1122[TOC](#TOC)
1123<div id="5-4">
1124### 5.4 Cygwin/64
1125
1126Please note that the platform Cygwin/32 is obsolete and superceded by Cygwin/64.
1127
1128Download: [https://cygwin.com/install.html](https://cygwin.com/install.html) and run setup-x86_64.exe.  I install into c:\\cygwin64
1129
1130You need:
1131make, cmake, curl, gcc, gettext-devel pkg-config, dos2unix, tar, zlib-devel, libexpat1-devel, git, libxml2-devel python3-interpreter, libiconv, libxml2-utils, libncurses, libxml2-devel libxslt-devel python38 python38-pip python38-libxml2
1132
1133The file `appveyor_mingw_cygwin.yml` has instructions to configure the AppVeyor CI to configures itself to build Exiv2 on MinGW/msys2 and Cygwin/64.
1134
1135To build unit tests, you should install googletest-release-1.8.0 as discussed [4.3 Unit tests](#4-3)
1136
1137I use the following batch file "cygwin64.bat" to start the Cygwin/64 bash shell from the Dos Command Prompt (cmd.exe).
1138
1139```bat
1140@echo off
1141setlocal
1142set "PATH=c:\cygwin64\usr\local\bin;c:\cygwin64\bin;c:\cygwin64\usr\bin;c:\cygwin64\usr\sbin;"
1143if NOT EXIST %HOME% mkdir %HOME%
1144set "HOME=c:\cygwin64\home\rmills"
1145cd  %HOME%
1146set "PS1=\! CYGWIN64:\u@\h:\w \$ "
1147bash.exe -norc
1148endlocal
1149```
1150
1151[TOC](#TOC)
1152<div id="5-5">
1153### 5.5 Visual Studio
1154
1155We recommend that you use Conan to build Exiv2 using Visual Studio. Exiv2 v0.27 can be built with Visual Studio versions 2008 and later.  We actively support and build with Visual Studio 2015, 2017 and 2019.
1156
1157As well as Visual Studio, you will need to install CMake, Python3, and Conan.
1158
11591) Binary installers for CMake on Windows are availably from [https://cmake.org/download/](https://cmake.org/download/).<br/>
11602) Binary installers for Python3 are available from [python.org](https://python.org)<br/>
11613) Conan can be installed using python/pip.  Details in [README-CONAN.md](README-CONAN.md)
1162
1163
1164```
1165..>copy c:\Python37\python.exe c:\Python37\python3.exe
1166```
1167
1168The python3 interpreter must be on your PATH.
1169
1170[TOC](#TOC)
1171<div id="5-6">
1172### 5.6 Unix
1173
1174Exiv2 can be built on many Unix and Linux distros.  With v0.27.2, we are starting to actively support the Unix Distributions NetBSD and FreeBSD.  For v0.27.3, I have added support for Solaris 11.4
1175
1176We do not have CI support for these platforms on GitHub.  However, I regularly build and test them on my MacMini Buildserver.  The device is private and not on the internet.
1177
1178I have provided notes here based on my experience with these platforms.   Feedback is welcome.  I am willing to support Exiv2 on other commercial Unix distributions such as AIX, HP-UX and OSF/1 if you provide with an ssh account for your platform.  I will require super-user privileges to install software.
1179
1180For all platforms you will need the following components to build:
1181
11821. gcc or clang
11832. cmake
11843. bash
11854. sudo
11865. gettext
1187
1188To run the test suite, you need:
1189
11901. python3
11912. chksum
11923. dos2unix
11934. xmllint
1194
1195#### NetBSD
1196
1197You can build exiv2 from source using the methods described for linux.  I built and installed exiv2 using "Pure CMake" and didn't require conan.
1198
1199You will want to use the package manager `pkgsrc` to build/install the build and test components listed above.
1200
1201I entered links into the file system
1202
1203```
1204# ln -s /usr/pkg/bin/python37 /usr/local/bin/python3
1205# ln -s /usr/pkg/bin/bash /bin/bash`
1206```
1207
1208It's important to ensure that `LD_LIBRARY_PATH` includes `/usr/local/lib` and `/usr/pkg/lib`.
1209
1210It's important to ensure that `PATH` includes `/usr/local/bin`, `/usr/pkg/bin` and `/usr/pkg/sbin`.
1211
1212#### FreeBSD
1213
1214Clang is pre-installed as ``/usr/bin/{cc|c++}` as well as libz and expat.  FreeBSD uses pkg as the package manager which I used to install cmake and git.
1215
1216```bash
1217$ su root
1218Password:
1219# pkg install cmake
1220# pkg install git
1221# pkg install bash
1222# pkg install python
1223```
1224
1225**Caution**: _The package manager *pkg* is no longer working on FreeBSD 12.0.  I will move to 12.1 for future work.  Others have reported this issue on 12.1.  Broken package manager is very bad news.  There are other package managers (such as ports), however installing and getting it to work is formidable._
1226
1227```
1228634 rmills@rmillsmm-freebsd:~/gnu/github/exiv2/0.27-maintenance/build $ sudo pkg install libxml2
1229Updating FreeBSD repository catalogue...
1230pkg: repository meta /var/db/pkg/FreeBSD.meta has wrong version 2
1231pkg: Repository FreeBSD load error: meta cannot be loaded No error: 0
1232Fetching meta.txz: 100%    916 B   0.9kB/s    00:01
1233pkg: repository meta /var/db/pkg/FreeBSD.meta has wrong version 2
1234repository FreeBSD has no meta file, using default settings
1235Fetching packagesite.txz: 100%    6 MiB 340.2kB/s    00:19
1236pkg: repository meta /var/db/pkg/FreeBSD.meta has wrong version 2
1237pkg: Repository FreeBSD load error: meta cannot be loaded No error: 0
1238Unable to open created repository FreeBSD
1239Unable to update repository FreeBSD
1240Error updating repositories!
1241635 rmills@rmillsmm-freebsd:~/gnu/github/exiv2/0.27-maintenance/build $
1242```
1243
1244#### Solaris
1245
1246Solaris uses the package manager pkg.  To get a list of packages:
1247
1248```bash
1249$ pkg list
1250```
1251
1252To install a package:
1253
1254```bash
1255$ sudo pkg install developer/gcc-7
1256```
1257
1258
1259[TOC](#TOC)
1260
1261Written by Robin Mills<br>robin@clanmills.com<br>Updated: 2021-08-10
1262
1263