| gclib 424 Communications API for Galil controllers and PLCs |

gcl.md
1 # GalilTools {#gcl}
2
3 To provide maximum compatibility, gclib ships with an open source wrapper implementation of the GCL
4 (GalilTools Communication Library). Users wanting to upgrade to gclib that have source built on Galil.h
5 can use this wrapper to minimize source changes. This wrapper is also indicated for users that want the
6 same function calls as Galil.h, but don't want the usage of <a href="http://qt-project.org/">QT</a>
7 as in galil1.dll.
8
9 **This wrapper is intended for existing applications already using the library distributed with GalilTools (galil1.dll)
10 or the previous *STL* library (galil2.dll). New applications should be written with gclib.**
11
12 <!--- *********************************************************************************** -->
13 ***
14 ## Windows
15 ***
16 <!--- *********************************************************************************** -->
17
18 ###Compile galil2.dll with MSVC 2013
19 The following instructions were performed on *Visual Studio Professional 2013* and can be extended to other Visual Studio versions.
20 For brevity, the instructions assume the default installation location of **C:\\Program Files (x86)\\Galil\\gclib** and a build type of **x86 (win32)**.
21
22 ###Launch the compiler command prompt
23
24 * Open *VS2013 x86 Native Tools Command Prompt*.
25 * Navigate to a convenient, writable location, e.g. *C:\\temp*.
26
27 ###Set an environment variable for the base path
28
29 C:\temp>set base=C:\Program Files (x86)\Galil\gclib
30
31 ###Compile the source code
32 **Note the quotes.**
33
34 C:\temp>cl -c "%base%\source\wrappers\gcl\*.cpp" -I "%base%\include" -EHsc -MD
35
36 ###Link the source code
37 **Note the quotes.**
38
39 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
40
41 The output files *galil2.dll* and *galil2.lib* can now be used in a project using the GCL.
42
43 ###Test
44 Help the loader find the right dlls.
45
46 C:\temp>set PATH=%PATH%;%BASE%\dll\x86
47
48 Link the simple example.
49
50 C:\temp>link gcl_simple.obj "%base%\lib\dynamic\x86\gclib.lib" "%base%\lib\dynamic\x86\gclibo.lib" galil2.lib /OUT:simple.exe
51
52 Run the example.
53
54 C:\temp>simple.exe
55 Galil2.dll wrapper, gclib 106.75.180
56 10.1.3.169, DMC4020 Rev 1.2c, 291
57
58
59 <!--- *********************************************************************************** -->
60 ***
61 ## Linux
62 ***
63 <!--- *********************************************************************************** -->
64
65 ###Copy files
66
67 $ tar -xzf /usr/share/doc/gclib/src/gclib_gcl.tar.gz
68 $ ls
69 Galil.h gcl_galil.cpp gcl_simple.cpp
70 gcl_datarecord.cpp gcl_galil.h makefile
71
72 ###Make and install
73
74 $ make
75 gcl open source wrapper for gclib
76 Compiling wrapper, libgalil.so.2.0
77 g++ -c -fPIC -std=c++11 gcl_datarecord.cpp gcl_galil.cpp
78 Linking wrapper into shared library.
79 g++ -shared -o libgalil.so.2.0 *.o -Wl,-soname=libgalil.so.2
80 strip --strip-unneeded libgalil.so.2.0
81 Cleaning up.
82 $ sudo make install
83 Installing libgalil.so.2.0
84 install -m 755 libgalil.so.2.0 /usr/lib
85 install -m 644 Galil.h /usr/lib
86 ldconfig
87 ln -s /usr/lib/libgalil.so.2 /usr/lib/libgalil.so
88 $ make clean
89 Cleaning project...
90
91 ###Test
92
93 $ g++ gcl_simple.cpp -lgalil -lgclib -lgclibo -o simple
94 $ ./simple
95 Galil2.dll wrapper, gclib 95.71.164
96 10.1.3.169, DMC4020 Rev 1.2c, 291
97
98
99
100
101
102
103
104
105