Language - C Windows CodeBlocks: Difference between revisions

From Phidgets Support
No edit summary
(Redirected page to Language - C)
 
Line 1: Line 1:
{{NoTitle}}
#REDIRECT [[Language - C]]
{|
|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}}
 
{{Finding Code Samples|C}}
 
==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 start, 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]]
 
 
Now your project is created, and you can open the generated main.c to begin coding.
 
To include the Phidget C library, add the following line to your code:
<syntaxhighlight lang='C'>
#include <phidget22.h>
</syntaxhighlight>
 
Your project now has access to the Phidget libraries.
 
==Using the Code Samples==
Now that you have configured a project to use Phidgets, you can copy the code sample from the [{{server}}/?view=code_samples&lang=C Code Samples] page into your project, and run it.
 
{{Language Page What's Next}}

Latest revision as of 17:00, 15 March 2021

Redirect to: