Language - C Windows Visual Studio: Difference between revisions
No edit summary |
|||
Line 29: | Line 29: | ||
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'''. | 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|800px]] | [[File:C_Visual_Studio_Sample_Download.jpg|center|border|link=|800px]] | ||
Revision as of 16:22, 22 October 2019
Language - C Windows with Visual Studio 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++. |
Install Phidget Drivers for Windows
Before getting started with the guides below, ensure you have the following components installed on your machine:
- You will need the Phidgets Windows Drivers
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:
Finding Code Samples
To find the code sample to use for your Phidget, navigate to the Code Samples page and select your device from the drop-down menu.
Once you select your device, the code sample generator will give you a working code sample, and a selection of options to customize it to your needs.
Using the Code Samples
You can download a working Visual Studio project for C directly from the Code Samples page. Simply make your selections, and click the Visual Studio Project button under Downloads.
Open the example project and start the example by pressing the Start button:
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:
Select an empty project and finish:
If you are using a 64-bit machine, select x64, otherwise, keep x86:
Next, add a new item to your source folder:
Give the source file a descriptive name and continue:
Access the project's properties:
Next, navigate to Configuration Properties -> C/C++ -> General and add the following line to the additional include directories:
- C:\Program Files\Phidgets\Phidget22
Navigate to Configuration Properties -> Linker -> Input and add the following line to the additional dependencies:
- C:\Program Files\Phidgets\Phidget22\phidget22.lib
Finally, include the Phidget library in your code, and any other header files:
#include <phidget22.h>
Success! The project now has access to Phidgets.
What's Next?
Now that you have set up Phidgets to work with your programming environment, we recommend you read our guide on Phidget Programming Basics to learn the fundamentals of programming with Phidgets.