|
|
(7 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 Code::Blocks'''</font>
| |
| | |
| Welcome to using Phidgets with C! By using C, you will have access to the complete Phidget22 API, including events.
| |
| | |
| Code::Blocks is a free, open source cross-platform IDE that can be used for C and C++.
| |
| |{{TOC limit|2}}
| |
| |}
| |
| {{Language_-_C_Intro|Windows|Code::Blocks}}
| |
| | |
| ==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 [http://www.codeblocks.org/downloads Code::Blocks].
| |
| | |
| | |
| Now that you have Code::Blocks installed, select an example that will work with your Phidget:
| |
| *{{SampleCode|C|C Examples}}
| |
| | |
| | |
| Open the example in Code::Blocks (you do not need to create a new project) and navigate to Settings -> Compiler... as shown in the image below:
| |
| | |
| [[Image:C_codeblocks_settings.png|link=|center]] | |
| | |
| | |
| From the Global compiler settings screen, navigate to Search directories -> Compiler and add the following directory:
| |
| *C:\Program Files\Phidgets\Phidget22
| |
| | |
| [[Image:C_codeblocks_compiler.PNG|link=|center]]
| |
| | |
| | |
| Next, select Search directories -> Linker and add the following directory:
| |
| *C:\Program Files\Phidgets\Phidget22\x86
| |
| | |
| [[Image:C_codeblocks_linker.PNG|link=|center]]
| |
| | |
| | |
| Finally, from the Global compiler settings screen, navigate to Linker settings and add the following line:
| |
| *phidget22
| |
| | |
| [[Image:C_codeblocks_libraries.PNG|link=|center]]
| |
| | |
| | |
| You can now build and run the example:
| |
| | |
| [[Image:C_codeblocks_run.png|link=|center]]
| |
| | |
| {{Edit_the_Examples}}
| |
| | |
| ==Editing the Examples==
| |
| {{Language_-_C_Editing_The_Examples}}
| |
| | |
| ==Write Code==
| |
| {{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 include the Phidget C library, add the following line to your code:
| |
| <syntaxhighlight lang='C'>
| |
| #include <phidget22.h>
| |
| </syntaxhighlight>
| |
| | |
| You can now compile the file as shown in the [[#Use Our Examples|Use Our Examples]] section.
| |
| | |
| {{Language_-_C_Further_Reading}}
| |