gclib  386
Communications API for Galil controllers and PLCs
 All Data Structures Files Functions Variables Typedefs Macros Pages
Microsoft Visual Studio

For brevity, these instructions assume the default installation location of C:\Program Files (x86)\Galil\gclib.

x_simple.c from VS2013 x64 Native Tools Command Prompt

Open VS2013 x64 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 simple example

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

Edit GOpen() call as necessary

In a text editor, open x_simple.c. Find the GOpen() call and update the address to match the desired hardware. See the documentation for GOpen() for address formatting options.

Compile

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

Set Path to DLL

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

Execute

C:\temp>x_simple.exe
rc: 0
version: 85.60.138
rc: 0
rc: 0
info: 10.1.3.17, DMC4020 Rev 1.2b, 291
rc: 0
response:  357247808.0000
:

Using the pre-configured MSVC project (x_examples.cpp)

The directory gclib\examples\msvc has fully functional MSVC examples. These instructions detail how to use the 2013 version.

  • Copy gclib\examples\msvc\2013_12.0\gclib_example to a convenient, writable location, e.g. C:\temp.
  • Run gclib_example\gclib_example\copy_source.bat to copy the files.
  • Open gclib_example\gclib_example.sln in Visual Studio 2013.
  • In the Solution Explorer, expand the gclib_example and expand Source Files to show a listing of source.
  • Open x_examples.cpp
  • Find the GOpen() call and update the address to match the desired hardware. See the documentation for GOpen() for address formatting options.
  • Find the #if 0 preprocessor block enclosing the example calls. Change to #if 1 to run the examples. Comment out the function calls to be avoided. Note some calls attempt to move motors and not all functions are compatible with all Galil products.
  • Hit F5 to build and run the example.

Create Project with MSVC 2013 (x_examples.cpp)

The instructions below allow building a project from scratch.

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 Visual Studio 2013
  • Choose File->New->Project
  • In the New Project dialog, choose Visual C++->Empty Project
  • Choose a Name, e.g. gclib_example
  • Choose a Location, e.g. C:\Users\user\Desktop
  • Check Create directory for solution
  • Click OK
  • In the Solution Explorer, right-click on Source Files and choose Add->Existing Item
    • Navigate to the gclib installation directory, then to examples\cpp in the installation directory
    • In File Name type x_*.cpp and click Add, this will filter out the files needed
    • Select all files in the file chooser and click Add
  • In the Solution Explorer right-click on gclib_example, choose Properties, highlight Configuration Properties, and set the following project properties
    • At the top of the window, change Configuration: to All Configurations and ensure Platform lists Active(Win32)
    • Configuration Properties -> C/C++ -> Additional Include Directories add C:\Program Files (x86)\Galil\gclib\include
    • Configuration Properties -> Linker -> General -> Additional Library Directories add C:\Program Files (x86)\Galil\gclib\lib\dynamic\x86
    • Configuration Properties -> Linker -> Input -> Additional Dependencies add gclib.lib;gclibo.lib;{rest of text} where {rest of text} is the original string that was in the cell. Note the semicolons between library files.
    • Configuration Properties -> Debugging -> Environment add PATH=C:\Program Files (x86)\Galil\gclib\dll\x86;%PATH%
  • In the Solution Explorer open x_examples.cpp. Find the GOpen() call and update the address to match the desired hardware. See the documentation for GOpen() for address formatting options.
  • Find the #if 0 preprocessor block enclosing the example calls. Change to #if 1 to run the examples. Comment out the function calls to be avoided. Note some calls attempt to move motors and not all functions are compatible with all Galil products.
  • Hit F5 to build and run the example.