|
|
Line 1: |
Line 1: |
| [[Category:Language]]{{NoTitle}} | | #REDIRECT [[Language - C]] |
| {|
| |
| |style="vertical-align:middle; width: 60%;"|
| |
| <font size=6>'''Language - C'''
| |
| | |
| '''Windows 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. It is available on Windows by using tools like MinGW or Cygwin to allow compilation of C programs from the command line.
| |
| |{{TOC limit|2}}
| |
| |}
| |
| | |
| {{Language_-_C_Intro|Windows|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==
| |
| In order compile C programs from the command prompt, you will need to download and install either [http://www.mingw.org/ MinGW] or [https://www.cygwin.com/ 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:
| |
| | |
| <tabber>
| |
| Cygwin x86=
| |
| <syntaxhighlight lang='bash'>
| |
| gcc example.c -o example -I"/cygdrive/c/Program Files/Phidgets/Phidget22"-L"/cygdrive/c/Program Files/Phidgets/Phidget22/x86" -lphidget22
| |
| </syntaxhighlight>
| |
| |-|
| |
| Cygwin x64=
| |
| <syntaxhighlight lang='bash'>
| |
| gcc example.c -o example -I"/cygdrive/c/Program Files/Phidgets/Phidget22" -L"/cygdrive/c/Program Files/Phidgets/Phidget22" -lphidget22
| |
| </syntaxhighlight>
| |
| |-|
| |
| MinGW=
| |
| <syntaxhighlight lang='bash'>
| |
| gcc example.c -o example -I"C:/Program Files/Phidgets/Phidget22" -L"C:/Program Files/Phidgets/Phidget22/x86" -lphidget22
| |
| </syntaxhighlight>
| |
| </tabber>
| |
| | |
| | |
| 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:
| |
| <syntaxhighlight lang='bash'>
| |
| example.exe
| |
| </syntaxhighlight>
| |
| | |
| {{Language Page What's Next}}
| |