|
|
Line 1: |
Line 1: |
| [[Category:Language]]{{NoTitle}} | | #REDIRECT [[Language - C]] |
| {|
| |
| |style="vertical-align:middle; width: 60%;"|
| |
| <font size=6>'''Language - C'''
| |
| | |
| '''Linux with GCC'''</font>
| |
| | |
| 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 like Linux. It allows compilation of C programs from the command line.
| |
| |{{TOC limit|2}}
| |
| |}
| |
| {{Language_-_C_Intro|Linux|GCC}}
| |
| | |
| {{Finding Code Samples|C}}
| |
| | |
| ==Using the Code Samples==
| |
| To use the code sample from the [{{server}}/?view=code_samples&lang=C Code Samples] page, you can click the '''Download Example''' button to download a C file with the sample code.
| |
| | |
| [[Image:C_Sample_Code_Download.png|link=|center|border|800px]]
| |
| | |
| | |
| Once you have the example, you can compile and run your code:
| |
| | |
| ==Compile and Run==
| |
| | |
| To compile C programs, you will need gcc. You likely have gcc installed on your Linux machine already, but if not, you can easily get it by entering the following command in the terminal:
| |
| <syntaxhighlight lang='C'>
| |
| apt-get install gcc
| |
| </syntaxhighlight>
| |
| | |
| To compile the program, enter the following command in the terminal, substituting "example" for the name of your C file:
| |
| | |
| <syntaxhighlight lang='bash'>
| |
| gcc example.c -o example -lphidget22
| |
| </syntaxhighlight>
| |
| | |
| After compiling, you can run the program by entering the following command in the terminal:
| |
| <syntaxhighlight lang='bash'>
| |
| ./example
| |
| </syntaxhighlight>
| |
| | |
| Success! The project now has access to Phidgets.
| |
| | |
| {{Language Page What's Next}}
| |