Language - C Windows CodeBlocks: Difference between revisions

From Phidgets Support
No edit summary
(Redirected page to Language - C)
 
(6 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}}
 
 
Next, open Code::Blocks, 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]]
 
 
From the Global compiler settings screen, navigate to Linker settings and add the following line:
*phidget22
 
[[Image:C_codeblocks_libraries.PNG|link=|center]]
 
Next, create a new Console Application project, as follows:
 
[[Image:C_codeblocks_console_application.png|link=|center]]
 
Name your project, and finish creating the project.
 
[[Image:C_codeblocks_name_project.png|link=|center]]
 
Next, remove main.c from the created project.
 
[[Image:C_codeblocks_remove_main.png|link=|center]]
 
Copy the files from your downloaded example and paste them into the project directory.
 
[[Image:C_codeblocks_project_directory.png|link=|center]]
 
Add the example C file, and PhidgetHelperFunctions.c to the project.
 
[[Image:C_codeblocks_project_with_files.png|link=|center]]
 
Lastly, you'll need to add the common directory to your project search directories. Right-click your project:
 
[[Image:C_codeblocks_project_build_options.png|link=|center]] 
 
Then add the common directory under "Search directories":
[[Image:C_codeblocks_add_project_directory.png|link=|center]]
 
You can now build and run the example:
 
[[Image:C_codeblocks_run.png|link=|center]]
 
{{Edit_the_Examples}}
 
{{Language_-_C_Editing_The_Examples}}
 
{{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}}

Latest revision as of 17:00, 15 March 2021

Redirect to: