Error when connecting Azure IoT Suite with Raspberry Pi - azure

I am attempting to link my Raspberry Pi to my Azure IoT suite using this tutorial.
I get these errors when entering the following code into my terminal:
cd ~/azure-iot-sdks/
sudo ~/azure-iot-sdks/c/build_all/linux/setup.sh
chmod +x ~/azure-iot-sdks/c/build_all/linux/build.sh
~/azure-iot-sdks/c/build_all/linux/build.sh
Any help is appreciated, as I cannot wait to connect my Pi to Azure!

I've verified the tutorial works on various environments,
Host: Ubuntu 14.04, gcc version 4.8.4, cmake version 2.8.12.2, build succesfully.
Host: Ubuntu 14.04, gcc version 4.9.3, cmake version 2.8.12.2, build succesfully.
Host: Ubuntu 14.04, gcc version 4.9.3, cmake version 3.3.2, build succesfully.
Host: Bash On Ubuntu On Windows, gcc version 4.8.4, cmake version 2.8.12.2, build succesfully.
Interesting thing is although gcc(>=4.9) and cmake(>=3.0) is recommended per this page, I found gcc 4.8 and cmake 2.8 also works find with this tutorial.
Anyway, you need to make sure you follow the steps thoroughly,
Clone iot-hub-c-raspberrypi-getstartedkit and WiringPi repositories, with the --recursive parameter.
Go to WiringPi and do ./build. This step is not mentioned in the tutorial but I found it necessary.
Make sure you have all the tools installed,
sudo apt-get install curl libcurl4-openssl-dev uuid-dev uuid g++ make cmake git unzip openjdk-7-jre libssl-dev libncurses-dev subversion gawk
Build the source code,
cd ~/iot-hub-c-raspberrypi-getstartedkit/
sudo ~/iot-hub-c-raspberrypi-getstartedkit/azure-iot- sdks/c/build_all/linux/setup.sh
chmod +x ~/iot-hub-c-raspberrypi-getstartedkit/sample/build.sh
~/iot-hub-c-raspberrypi-getstartedkit/sample/build.sh
I've verified following the steps above, it builds successfully on various environments.

Related

Bitbucket pipeline installing the wrong version of cmake

When I apt-get install cmake in my Bitbucket pipeline, it installs version 3.0.2. This then leads to an error "CMake 3.7.2 or higher is required. You are running version 3.0.2". How can I install cmake version 3.7.2 or higher in my .yml?
bitbucket-pipelines.yml
image: gcc:6.5
pipelines:
default:
- step:
script: # Modify the commands below to build your repository.
- apt-get update && apt-get -y install cmake
- cmake -B build .
Error:
+ cmake -B build .
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
CMake 3.7.2 or higher is required. You are running version 3.0.2
This isn't really a pipelines issue. I'll walk through the troubleshooting process to identify the problem and a possible solution. You could pursue other solutions to install your desired version but hopefully following the approach here will help you in future.
Full disclosure, I work for Atlassian - though not on the Bitbucket Pipelines team :)
The version of cmake that you see being installed is actually related to the third party base image you're using, gcc:6.5. You can test/verify this on your own machine:
$ docker run --rm -it gcc:6.5 bash
root#77d4fde67119:/# apt-get update && apt-get -y install cmake
root#77d4fde67119:/# cmake --version
cmake version 3.0.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
We can see the gcc:6.5 image is based on Debian Jessie:
root#77d4fde67119:/# cat /etc/os-release | grep PRETTY
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
If you look up the default cmake package for Jessie you'll find that it's v3.0.2: https://packages.debian.org/jessie/devel/cmake
A little more digging will show you that newer Debian versions package newer versions of cmake by default: Stretch or Buster will package 3.7 or 3.13 respectively. So the solution to your issue is using a newer version of the gcc base image based on a more recent Debian version:
Let's try it again with the gcc:7 base image:
$ docker run --rm -it gcc:7 bash
root#26e82f7b5e56:/# cat /etc/os-release | grep PRETTY
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
Well, that's a good sign: gcc:7 is based on Debian Buster. Buster ships 3.13: https://packages.debian.org/buster/devel/cmake
root#26e82f7b5e56:/# apt-get update && apt-get -y install cmake
root#26e82f7b5e56:/# cmake --version
cmake version 3.13.4
CMake suite maintained and supported by Kitware (kitware.com/cmake).
There you have it: a version above 3.7.
If you can't use this version of gcc, of course, you'll need to look at a different solution. But hopefully this helps to illustrate the source of your issue and how you can investigate these kinds of issues in future.

