gclib  339
Communications API for Galil controllers and PLCs
 All Data Structures Files Functions Variables Typedefs Macros Pages
Rebuilding gclibo

gclib ships with a compiled version of the open source portion, gclibo. However, if a source modification is desired, the following instructions will help with recompiling this portion of the library.


Windows


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

Open VS2013 x86 Native Tools Command Prompt.

Copy files

Navigate to a convenient, empty, writable location, e.g. C:\temp.

Set an environment variable for the base path.

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

Copy the source files. Note the quotes.

C:\temp>copy "%base%\source\gclibo\*.c" .

Modify source

Make any necessary changes. For this example, the GInfo() function was changed from

{
return GUtility(g, G_UTIL_INFO, info, &info_len);
}

to

{
strncpy(info, "My controller", info_len);
return G_NO_ERROR;
//return GUtility(g, G_UTIL_INFO, info, &info_len);
}

Compile and copy

Compile the source code. Note the quotes.

C:\temp>cl -c *.c -I "%base%\include" -DBUILDING_GCLIB

Link the source code. Note the quotes.

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

Copy

Copy back to the installation location from the file explorer.

  • Copy gclibo.lib to "C:\Program Files (x86)\Galil\gclib\lib\dynamic\x86"
  • Copy gclibo.dll to "C:\Program Files (x86)\Galil\gclib\dll\x86"

Test

Copy simple example

C:\temp>copy "%base%\examples\cpp\x_simple.c" .

Edit GOpen() call as necessary

Compile

C:\temp>cl x_simple.c "%base%\lib\dynamic\x86\*.lib" -I "%base%\include"

Set Path to DLL

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

Execute

C:\temp>x_simple.exe
rc: 0
version: 85.60.138
rc: 0
rc: 0
info: My controller
rc: 0
response:  355000958.0000
:

Linux


Copy files

$ mkdir test
$ cd test
$ tar -xvf /usr/share/doc/gclib/src/gclibo_164_src.tar.gz
gclibo.h
gclibo.c
arrays.c
makefile_gclibo
$ cp /usr/include/gclib*.h .
$ ls
arrays.c        gclib.h   gclibo.h        makefile_gclibo
gclib_errors.h  gclibo.c  gclib_record.h

Modify source

Make any necessary changes. For this example, the GInfo() function was changed from

{
return GUtility(g, G_UTIL_INFO, info, &info_len);
}

to

{
strncpy(info, "My controller", info_len);
return G_NO_ERROR;
//return GUtility(g, G_UTIL_INFO, info, &info_len);
}

Make and install

$ make -f makefile_gclibo 
Open source component, libgclibo.so.0.0
  Compiling open source component.
gcc -c -Wall -Werror -fPIC -fvisibility=hidden -DBUILDING_GCLIB -DHAVE_VISIBILITY *.c
  Linking open source component into shared library.
gcc -shared -o libgclibo.so.0.0 *.o -Wl,-soname=libgclibo.so.0
strip --strip-unneeded libgclibo.so.0.0
  Cleaning up.
$ sudo make install -f makefile_gclibo 
Installing libgclibo.so.0.0
install -m 755 libgclibo.so.0.0 /usr/lib
ldconfig
$ make clean -f makefile_gclibo 
Cleaning project...

Test

Extract simple example

$ tar -xzf /usr/share/doc/gclib/src/gclib_165_examples.tar.gz x_simple.c

Edit GOpen() call as necessary.

Compile

$ gcc x_simple.c -Wall -Werror -lgclib -lgclibo -o simple

Execute

$ ./simple
rc: 0
version: 85.60.131
rc: 0
rc: 0
info: My controller
rc: 0
response:  182879322.0000
:

OS X


Copy files

$ mkdir test
$ cd test
$ tar -xvf /Applications/gclib/source/gclibo_253_src.tar.gz x gclibo.h
x gclibo.c
x arrays.c
x makefile_gclibo
$ cp /Applications/gclib/include/* .
$ cp /Applications/gclib/dylib/gclib.0.dylib .
$ ls
arrays.c  gclib.h   gclib_record.h  gclibo.h
gclib.0.dylib gclib_errors.h  gclibo.c  makefile_gclibo

Modify source

Make any necessary changes. For this example, the GInfo() function was changed from

{
return GUtility(g, G_UTIL_INFO, info, &info_len);
}

to

{
strncpy(info, "My controller", info_len);
return G_NO_ERROR;
//return GUtility(g, G_UTIL_INFO, info, &info_len);
}

Make and install

$ make -f makefile_gclibo 
Open source component, gclibo.0.dylib
  Compiling open source component.
gcc -c -Wall -Werror -fPIC -fvisibility=hidden -DBUILDING_GCLIB -DHAVE_VISIBILITY *.c
  Linking open source component into shared library.
gcc -dynamiclib -o gclibo.0.dylib *.o gclib.0.dylib
strip -u -r gclibo.0.dylib
  Cleaning up.
$ make install -f makefile_gclibo 
Installing gclibo.0.dylib
cp gclibo.0.dylib /Applications/gclib/dylib
$ make clean -f makefile_gclibo 
Cleaning project...

Test

Extract simple example

$ tar -xzf /Applications/gclib/examples/gclib_253_examples.tar.gz x_simple.c

Edit GOpen() call as necessary.

Compile

$ gcc x_simple.c -Wall -Werror gclib.0.dylib gclibo.0.dylib -o simple

Execute

$ ./simple
rc: 0
version: 127.110.253
rc: 0
rc: 0
info: My controller
rc: 0
response:  182879322.0000
: