Language - C macOS GCC: Difference between revisions

From Phidgets Support
No edit summary
(Redirected page to Language - C)
 
(11 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'''
 
'''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. GCC is readily available on macOS, and can be used to compile C programs from the terminal.
|{{TOC limit|2}}
|}
{{Language_-_C_Intro|macOS|GCC}}
 
==Use Our Examples==
One of the best ways to start programming with Phidgets is to use our example code as a guide. You likely have gcc installed on your macOS machine already, but if not, you can easily get it by downloading [https://developer.apple.com/xcode/ Xcode].
 
Next, select an example that will work with your Phidget:
*{{SampleCode|C|C Examples}}
 
 
To compile the example program, enter the following command in the terminal:
<syntaxhighlight lang='bash'>
gcc example.c ../Common/PhidgetHelperFunctions.c -o example -F /Library/Frameworks -framework Phidget22 -I /Library/Frameworks/Phidget22.framework/Headers -I ../Common
</syntaxhighlight>
 
Finally, run the program by entering the following command in the terminal:
<syntaxhighlight lang='bash'>
./example
</syntaxhighlight>
 
 
[[Image:c_mac_gcc.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.
 
The project now has access to Phidgets.
 
{{Language_-_C_Further_Reading}}

Latest revision as of 16:36, 15 March 2021

Redirect to: