|
|
(One intermediate revision by the same user not shown) |
Line 1: |
Line 1: |
| {{NoTitle}}
| | #REDIRECT [[Language - C]] |
| {|
| |
| |style="vertical-align:middle; width: 60%;"|
| |
| <font size=6>'''Language - C'''
| |
| | |
| '''Windows with Visual Studio'''</font>
| |
| | |
| Welcome to using Phidgets with C! By using C, you will have access to the complete Phidget22 API, including events.
| |
| | |
| Visual Studio is an IDE provided by Microsoft that can be used to develop code in a wide variety of programming languages, including C/C++.
| |
| |{{TOC limit|2}}
| |
| |}
| |
| | |
| {{Language_-_C_Intro|Windows|Visual Studio|link=}}
| |
| | |
| ==Using Phidgets in Your Programs==
| |
| | |
| There are two main ways you can go about adding Phidgets to your programs in Visual Studio. You can either start from a working project provided by the Phidgets code sample generator, or you can add the Phidgets libraries to an existing Visual Studio project.
| |
| | |
| Select your preferred method below for instructions:
| |
| | |
| | |
| <tabber>
| |
| Using Code Samples=
| |
| {{Finding Code Samples|C}}
| |
| | |
| ==Using the Code Samples==
| |
| | |
| You can download a working '''Visual Studio''' project for '''C''' directly from the [{{server}}/?view=code_samples&lang=C Code Samples] page. Simply make your selections, and click the '''Visual Studio Project''' button under '''Downloads'''.
| |
| | |
| [[File:C_Visual_Studio_Sample_Download.jpg|center|border|link=|800px]] | |
| | |
| | |
| Open the example project and start the example by pressing the ''Start'' button:
| |
| | |
| [[File:Csharp_visualstudio_run.png |link=|center]]
| |
| | |
| |-|
| |
| Adding Phidgets to an Existing Project=
| |
| | |
| ==Setting up a New Project==
| |
| When you are building a project from scratch, or adding Phidget functionality to an existing project, you'll need to configure your development environment to properly link the Phidget C library. To begin:
| |
| | |
| | |
| Create a new Win32 Console application:
| |
| | |
| [[Image:C_vs_newproject.PNG|link=|center|800px]]
| |
| | |
| | |
| Select an empty project and finish:
| |
| | |
| [[Image:C_vs_emptyproject.PNG|link=|center]]
| |
| | |
| | |
| If you are using a 64-bit machine, select x64, otherwise, keep x86:
| |
| | |
| [[Image:C_vs_configuration.png|link=|center|800px]]
| |
| | |
| | |
| Next, add a new item to your source folder:
| |
| | |
| [[Image:C_vs_additem.png|link=|center|800px]]
| |
| | |
| | |
| Give the source file a descriptive name and continue:
| |
| | |
| [[Image:C_vs_addsource.PNG|link=|center|800px]]
| |
| | |
| | |
| Access the project's properties:
| |
| | |
| [[Image:C_vs_propertie.png|link=|center|800px]]
| |
| | |
| | |
| Next, navigate to Configuration Properties -> C/C++ -> General and add the following line to the additional include directories:
| |
| *C:\Program Files\Phidgets\Phidget22
| |
| | |
| | |
| [[Image:C_vs_additionalinclude.png|link=|center|800px]]
| |
| | |
| | |
| Navigate to Configuration Properties -> Linker -> Input and add the following line to the additional dependencies:
| |
| *C:\Program Files\Phidgets\Phidget22\phidget22.lib
| |
| | |
| | |
| [[Image:C_vs_additionadepend.png|link=|center|800px]]
| |
| | |
| Finally, include the Phidget library in your code, and any other header files:
| |
| | |
| <syntaxhighlight lang='C'>
| |
| #include <phidget22.h>
| |
| </syntaxhighlight>
| |
| | |
| [[Image:C_vs_finished.PNG|link=|center|800px]]
| |
| | |
| | |
| Success! The project now has access to Phidgets.
| |
| | |
| </tabber>
| |
| | |
| {{Language Page What's Next}}
| |