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