Installing/Linking libwebsockets library in AWS Linux for mosquitto MQTT

Following the AWS Guide: https://aws.amazon.com/blogs/iot/how-to-bridge-mosquitto-mqtt-broker-to-aws-iot/ and I got to the step that has me install mosquitto.
//Update the list of repositories with one containing Mosquitto
sudo wget http://download.opensuse.org/repositories/home:/oojah:/mqtt/CentOS_CentOS-7/home:oojah:mqtt.repo -O /etc/yum.repos.d/mqtt.repo
//Install Mosquitto broker and Mosquitto command line tools
sudo yum install mosquitto mosquitto-clients
However, the guide is so outdated that it does not mention anything about the missing libwebsockets library. I've spent roughly 4-5 hours on searching for an answer on how to manually install/link/setup the library but I have not been able to make anything work.
(1) Tried this
git clone https://github.com/warmcat/libwebsockets.git
cd libwebsockets
mkdir build
cd build
cmake .. -DCMAKE_C_COMPILER=/usr/bin/gcc
make
sudo make install
But yea that didn't work because CMAKE throws all kinds of errors like
CMake Error at /usr/share/cmake/Modules/CMakeDetermineSystem.cmake:99 (message): Could not find toolchain file: /tmp/mytoolchainfile
Call Stack (most recent call first):
CMakeLists.txt:131 (project)
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Could not find cmake module file: /tmp/libwebsockets/build/CMakeFiles/2.8.12.2/CMakeCCompiler.cmake
-- Configuring incomplete, errors occurred!
So I tried to set the CMAKE_C_COMPILER path to /usr/bin/gcc, which is where the compiler is installed and that didn't do anything either. In all honesty, I'm not super familiar with Linux, I'm just trying to make do the best I can. I could really use some guidance on how best to get library installed and linked into Linux. I do believe AWS runs a red-hat version of linux.
Thanks for your time!
I had this working using aws linux 2
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -P /tmp
sudo yum install -y /tmp/epel-release-latest-7.noarch.rpm
sudo yum install libwebsockets
sudo yum install mosquitto mosquitto-clients

How do I install protobuf 2.5 on Arch Linux for compiling hadoop 2.6.0 using maven 3.3.1?

Am looking for installing protobuf 2.5.0 on Arch Linux, so that protoc-2.5.0.so is installed on the OS, so that I can go ahead with building hadoop 2.6.0 from source and make my life easy! :)
BTW, protobuf 2.6.0 does not compile when hadoop is built from source I have tried that as well. Ubuntu 14.04 comes with protoc 2.5.0. I DO NOT want to use Ubuntu.
Please check the screenshot first (there is no protobuf 2.5.0), since the problem lies there.. I guess
am getting the following exception, I am aware that protoc is not installed in arch linux currently.
[ERROR] Failed to execute goal
org.apache.hadoop:hadoop-maven-plugins:2.6.0:protoc (compile-protoc)
on project hadoop-common:
org.apache.maven.plugin.MojoExecutionException: 'protoc --version' did
not return a version -> [Help 1]
Please help me out, since, I have spent 4 hours every day from two days, with no luck.
Compiling Google's protobuf is pretty easy.
I originally found out how to do it on this blog post while compiling hadoop myself.
But here is my version:
$ cd /usr/local/src/
$ wget https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz
$ tar xvf protobuf-2.5.0.tar.gz
$ cd protobuf-2.5.0
$ ./autogen.sh
$ ./configure --prefix=/usr
$ make
$ make install
$ protoc --version
Install protobuf for java
$ cd java
$ mvn install
$ mvn package
You should be good to go.
To enable you to install different versions of protobuf, install stow
then change ./configure --prefix=/usr to ./configure --prefix=/usr/local/stow/protobuf-2.5.0
Then link protobuf into your system with stow:
$ cd /usr/local/stow
$ stow protobuf-2.5.0
Note: stow uses /usr/local/bin by default. Make sure thats in your $PATH
To unlink that version of protobuf,
$ stow -D protobuf-2.5.0
Hope this helped.
I wonder why the above answer got downvoted,even I had to perform few more steps (in addition to the accepted answer by Rudker) to get protobuf 2.5 installed on Ubuntu Xenial.
Leaving the additional steps here for everyone's benefit:
apt-get install autoconf in response to the error : ./autogen.sh: autoreconf: not found for command : ./autogen.sh
apt-get install libtool in response to the error : autoreconf: libtoolize is needed because this package uses Libtool for command : ./autogen.sh
apt install g++ in response to the error : configure: error: C++ preprocessor "/lib/cpp" fails sanity check for command : ./configure --prefix=/usr
An easier but not future proof solution (for future queries) would be to head over to Arch Linux Archives: http://seblu.net/a/archive/packages/p/protobuf/
Uninstall the newer version of protobuf and install the downloaded package via pacman -U protobuf-2.5.x..
Though whenever you upgrade the Arch Linux packages via pacman you'd need to ensure you are doing: sudo pacman -Syu --ignore protobuf
I currently don't have enough reputation to comment, so I add a answer here to update the top voted answer.
Since protobuf move to different repo, the new wget command should be:
wget https://github.com/protocolbuffers/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz
And in order to run ./autogen.sh, you may need install these:
sudo yum install libtool automake autoconf
For OSX prerequisites, try SunitaKoppar's answer (I don't know why the down-votes).
Thanks for the steps. Just wanted to add that, to get autogen.sh to work, I had to install the below packages (commands for mac below):
brew install gtk
brew install autoconf
brew install automake

