Language - C Windows Visual Studio: Difference between revisions

From Phidgets Support
(Created page with "{{NoTitle}} {{Language_-_C_Dev_Environment_Table}} {| |style="vertical-align:middle; width: 60%;"| <font size=6>'''Language - C''' '''Windows with Visual Studio'''</font> We...")
 
(Redirected page to Language - C)
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{NoTitle}}
#REDIRECT [[Language - C]]
{{Language_-_C_Dev_Environment_Table}}
{|
|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}}
 
==Use Our Examples==
One of the best ways to start programming with Phidgets is to use our example code as a guide. In order to run the examples, you will need to download and install [https://www.visualstudio.com/ Microsoft Visual Studio].
 
 
Now that you have Microsoft Visual Studio installed, select an example that will work with your Phidget:
*{{SampleCode|C|C Examples}}
 
 
Open the example project and start the example by pressing the ''Local Windows Debugger'' button:
 
 
[[Image: c_vs_run.png|link=|center]]
 
 
The application will open the Phidget, list basic information about the Phidget, and demonstrate the Phidget's functionality. Here is an example of an Accelerometer channel on a Spatial Phidget:
 
 
[[Image: c_vs_output.PNG|link=|center]]
 
{{Edit_the_Examples}}
 
{{Language_-_C_Write_Code}}
 
==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]]
 
 
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]]
 
 
Next, add a new item to your source folder:
 
[[Image:C_vs_additem.png|link=|center]]
 
 
Give the source file a descriptive name and continue:
 
[[Image:C_vs_addsource.PNG|link=|center]]
 
 
Access the project's properties:
 
[[Image:C_vs_propertie.png|link=|center]]
 
 
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]]
 
 
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]]
 
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]]
 
Success! The project now has access to Phidgets.
 
{{Language_-_C_Further_Reading}}

Latest revision as of 17:01, 15 March 2021

Redirect to: