This document describes how to prepare your development environment to use the Microsoft Azure IoT device SDK for C. It describes preparing a development environment in Windows using Visual Studio and in Linux.
- Setting up a Windows development environment
- Setting up a Linux development environment
- Setting up a Windows Embedded Compact 2013 development environment
- Sample applications
-
Install Visual Studio 2015. You can use the free Community Edition if you meet the licensing requirements. Be sure to include Visual C++ and NuGet Package Manager.
-
Install git making sure git.exe can be run from a command line.
-
Clone the latest version of this repository to your local machine with the recursive parameter
git clone --recursive https://github.com/Azure/azure-iot-sdks.git
Use the master branch to ensure you fetch the latest release version.
-
Cloning the repository will bring in the Azure-C-Shared-Utility dependency and give you the following directory structure:
| ...
|--- azure-iot-sdk
\------ c
|------ azure-c-shared-utility
|------ azure-uamqp-c
| |------ azure-c-shared-utility
| \------ libwebsockets
\------ azure-umqtt-c
\------ azure-c-shared-utility
-
If you have a previous version of the repository you will need to run the following commands (under each submodule):
git submodule init
git submodule update
You can now run the Windows sample applications included in the repository. All the samples use the NuGet package manager to download any required dependencies such as the Microsoft.Azure.C.SharedUtility, Microsoft.Azure.IoTHubClient, and Microsoft.Azure.IoTHubSerializer libraries.
The following is a list of the Visual Studio solution files for the Windows samples in the repository:
-
c\iothub_client\samples\iothub_client_sample_amqp\windows\iothub_client_sample_amqp.sln
-
c\iothub_client\samples\iothub_client_sample_http\windows\iothub_client_sample_http.sln
-
c\serializer\samples\remote_monitoring\windows\remote_monitoring.sln
-
c\serializer\samples\simplesample_amqp\windows\simplesample_amqp.sln
-
c\serializer\samples\simplesample_http\windows\simplesample_http.sln
-
c\serializer\samples\simplesample_mqtt\windows\simplesample_mqtt.sln
-
c\serializer\samples\temp_sensor_anomaly\windows\temp_sensor_anomaly.sln
You do not need to build the libraries in order to run the sample applications because the samples install all their dependencies using the NuGet package manager.
The following instructions outline how you can build the libraries in Windows:
-
Create the folder C:\OpenSSL on your development machine in which to download OpenSSL.
-
Install cmake (make sure it is installed in your path, type "cmake -version" to verify).
-
Ensure that the git.exe application is in your system path.
-
Open a Visual Studio 2015 x86 Native Tools command prompt.
-
Run the script build_client.cmd in the c\build_all\windows directory.
Note: To enable support to AMQP over WebSockets,
- Install OpenSSL 1.0.1 (x86) (tip: build the dll prior to running the following steps);
- Additionally to instructions on step 1 above, create the environment variable OPENSSL_ROOT_DIR=C:\OpenSSL
- Run the build_client.cmd script with the option
--use-websockets
.
This section shows you how to set up a development environment for the Azure IoT device SDK for C on Ubuntu.
Note: this setup process requires cmake version 3.x or higher and gcc version 4.9 or higher. You can verify the current version installed in your environment using the cmake --version
command. For information about how to upgrade your version of cmake to 3.x on Ubuntu 14.04, see http://askubuntu.com/questions/610291/how-to-install-cmake-3-2-on-ubuntu-14-04.
this library requires gcc version 4.9 or higher. You can verify the current version installed in your environment using the gcc --version
command. For information about how to upgrade your version of gcc on Ubuntu 14.04, see http://askubuntu.com/questions/466651/how-do-i-use-the-latest-gcc-4-9-on-ubuntu-14-04.
- Clone the latest version of this repository to your Ubuntu machine with the recursive parameter
git clone --recursive https://github.com/Azure/azure-iot-sdks.git
Use the master branch to ensure you fetch the latest release version.
-
Open a shell and navigate to the folder c/build_all/linux in your local copy of the repository.
-
Run the
/setup.sh
script to install the prerequisite packages and the dependent libraries. -
Run the
./build.sh
script.
This script uses cmake to make a folder called "cmake" in your home directory and generates a makefile. The script then builds the solution and runs the tests.
Note: Every time you run
build.sh
, it deletes and then recreates the "cmake" folder in your home directory.
## Set up a Windows Embedded Compact 2013 development environmentNote: You will not be able to run the samples until you configure them with a valid IoT Hub device connection string. For more information, see Run sample on Linux.
-
Install Visual Studio 2013. You can use the free Community Edition if you meet the licensing requirements. Be sure to include Visual C++ and NuGet Package Manager.
-
Install Application Builder for Windows Embedded Compact 2013
-
Install Toradex Windows Embedded Compact 2013 SDK or your own SDK.
-
Install git making sure git.exe can be run from a command line.
-
Clone the latest version of this repository to your local machine. Use the master branch to ensure you fetch the latest release version.
If you installed a different SDK please check azure-iot-sdks\c\build_all\windowsce\build.cmd and replace:
set SDKNAME=TORADEX_CE800
set PROCESSOR=arm
with a reference to the name of the SDK and the processor architecture (arm/x86) you plan to use.
You can build the Windows samples to verify that your environment is set up correctly.
-
Open a Visual Studio 2013 Developer command prompt.
-
Navigate to the c\build_all\windowsce folder in your local copy of the repository.
-
Run the following command:
build.cmd --skip-e2e-tests
This script uses cmake to make a folder called "cmake_ce8" in your home directory and generates in that folder a Visual Studio solution called azure_iot_sdks.sln. The script will then proceed to build the solution and run tests.
Note: you will not be able to run the samples until you configure them with a valid IoT hub device connection string. For more information, see running a C sample application on Windows Embedded Compact 2013 on a Toradex module.
To view the projects and examine the source code, open the azure_iot_sdks.sln solution files in Visual Studio.
You can use one of the sample applications as a template to get started when you are creating your own client applications.
## Sample applicationsThis repository contains various C sample applications that illustrate how to use the Azure IoT device SDK for C. For more information, see the Read Me.