=================================================================
            libdmtx - Open Source Data Matrix Software
=================================================================

                   libdmtx README file (MinGW)

This README.mingw file contains information on installing and
using libdmtx using MinGW. The general README file, also found in
this directory, contains a high level summary of libdmtx and its
components.


1. Installing libdmtx on Windows using MinGW and MSYS
-----------------------------------------------------------------

libdmtx can be installed on MinGW using the instructions provided
in the general README file. However, please see below for
additional details that might benefit users on this platform.


2. Installing MinGW and MSYS
-----------------------------------------------------------------

If you haven't done so already, first install MinGW, MSYS, and
all recommended updates to your Windows system. Instructions for
doing this are provided here:

  http://www.mingw.org/wiki/msys


3. Building and installing the core library
-----------------------------------------------------------------

To install libdmtx, download and unpack the libdmtx source to
your MSYS folder. If you accepted the installation defaults this
will be C:\msys\1.0.

Open the MSYS shell and run the following:

  $ ./configure
  $ make
  $ sudo make install

Go to folder .libs:

  $ cd .libs
  $ ls

Now you should see following output:

  libdmtx.a libdmtx.la libdmtx.lai  libdmtx_la-dmtx.o

Finally run:

  $ gcc -shared -o dmtx.dll libdmtx_la-dmtx.o -Wl,--out-implib,libdmtx.a

Now you should have working dmtx.dll in the folder .libs.


3.1. Building and installing the core library from different folder
-------------------------------------------------------------------

Recent MSYS2 installation uses C:\msys64 root folder, To build libdmtx:

1. install the MSYS2 packages:

  $ pacman -S --needed base-devel mingw-w64-x86_64-toolchain autoconf automake make libtool

Details on how to install and setup MSYS2 environment on Windows can be found `here <https://code.visualstudio.com/docs/languages/cpp>`_
and `here <https://www.freecodecamp.org/news/how-to-install-c-and-cpp-compiler-on-windows>`_ .

2. clone git repository
3. open msys2 console and add msys' mingw64 bin folder to path environment variable

  $ export PATH=$PATH:/c/msys64/mingw64/bin

4. to create configure script, run
  $ ./autogen.sh

5. open the configure file and put as very first instruction the following one
  LDFLAGS="-Wl,-no-undefined"

6. from within the libdmtx folder, run

  $ ./configure <your building options>
  $ make

Now, into .libs subfolder, you should find following files:

  libdmtx.a libdmtx.la libdmtx.lai  libdmtx_la-dmtx.o

Then finally run:

  $ gcc -shared -o dmtx.dll libdmtx_la-dmtx.o -Wl,--out-implib,libdmtx.a

Now you should have working dmtx.dll in the folder .libs.


4. This Document
-----------------------------------------------------------------

This document is derived from the wiki page located at:

  http://libdmtx.wikidot.com/libdmtx-on-windows-using-mingw

If you find an error or have additional helpful information,
please edit the wiki directly with your updates.