Dart throwing errors on linux: GLIBC_2.14 GLIBC_2.15 not found

I'm running Debian 7.2 on Google Compute Engine (Though I suspect Centos, Red Hat, and Amazon Linux AMI all have the same problem). After downloading the 64-bit Linux version of the Dart SDK from this page, any dart command I run, for example, dart --version, will output the following error:
./editor/dart/dart-sdk/bin/dart: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.15' not found (required by ./editor/dart/dart-sdk/bin/dart)
./editor/dart/dart-sdk/bin/dart: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by ./editor/dart/dart-sdk/bin/dart)
Update: October 2014: Dart can now be installed on Debian with apt-get:
Instructions summarized from the dart website:
# Enable HTTPS for apt.
sudo apt-get update
sudo apt-get install apt-transport-https
# Get the Google Linux package signing key.
sudo sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
# Set up the location of the stable repository.
sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
sudo apt-get update
# Finally, install the dart package!
sudo apt-get install dart
Instructions for building the binary yourself:
This problem appears to be caused by Google compiling against an edge version of GLIBC (>= 2.15) which is not generally supported on Linux outside of Ubuntu 12 (Precise Pangolin).
First of all, do not attempt to download an experimental version of GLIBC or EGLIBC. I was able to get dart to work using that method, but the rest of my machine fell apart. Updating GLIBC is a recipe for madness.
Instead, the best solution is building dart from source. Despite the GLIBC version requirements of the binary, the source itself has no such requirements. There are wiki pages for installing from source on debian, centos/fedora/red hat/amazon, ubuntu, and other linux versions.
Here is an overview of those steps, which I can confirm works on Debian 7.2. The centos/fedora/redhat steps appear to be the same except they use yum instead of apt-get.
Install subversion and the required build tools:
sudo apt-get -y update
sudo apt-get -y install subversion
sudo apt-get -y install make
sudo apt-get -y install g++
sudo apt-get -y install openjdk-6-jdk
Check out google's depot tools and add gclient to your path
svn co http://src.chromium.org/svn/trunk/tools/depot_tools
export PATH=$PATH:`pwd`/depot_tools
Download the dart source at the desired branch.
Replace 1.2 with whatever branch you wish to build. You can see a list of available versions here. In general, the latest numbered branch is best.
gclient config http://dart.googlecode.com/svn/branches/1.2/deps/all.deps
gclient sync
gclient runhooks
Move into the new dart directory
cd dart
Do only A or B below:
Note: For 32bit, use the --arch=ia32 flag instead.
A. Build the entire Dart SDK including pub, dart2js, dart, etc.:
tools/build.py --mode=release --arch=x64 create_sdk
B. Build just the dart executable:
tools/build.py --mode=release --arch=x64 runtime
The dart executable is now at either out/ReleaseX64/dart or out/ReleaseX64/dart-sdk/bin/dart you can do a smoke test by printing the version
dart/out/ReleaseX64/dart --version
The output should be something like Dart VM version: 1.2.0 (Mon Mar 3 03:06:20 2014) on "linux_x64".
How to help fix this issue
This was much more painful than it needed to be, since the binary clearly doesn't need to be built using GLIBC >= 2.15. If you wish to draw attention to this issue, please star this dart bug.

