| gclib 367 Communications API for Galil controllers and PLCs |

All Data Structures Files Functions Variables Typedefs Macros Pages
msvc.md
1 # Microsoft Visual Studio {#msvc}
2
3 For brevity, these instructions assume the default installation location of **C:\\Program Files (x86)\\Galil\\gclib**.
4
5 ## x_simple.c from *VS2013 x64 Native Tools Command Prompt*
6
7 Open *VS2013 x64 Native Tools Command Prompt*.
8
9 ###Copy files
10 Navigate to a convenient, empty, writable location, e.g. *C:\\temp*.
11
12 #### Set an environment variable for the base path.
13
14 C:\temp>set base=C:\Program Files (x86)\Galil\gclib
15
16 #### Copy simple example
17
18 C:\temp>copy "%base%\examples\cpp\x_simple.c" .
19
20 ### Edit GOpen() call as necessary
21 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.
22
23 ### Compile
24
25 C:\temp>cl x_simple.c "%base%\lib\dynamic\x64\*.lib" -I "%base%\include"
26
27 ### Set Path to DLL
28
29 C:\temp>set PATH=%base%\dll\x64\;%PATH%
30
31 ### Execute
32
33 C:\temp>x_simple.exe
34 rc: 0
35 version: 85.60.138
36 rc: 0
37 rc: 0
38 info: 10.1.3.17, DMC4020 Rev 1.2b, 291
39 rc: 0
40 response: 357247808.0000
41 :
42
43
44 ##Using the pre-configured MSVC project (x_examples.cpp)
45
46 The directory *gclib\\examples\\msvc* has fully functional MSVC examples. These instructions detail how to use the 2013 version.
47
48 * Copy *gclib\\examples\\msvc\\2013_12.0\\gclib_example* to a convenient, writable location, e.g. *C:\\temp*.
49 * Run *gclib_example\\gclib_example\\copy_source.bat* to copy the files.
50 * Open *gclib_example\\gclib_example.sln* in Visual Studio 2013.
51 * In the *Solution Explorer*, expand the *gclib_example* and expand *Source Files* to show a listing of source.
52 * Open *x_examples.cpp*
53 * Find the GOpen() call and update the address to match the desired hardware. See the documentation for GOpen() for address formatting options.
54 * 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.
55 * Hit *F5* to build and run the example.
56
57
58 ##Create Project with MSVC 2013 (x_examples.cpp)
59
60 The instructions below allow building a project from scratch.
61
62 The following instructions were performed on *Visual Studio Professional 2013* and can be extended to other Visual Studio versions.
63 For brevity, the instructions assume the default installation location of **C:\\Program Files (x86)\\Galil\\gclib** and a build type of **x86 (win32)**.
64
65 * Launch *Visual Studio 2013*
66 * Choose *File->New->Project*
67 * In the *New Project* dialog, choose *Visual C++->Empty Project*
68 * Choose a Name, e.g. **gclib_example**
69 * Choose a Location, e.g. *C:\\Users\\user\\Desktop*
70 * Check *Create directory for solution*
71 * Click *OK*
72 * In the *Solution Explorer*, right-click on *Source Files* and choose *Add->Existing Item*
73 * Navigate to the gclib installation directory, then to *examples\\cpp* in the installation directory
74 * In *File Name* type **x_*.cpp** and click *Add*, this will filter out the files needed
75 * Select all files in the file chooser and click *Add*
76 * In the *Solution Explorer* right-click on *gclib_example*, choose *Properties*, highlight *Configuration Properties*, and set the following project properties
77 * At the top of the window, change *Configuration:* to *All Configurations* and ensure *Platform* lists *Active(Win32)*
78 * *Configuration Properties -> C/C++ -> Additional Include Directories* add **C:\\Program Files (x86)\\Galil\\gclib\\include**
79 * *Configuration Properties -> Linker -> General -> Additional Library Directories* add **C:\\Program Files (x86)\\Galil\\gclib\\lib\\dynamic\\x86**
80 * *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.
81 * *Configuration Properties -> Debugging -> Environment* add **PATH=C:\\Program Files (x86)\\Galil\\gclib\\dll\\x86;\%PATH%**
82 * 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.
83 * 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.
84 * Hit *F5* to build and run the example.