- Consuming with CMake
- Debugging Exiv2
- Added "2.13 Building Exiv2 with ccache".
- Revised "Building Exiv2 with ccache" in response to Dan's feedback.
- Fixed typo in README.md
- ReleaseNotes update in preparation for RC3.
When 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:
When 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:
```bash
```ini
[settings]
[settings]
os=Linux
os=Linux
os_build=Linux
os_build=Linux
@ -162,7 +162,6 @@ settings works with conan and different compilers:
compiler.libcxx=libstdc++11 # will use -stdlib=libstdc++ and define _GLIBCXX_USE_CXX11_ABI=1
compiler.libcxx=libstdc++11 # will use -stdlib=libstdc++ and define _GLIBCXX_USE_CXX11_ABI=1
compiler.libcxx=libstdc++ # will use -stdlib=libstdc++ and define _GLIBCXX_USE_CXX11_ABI=0
compiler.libcxx=libstdc++ # will use -stdlib=libstdc++ and define _GLIBCXX_USE_CXX11_ABI=0
compiler.libcxx=libc++ # will use -stdlib=libc++
compiler.libcxx=libc++ # will use -stdlib=libc++
```
```
As a rule of thumb, set `compiler.libcxx=libstdc++11` when using a version of gcc >= 5.1.
As a rule of thumb, set `compiler.libcxx=libstdc++11` when using a version of gcc >= 5.1.
@ -180,7 +179,7 @@ algorithms when bringing the Exiv2 dependencies with conan, this might indicate
I use the following batch file to start cmd.exe. I do this to reduce the complexity of the path which grows as various tools are installed on Windows. The purpose of this script is to ensure a "stripped down path".
I use the following batch file to start cmd.exe. I do this to reduce the complexity of the path which grows as various tools are installed on Windows. The purpose of this script is to ensure a "stripped down path".
```
```bat
@echo off
@echo off
setlocal
setlocal
cd %HOMEPATH%
cd %HOMEPATH%
@ -190,9 +189,18 @@ cmd
### Profiles for Visual Studio
### Profiles for Visual Studio
You can build Exiv2 with either Visual Studio 2015 (version 14) or 2017 (version 15). You create profiles in %HOMEPATH%\.conan\profiles with a text editor.
You can build Exiv2 with Visual Studio 2017 (version 15), 2015 (version 14), 2013 (version 12), 2012 (version 11), 2010 (version 10) or 2008 (version 9).
You create profiles in %HOMEPATH%\.conan\profiles with a text editor. For your convenience, you'll find profiles in **<exiv2dir>/cmake/msvc\_conan\_profiles**. There are 24 in total:
The default (and recommended) builds of Exiv2 and sample applications build and use DLLs. If you wish to build static applications and libraries, you will need to set the correct "C" run-time library to be linked both to your code and dependencies being built/downloaded by conan.
The default builds of Exiv2 and sample applications build use DLLs.
| Static Release | Static Debug |
To build static libraries, use the cmake option -DBUILD\_SHARED\_LIBS=Off.
|:---------|:-------------------|
| compiler.runtime=MT | compiler.runtime=MTd |
Additionally, you will have to use the cmake option -DBUILD\_SHARED\_LIBS=Off
### Changing profile settings with the conan command
### Changing profile settings with the conan command
It is recommended that you create 8 profiles for msvc{2017|2015}{Release|Debug}{64|32}.
It is recommended that you use profiles provided in **<exiv2dir>/cmake/msvc\_conan\_profiles**.
You can modify profile settings on the command line.
You can modify profile settings on the command line.
The 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 to some conan flexibility which be useful when your build environment is automated.
The 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 to some conan flexibility which be useful when your build environment is automated.
If necessary, temporarily rename c:\\cygwin64\\usr\\include as c:\\cygwin64\\usr\\uncle to hide those files when working with CMake.
[TOC](#TOC)
[TOC](#TOC)
<nameid="2-3"></a>
<nameid="2-3"></a>
### 2.3) Cygwin Notes
### 2.3) Cygwin Notes
Do not use conan on the Cygwin Platform. To build Exiv2 for Cygwin use CMake without conan. We recommend installing or building dependences (expat, zlib) with platform tools.
Do not use conan on the Cygwin Platform. To build Exiv2 for Cygwin use CMake without conan. We recommend installing dependences (expat, zlib) with platform tools or build/install from source.
[TOC](#TOC)
<nameid="2-4"></a>
<nameid="2-4"></a>
### 2.4) MinGW Notes
### 2.4) MinGW Notes
Team Exiv2 supports MinGW msys/2. Team Exiv2 does not support MinGW msys/1.0.
Team Exiv2 supports MinGW msys/2. Team Exiv2 does not support MinGW msys/1.0.
As with Cygwin, we recommend installing or building dependencies with platform tools dependencies and using CMake to build Exiv2.
As with Cygwin, we do not recommend using conan to build on the MinGW/msys2 platform. We recommend installing dependences (expat, zlib) with platform tools or build/install from source.
[TOC](#TOC)
[TOC](#TOC)
<nameid="3">
<nameid="3">
@ -592,9 +577,11 @@ Exiv2 can perform I/O using internet protocols such as https, https, ftp and ssh
The 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.
The 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.
@ -103,11 +105,11 @@ There are two groups of CMake options. There are many options defined by CMake.
| Options | Purpose (_default_) |
| Options | Purpose (_default_) |
|:------------- |:------------- |
|:------------- |:------------- |
| CMAKE\_INSTALL\_PREFIX<br/>CMAKE\_BUILD\_TYPE<br/>BUILD\_SHARED\_LIBS | Where to install on your computer _**(/usr/local)**_<br/>Type of build _**(Release)**_<br/>Build exiv2lib as shared or static _**(On)**_ |
| 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)**_ |
Options defined by <exiv2>/CMakeLists.txt include:
Options defined by <exiv2>/CMakeLists.txt include:
@ -136,7 +138,7 @@ The following Exiv2 features are enabled by default and require external librari
On Linux, you may install the dependencies using the distribution's package management system. Install the development package of a dependency to install the header files and static libraries required to build Exiv2.
On Linux, you may install the dependencies using the distribution's package management system. Install the development package of a dependency to install the header files and static libraries required to build Exiv2.
Notes about different platforms are included in this document: [Platform Notes](#platforms)
Notes about different platforms are included in this document: [Platform Notes](#5)
You may choose to install dependences with conan. This is supported on all platforms and is especially useful for users of Visual Studio.
You may choose to install dependences with conan. This is supported on all platforms and is especially useful for users of Visual Studio.
See [README-CONAN](README-CONAN.md) for more information.
See [README-CONAN](README-CONAN.md) for more information.
@ -145,25 +147,25 @@ See [README-CONAN](README-CONAN.md) for more information.
<nameid="2-5">
<nameid="2-5">
### 2.5 Building and linking your code with Exiv2
### 2.5 Building and linking your code with Exiv2
There are detailed platform notes about linking code in releasenotes\platform\ReadMe.txt
There are detailed platform notes about linking code in releasenotes/platform/ReadMe.txt
Platform: Linux | Darwin | MinGW | CYGWIN | MSVC
platform: { CYGWIN| Darwin | Linux | MinGW | msvc }
In general you need to do the following:
In general you need to do the following:
1) Application code should be written in C++ 98 and should include exiv2 headers:
1) Application code should be written in C++ 98 and include exiv2 headers:
```
```C++
#include<exiv2/exiv2.hpp>
#include<exiv2/exiv2.hpp>
```
```
2 You should compile your C++ code with the directive: `-I/usr/local/include`
2 Compile your C++ code with the directive: **`-I/usr/local/include`**
3 You should link your code with libexiv2 using the linker options: `-lexiv2` and `-L/usr/local/lib`
3 Link your code with libexiv2 using the linker options: **`-lexiv2`** and **`-L/usr/local/lib`**
The following is a typical command to build an link with libexiv2:
The following is a typical command to build and link with libexiv2:
When exiv2 is installed, the files required to consume Exiv2 are installed in `${CMAKE_INSTALL_PREFIX}/share/exiv2/cmake/`
When exiv2 is installed, the files required to consume Exiv2 are installed in `${CMAKE_INSTALL_PREFIX}/share/exiv2/cmake/`
A Project to demonstrate consuming Exiv2 via CMake using those files is available here: [https://github.com/piponazo/exiv2Consumer](https://github.com/piponazo/exiv2Consumer)
The default cmake Generator is usually appropriate for your platform. Additional information concerning Generators for Visual Studio in [README-CONAN](README-CONAN.md)
[TOC](#TOC)
[TOC](#TOC)
<nameid="2-7">
<nameid="2-7">
@ -181,13 +209,13 @@ A Project to demonstrate consuming Exiv2 via CMake using those files is availabl
When 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:
When 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:
Localisation is supported on "*ix" platforms: Linux, MacOS-X, Cygwin and MinGW/msys2. Localisation is not supported for Visual Studio builds.
Localisation is supported on a UNIX-like platform: Linux, MacOS-X, Cygwin and MinGW/msys2. Localisation is not supported for Visual Studio builds.
To build localisation support, use the CMake options`-DEXIV2_BUILD_PO=On` There are no additional build steps as the normal build command will compile the library, samples and localisation support.
To build localisation support, use the CMake option **`-DEXIV2_BUILD_PO=On`**. There are no additional build steps as the normal build commands will compile the library, samples and localisation support. You must install the build to ensure the localisation message files can be found at run-time.
1) Running exiv2 in a foreign language
1) Running exiv2 in a foreign language
```
```bash
$ env LANG=fr_FR exiv2 # env LANGUAGE=fr_FR exiv2 on Linux!
$ env LANG=fr_FR exiv2 # env LANGUAGE=fr_FR exiv2 on Linux!
exiv2: Une action doit être spécifié
exiv2: Une action doit être spécifié
exiv2: Au moins un fichier est nécessaire
exiv2: Au moins un fichier est nécessaire
@ -225,7 +253,7 @@ To support a new language which we'll designate 'xy' for this discussion:
You must install the library to ensure that your code is linked to the debug library.
You can check that you have generated a debug build with the command:
```bash
$ exiv2 -vVg debug
exiv2 0.27.0.3
debug=1
$
```
[TOC](#TOC)
2) About preprocessor symbols **NDEBUG** and **DEBUG**
In accordance with current practice, exiv2 respects the symbol *NDEBUG* which is set for Release builds. There are sequences of code which are defined within:
```C++
#ifdef DEBUG
....
#endif
```
Those blocks of code are not compiled for debug builds. They are provided for additional debugging information. For example, if you are interested in additonal output from webpimage.cpp, you can update your build as follows:
```bash
$ cd <exiv2dir>
$ touch src/webpimage.cpp
$ make CXXFLAGS=-DDEBUG
$ bin/exiv2 ...
-- or --
$ sudo make install
$ exiv2 ...
```
If you are debugging library code, it is recommended that you use the exiv2 command-line as your test harness as Team Exiv2 is very familiar with this tool and able to give support.
[TOC](#TOC)
3) Starting the debugger
This is platform specific. On Linux:
```bash
$ gdb exiv2
```
[TOC](#TOC)
4) Using Debugger IDEs such as Xcode, CLion, Visual Studio, Eclipse or QtCreator
I 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.
I personally use CLion which has excellent integration with CMake. It will automatically add **`-DCMAKE_BUILD_TYPE=Debug`** to the cmake command. It keeps build types in separate directories such as **`<exiv2dir>/cmake-build-debug`**.
[TOC](#TOC)
5) cmake --build . options **`--config Release|Debug`** and **`--target install`**
Visual 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 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.
With the Unix Makefile generator, the targets can be listed:
```bash
$ make help
The following are some of the valid targets for this Makefile:
... all (the default if no target is provided)
... clean
... depend
... install/local
.........
```
[TOC](#TOC)
<nameid="2-12">
### 2.12 Building Exiv2 with **clang** and other build chains
Apple provide clang with Xcode. GCC has not been supported by Apple since 2013. The _"normal unix build"_ uses Clang.
3) On Cygwin, MinGW/msys2, Windows (using clang-cl) and Visual Studio.
I have been unable to get clang to work on any of those platforms.
4) Cross Compiling
I've never succeeded in getting this to work. I use different VMs for Linux 32 and 64 bit. I've documented how to set up Cygwin and MinGW/msys2 for 64 and 32 bit builds in [README-CONAN](README-CONAN.md)
[TOC](#TOC)
<nameid="2-13">
### 2.13 Building Exiv2 with ccache
To 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.
Installing and using ccache (and other similar utilities), is platform dependent. On Ubuntu:
```bash
$ sudo apt install --yes ccache
```
To build with ccache, use the cmake option **-DBUILD\_WITH\_CCACHE=On**
Due 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)
[TOC](#TOC)
[TOC](#TOC)
<nameid="3">
<nameid="3">
## 3 License and Support
## 3 License and Support
@ -382,8 +564,9 @@ The test suite is a mix of bash and python scripts. The python scripts are new
You can run the suite directly from the build:
You can run the suite directly from the build:
```
```bash
$ make build
$ cmake .. -G "Unix Makefiles"
$ make
...
...
$ make tests
$ make tests
... lots of output ...
... lots of output ...
@ -392,7 +575,7 @@ Summary report
You can run individual tests in the test directory using the environment variable EXIV2\_BINDIR to specify the location of the build artifacts. For Cygwin and MinGW/msys builds, also set EXIV2_EXT=.exe
You can run individual tests in the test directory using the environment variable EXIV2\_BINDIR to specify the location of the build artifacts. For Cygwin and MinGW/msys builds, also set EXIV2_EXT=.exe
```
```bash
rmills@rmillsmbp-w7 ~/gnu/github/exiv2/exiv2/build $ cd ../test
rmills@rmillsmbp-w7 ~/gnu/github/exiv2/exiv2/build $ cd ../test
Use the bash interpreter for MinGW/msys2 to run the test suite. It's essential to have a DOS Python3 interpreter on your path. The variables EXIV2\_BINDIR and EXIV2\_EXT enable the test suite to locate the MSVC build artifacts.
Use the bash interpreter for MinGW/msys2 to run the test suite. It's essential to have a DOS Python3 interpreter on your path. The variables EXIV2\_BINDIR and EXIV2\_EXT enable the test suite to locate the MSVC build artifacts.
```
```bash
$ cd <exiv2dir>/build
$ cd <exiv2dir>/build
$ cd ../test
$ cd ../test
$ PATH="/c/Python36:$PATH"
$ PATH="/c/Python36:$PATH"
@ -415,9 +598,9 @@ $ export EXIV2_EXT=.exe
$ export EXIV2_BINDIR=${PWD}/../build/bin
$ export EXIV2_BINDIR=${PWD}/../build/bin
```
```
Once you have modified the PATH and and exported EXIV2\_BINDIR and EXIV2\_EXT, you can execute the test suite as described for Unix type systems:
Once you have modified the PATH and and exported EXIV2\_BINDIR and EXIV2\_EXT, you can execute the test suite as described for UNIX-like systems:
```
```bash
$ cd <exiv2dir>/test
$ cd <exiv2dir>/test
$ make test
$ make test
$ make newtests
$ make newtests
@ -430,11 +613,11 @@ $ ./icc-test.sh
The code for the unit tests is in `<exiv2dir>/unitTests`
The code for the unit tests is in `<exiv2dir>/unitTests`
To build the unit tests, use the CMake option `-DEXIV2_BUILD_UNIT_TESTS=On`.
To build the unit tests, use the *cmake* option **`-DEXIV2_BUILD_UNIT_TESTS=On`**.
To execute the unit tests:
To execute the unit tests:
```
```bash
$ cd <exiv2dir>/build
$ cd <exiv2dir>/build
$ bin/unit_tests
$ bin/unit_tests
```
```
@ -450,14 +633,14 @@ There are many ways to set up and configure your platform. The following notes
I use the following batch file to start the MinGW/msys2 32 bit bash shell from the Dos Command Prompt (cmd.exe)
I use the following batch file to start the MinGW/msys2 32 bit bash shell from the Dos Command Prompt (cmd.exe)
```
```bat
@echo off
@echo off
setlocal
setlocal
set "PATH=c:\msys32\usr\bin;c:\msys32\usr\local\bin;"
set "PATH=c:\msys32\usr\bin;c:\msys32\usr\local\bin;"
set "HOME=c:\msys32\home\rmills"
set "HOME=c:\msys32\home\rmills"
if NOT EXIST %HOME% mkdir %HOME%
cd %HOME%
cd %HOME%
set "PS1=\! MSYS32:\u@\h:\w \$ "
set "PS1=\! MSYS32:\u@\h:\w \$ "
bash.exe -norc
bash.exe -norc
@ -519,19 +704,19 @@ bash.exe -norc
Install tools and dependencies:
Install tools and dependencies:
```
```bash
$ for i in base-devel git cmake coreutils python3 man gcc gdb make dos2unix diffutils zlib-devel libexpat-devel libiconv-devel gettext-devel; do (echo y|pacman -S $i); done
$ for i in base-devel git cmake coreutils python3 man gcc gdb make dos2unix diffutils zlib-devel libexpat-devel libiconv-devel gettext-devel; do (echo y|pacman -S $i); done
```
```
You can upgrade all installed packages on your system with the following command. For me, this broke msys32 and I had to reinstall msys32 and all the dependencies. Your experience may be different.
You can upgrade all installed packages on your system with the following command. For me, this broke msys32 and I had to reinstall msys32 and all the dependencies. Your experience may be different.
```
```bash
$ pacman -Syu
$ pacman -Syu
```
```
#### Download exiv2 from github and build
#### Download exiv2 from github and build
```
```bash
$ mkdir -p ~/gnu/github/exiv2
$ mkdir -p ~/gnu/github/exiv2
$ cd ~/gnu/github/exiv2
$ cd ~/gnu/github/exiv2
$ git clone https://github.com/exiv2/exiv2
$ git clone https://github.com/exiv2/exiv2
@ -543,28 +728,36 @@ $ make
#### MinGW and Regex
#### MinGW and Regex
The exiv2 command line program provides a `--grep` option which filters output. The implementation requires the header file `<regex.h>` and supporting library to be available during the build. When not available, the option 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 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:
```bash
$ exiv2 -vVg regex
exiv2 0.27.0.3
have_regex=1
$
```
[TOC](#TOC)
[TOC](#TOC)
<nameid="5-4">
<nameid="5-4">
### 5.4 Cygwin
### 5.4 Cygwin
Download: [https://cygwin.com/install.html](https://cygwin.com/install.html) and run setup-x86_64.exe
Download: [https://cygwin.com/install.html](https://cygwin.com/install.html) and run setup-x86_64.exe for 64 Bit Cygwin, or setup-x86.exe for 32 bit Cygwin. I install into c:\\cygwin64 and c:\\cygwin32
Download and build libiconv-1.15: [https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz](https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz)
Download and build libiconv-1.15: [https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz](https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz)
Download and build cmake from source because I can't get the cygwin installed cmake 3.6.2 to work.
Download and build cmake from source because I can't get the cygwin installed cmake 3.6.2 to work.
To build cmake from source, you need libncurses. [https://cmake.org/download/](https://cmake.org/download/)
To build cmake from source, you need libncurses. [https://cmake.org/download/](https://cmake.org/download/)
I use the following batch file to start the Cygwin/64 bit bash shell from the Dos Command Prompt (cmd.exe)
I use the following batch file "cygwin64.bat" to start the Cygwin/64 bit bash shell from the Dos Command Prompt (cmd.exe).
```
```bat
@echo off
@echo off
setlocal
setlocal
set "PATH=c:\cygwin64\usr\local\bin;c:\cygwin64\bin;c:\cygwin64\usr\bin;c:\cygwin64\usr\sbin;"
set "PATH=c:\cygwin64\usr\local\bin;c:\cygwin64\bin;c:\cygwin64\usr\bin;c:\cygwin64\usr\sbin;"
if NOT EXIST %HOME% mkdir %HOME%
set "HOME=c:\cygwin64\home\rmills"
set "HOME=c:\cygwin64\home\rmills"
cd %HOME%
cd %HOME%
set "PS1=\! CYGWIN64:\u@\h:\w \$ "
set "PS1=\! CYGWIN64:\u@\h:\w \$ "
@ -586,7 +779,7 @@ As well as Microsoft Visual Studio, you will need to install CMake, Python3, and
I use the following batch file to start cmd.exe. I do this to reduce the complexity of the path which grows as various tools are installed on Windows. The purpose of this script is to ensure a "stripped down path".
I use the following batch file to start cmd.exe. I do this to reduce the complexity of the path which grows as various tools are installed on Windows. The purpose of this script is to ensure a "stripped down path".
```
```bat
@echo off
@echo off
setlocal
setlocal
cd %HOMEPATH%
cd %HOMEPATH%
@ -596,3 +789,4 @@ cmd
[TOC](#TOC)
[TOC](#TOC)
Written by Robin Mills<br>robin@clanmills.com<br>Updated: 2018-11-28