Language - C Windows GCC
Language - C Windows with GCC Welcome to using Phidgets with C! By using C, you will have access to the complete Phidget22 API, including events. GCC is a compiler system for originally written for GNU, and is the standard compiler on unix-like operating systems. It is available on Windows by using tools like MinGW or Cygwin to allow compilation of C programs from the command line. |
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
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
To use the code sample from the Code Samples page, you can click the Download Example button to download a C file with the sample code.
Once you have the example, you can compile and run your code:
Compile and Run
In order compile C programs from the command prompt, you will need to download and install either MinGW or Cygwin.
Next, navigate to the folder where your code is and open the command prompt.
The specific command you will use depends on your compiler of choice. Select the tab for your compiler below, and enter the command within to compile your program, substituting "example" for the name of your C file:
gcc example.c -o example -I"/cygdrive/c/Program Files/Phidgets/Phidget22"-L"/cygdrive/c/Program Files/Phidgets/Phidget22/x86" -lphidget22
gcc example.c -o example -I"/cygdrive/c/Program Files/Phidgets/Phidget22" -L"/cygdrive/c/Program Files/Phidgets/Phidget22" -lphidget22
gcc example.c -o example -I"C:/Program Files/Phidgets/Phidget22" -L"C:/Program Files/Phidgets/Phidget22/x86" -lphidget22
After running the commands above for either Cygwin or MinGW, an executable file called example.exe will be created. Enter the following command to run the program:
example.exe
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.