| gclib 450 Communications API for Galil controllers and PLCs |

GalilTools

To provide maximum compatibility, gclib ships with an open source wrapper implementation of the GCL (GalilTools Communication Library). Users wanting to upgrade to gclib that have source built on Galil.h can use this wrapper to minimize source changes. This wrapper is also indicated for users that want the same function calls as Galil.h, but don't want the usage of QT as in galil1.dll.

This wrapper is intended for existing applications already using the library distributed with GalilTools (galil1.dll) or the previous STL library (galil2.dll). New applications should be written with gclib.

<!— *********************************************************************************** -->

## Windows

<!— *********************************************************************************** -->

### Compile galil2.dll with MSVC 2013

The following instructions were performed on Visual Studio Professional 2013 and can be extended to other Visual Studio versions. For brevity, the instructions assume the default installation location of C:\Program Files (x86)\Galil\gclib and a build type of x86 (win32).

### Launch the compiler command prompt

- Open VS2013 x86 Native Tools Command Prompt.
- Navigate to a convenient, writable location, e.g. C:\temp.

### Set an environment variable for the base path

    C:\temp>set base=C:\Program Files (x86)\Galil\gclib

### Compile the source code

Note the quotes.

    C:\temp>cl -c "%base%\source\wrappers\gcl\*.cpp" -I "%base%\include" -EHsc -MD

### Link the source code

Note the quotes.

    C:\temp>link /DLL gcl_datarecord.obj gcl_galil.obj "%base%\lib\dynamic\x86\gclib.lib" "%base%\lib\dynamic\x86\gclibo.lib" /OUT:galil2.dll

The output files galil2.dll and galil2.lib can now be used in a project using the GCL.

### Test

Help the loader find the right dlls.

    C:\temp>set PATH=%PATH%;%BASE%\dll\x86

Link the simple example.

    C:\temp>link gcl_simple.obj "%base%\lib\dynamic\x86\gclib.lib" "%base%\lib\dynamic\x86\gclibo.lib" galil2.lib /OUT:simple.exe

Run the example.

    C:\temp>simple.exe
    Galil2.dll wrapper, gclib 106.75.180
    10.1.3.169, DMC4020 Rev 1.2c, 291

<!— *********************************************************************************** -->

## Linux

<!— *********************************************************************************** -->

### Copy files

    $ tar -xzf /usr/share/doc/gclib/src/gclib_gcl.tar.gz
    $ ls
    Galil.h             gcl_galil.cpp  gcl_simple.cpp
    gcl_datarecord.cpp  gcl_galil.h    makefile

### Make and install

    $ make
    gcl open source wrapper for gclib
      Compiling wrapper, libgalil.so.2.0
    g++ -c -fPIC -std=c++11 gcl_datarecord.cpp  gcl_galil.cpp
      Linking wrapper into shared library.
    g++ -shared -o libgalil.so.2.0 *.o -Wl,-soname=libgalil.so.2
    strip --strip-unneeded libgalil.so.2.0
      Cleaning up.
    $ sudo make install
    Installing libgalil.so.2.0
    install -m 755 libgalil.so.2.0 /usr/lib
    install -m 644 Galil.h /usr/lib
    ldconfig
    ln -s /usr/lib/libgalil.so.2 /usr/lib/libgalil.so
    $ make clean
    Cleaning project...

### Test

    $ g++ gcl_simple.cpp -lgalil -lgclib -lgclibo -o simple
    $ ./simple
    Galil2.dll wrapper, gclib 95.71.164
    10.1.3.169, DMC4020 Rev 1.2c, 291