gcc-arm-linux-gnueabi command not found

I am trying to install the gnu arm toolchain for ubuntu. I first downloaded the tar from CodeSourcery. However when I go into the bin folder, I cannot run any of the binaries. I have tried with ./ and without and putting it in the PATH and it keeps telling me "Command not Found" yet the file is there in the folder right in front of me. Then I tried sudo apt-get install gcc-arm-linux-gnueabi except after it says it has installed successfully, I cannot find it with whereis gcc-arm-linux-gnueabi. Can anyone help?
fixed, using:
sudo apt-get install gcc-arm*
Are you compiling on a 64-bit OS? Try:
sudo apt-get install ia32-libs
I had the same problem when trying to compile the Raspberry Pi kernel. I was cross-compiling on Ubuntu 12.04 64-bit and the toolchain requires ia32-libs to work on on a 64-bit system.
See http://hertaville.com/2012/09/28/development-environment-raspberry-pi-cross-compiler/
CodeSourcery convention is to use prefix arm-none-linux-gnueabi- for all executables, not gcc-arm-linux-gnueabi that you mention. So, standard name for CodeSourcery gcc would be arm-none-linux-gnueabi-gcc.
After you have installed CodeSourcery G++, you need to add CodeSourcery directory into your PATH.
Typically, I prefer to install CodeSourcery into directory like /opt/arm-2010q1 or something like that. If you don't know where you have installed it, you can find it using locate arm-none-linux-gnueabi-gcc, however you may need to force to update your locate db using sudo updatedb before locate will work properly.
After you have identified where your CodeSourcery is installed, add it your PATH by editing ~/.bashrc like this:
PATH=/opt/arm-2010q1/bin:$PATH
Also, it is customary and very convenient to define
CROSS_COMPILE=arm-none-linux-gnueabi-
in your .bashrc, because with CROSS_COMPILE defined, most tools will automatically use proper compiler for ARM compilation without you doing anything.
if you are on 64 bit os then you need to install this additional libraries.
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0
got the same error when trying to cross compile the raspberry pi kernel on ubunto 14.04.03 64bit under VM. the solution was found here:
-Install packages used for cross compiling on the Ubuntu box.
sudo apt-get install gcc-arm-linux-gnueabi make git-core ncurses-dev
-Download the toolchain
cd ~
git clone https://github.com/raspberrypi/tools
-Add the toolchain to your path
PATH=$PATH:~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian:~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin
notice the x64 version in the path command
I was also facing the same issue and resolved it after installing the following dependency:
sudo apt-get install lib32z1-dev
If you are on a 64bit build of ubuntu or debian (see e.g. 'cat /proc/version') you should simply use the 64bit cross compilers, if you cloned
git clone https://github.com/raspberrypi/tools
then the 64bit tools are in
tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64
use that directory for the gcc-toolchain.
A useful tutorial for compiling that I followed is available here Building and compiling Raspberry PI Kernel (use the -x64 path from above as ${CCPREFIX})
You have installed a toolchain which was compiled for i686 on a box which is running an x86_64 userland.
Use an i686 VM.
Its a bit counter-intuitive. The toolchain is called gcc-arm-linux-gnueabi. To invoke the tools execute the following: arm-linux-gnueabi-xxx
where xxx is gcc or ar or ld, etc
try the following command:
which gcc-arm-linux-gnueabi
Its very likely the command is installed in /usr/bin.
I had to cross compile C code in Ubuntu for ARM. This worked for me:
$ sudo apt install gcc-arm-none-eabi
Later, tested it on the qemu emulator
#Install qemu
sudo apt-get install qemu qemu-user-static qemu-system-arm
#Cross compile "helloworld.c"
$ arm-none-eabi-gcc --specs=rdimon.specs -Wl,--start-group -lgcc -lc -lm -lrdimon -Wl,--end-group helloworld.c -o helloworld
#Run
qemu-arm-static helloworld

Resources