msvc.md

00001 # Microsoft Visual Studio  {#msvc}
00002 
00003 For brevity, these instructions assume the default installation location of **C:\\Program Files (x86)\\Galil\\gclib**.
00004 
00005 ## x_simple.c from *VS2013 x64 Native Tools Command Prompt*
00006 
00007 Open *VS2013 x64 Native Tools Command Prompt*.
00008 
00009 ###Copy files
00010 Navigate to a convenient, empty, writable location, e.g. *C:\\temp*.
00011 
00012 #### Set an environment variable for the base path.
00013 
00014     C:\temp>set base=C:\Program Files (x86)\Galil\gclib
00015 
00016 #### Copy simple example
00017 
00018     C:\temp>copy "%base%\examples\cpp\x_simple.c" .
00019 
00020 ### Edit GOpen() call as necessary
00021 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.
00022 
00023 ### Compile
00024   
00025     C:\temp>cl x_simple.c "%base%\lib\dynamic\x64\*.lib" -I "%base%\include"
00026 
00027 ### Set Path to DLL
00028 
00029     C:\temp>set PATH=%base%\dll\x64\;%PATH%
00030 
00031 ### Execute
00032 
00033     C:\temp>x_simple.exe
00034     rc: 0
00035     version: 85.60.138
00036     rc: 0
00037     rc: 0
00038     info: 10.1.3.17, DMC4020 Rev 1.2b, 291
00039     rc: 0
00040     response:  357247808.0000
00041     :
00042 
00043 
00044 ##Using the pre-configured MSVC project (x_examples.cpp)
00045 
00046 The directory *gclib\\examples\\msvc* has fully functional MSVC examples. These instructions detail how to use the 2013 version.
00047 
00048 * Copy *gclib\\examples\\msvc\\2013_12.0\\gclib_example*  to a convenient, writable location, e.g. *C:\\temp*.
00049 * Run *gclib_example\\gclib_example\\copy_source.bat* to copy the files.
00050 * Open *gclib_example\\gclib_example.sln* in Visual Studio 2013.
00051 * In the *Solution Explorer*, expand the *gclib_example* and expand *Source Files* to show a listing of source. 
00052 * Open *x_examples.cpp*
00053 * Find the GOpen() call and update the address to match the desired hardware. See the documentation for GOpen() for address formatting options. 
00054 * 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.
00055 * Hit *F5* to build and run the example.
00056 
00057 
00058 ##Create Project with MSVC 2013 (x_examples.cpp)
00059 
00060 The instructions below allow building a project from scratch.
00061 
00062 The following instructions were performed on *Visual Studio Professional 2013* and can be extended to other Visual Studio versions. 
00063 For brevity, the instructions assume the default installation location of **C:\\Program Files (x86)\\Galil\\gclib** and a build type of **x86 (win32)**.
00064 
00065 * Launch *Visual Studio 2013*
00066 * Choose *File->New->Project*
00067 * In the *New Project* dialog, choose *Visual C++->Empty Project*
00068 * Choose a Name, e.g. **gclib_example**
00069 * Choose a Location, e.g. *C:\\Users\\user\\Desktop*
00070 * Check *Create directory for solution*
00071 * Click *OK*
00072 * In the *Solution Explorer*, right-click on *Source Files* and choose *Add->Existing Item*
00073  * Navigate to the gclib installation directory, then to *examples\\cpp* in the installation directory
00074  * In *File Name* type **x_*.cpp** and click *Add*, this will filter out the files needed
00075  * Select all files in the file chooser and click *Add*
00076 * In the *Solution Explorer* right-click on *gclib_example*, choose *Properties*, highlight *Configuration Properties*, and set the following project properties
00077  * At the top of the window, change *Configuration:* to *All Configurations* and ensure *Platform* lists *Active(Win32)*
00078  * *Configuration Properties -> C/C++ -> Additional Include Directories* add **C:\\Program Files (x86)\\Galil\\gclib\\include**
00079  * *Configuration Properties -> Linker -> General -> Additional Library Directories* add **C:\\Program Files (x86)\\Galil\\gclib\\lib\\dynamic\\x86**
00080  * *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.
00081  * *Configuration Properties -> Debugging -> Environment* add **PATH=C:\\Program Files (x86)\\Galil\\gclib\\dll\\x86;\%PATH%**
00082 * 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. 
00083 * 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.
00084 * Hit *F5* to build and run the example.