Solarian Programmer

My programming ramblings

Raspberry Pi Raspbian - Building and Installing Vim 8.0

Posted on September 24, 2016 by Sol

About two weeks ago Vim 8 was released with some notable changes. While I’m not a Vim fanatic, I tend to use it for quick edits on my Raspberry Pi over the network. Currently, Raspbian Jessie comes with the venerable Vim 7.4 and it will be a while until this will be replaced with version 8.

Fortunately, compiling Vim from sources on Raspbian is pretty straightforward.

►  Continue reading


Compiling GCC 6 on macOS Sierra

Posted on September 22, 2016 by Sol

In this tutorial, I will show you how to compile from source and install the current stable version of GCC with Graphite loop optimizations on your macOS computer. The instructions from this tutorial were tested with Xcode 8 and Sierra (macOS 10.12).

Clang, the default compiler for macOS, supports only C, C++, Objective-C and Objective-C++. If you are interested in a modern Fortran compiler, e.g. you will need gfortran that comes with GCC. Another reason to have the latest stable version of GCC on your macOS is that it provides you with an alternative C and C++ compiler. Testing your code with two different compilers is always a good idea.

►  Continue reading


Install OpenCV 3 with Python 3 on Windows

Posted on September 17, 2016 by Sol

If you need a short tutorial about how to get started with OpenCV 3.1 programming in Python 3.5 on Windows, you are in the right place. Most articles I found online, including the OpenCV documentation, seem concerned only with Python 2.7.

We’ll start by installing the latest stable version of Python 3, which at the time of this writing is 3.5. Head over to https://www.python.org/downloads/ and download the installer. The default Python Windows installer is 32 bits and this is what I will use in this article. If you need the 64 bits version of Python, check the Looking for a specific release? section from the above page.

►  Continue reading


Raspberry Pi Raspbian Compiling GCC 6

Posted on June 29, 2016 by Sol

This is a short article about compiling, building, GCC 6 from sources and how to get started with C++14 and C++17 on Raspberry Pi with Raspbian. At this time Raspbian comes with the stable but outdated GCC 4.9 as the default C and C++ compiler.

I’ve tested the next steps on a Raspberry Pi 2, but it should work on all current models.

►  Continue reading


Raspberry Pi - Install GCC 6 and compile C++14 and C++17 programs

Posted on June 24, 2016 by Sol

This is a short article about how to get started with C++14 and C++17 on Raspberry Pi on Raspbian. At the time of this writing Raspbian is based on Debian Jessie, which comes with the stable but outdated GCC 4.9 as the default C and C++ compiler.

Fortunately, the next release of Debian, Stretch, comes with GCC 6.1 which has a complete C++11/C++14 implementation. I wouldn’t recommend a complete upgrade from Jessie to Stretch because, at this time, not all packages from Stretch have proper support for Raspberry Pi, this is why I will show you next how to install GCC 6 and his dependencies from Stretch and keep Jessie as the default source for all the other packages. I’ve tested the next steps on Raspberry Pi 2 and 3, but it should work on older models too.

►  Continue reading


How to share a compiled iOS app ipa with your users for testing using Dropbox or your website

Posted on May 14, 2016 by Sol

In this post I will show you a simple way in which you can share your iOS applications wirelessly with your friends or users for testing purposes. The procedure requires that you have an iOS device and an Apple developer account. You will also need a secure (https) personal website or a Dropbox account. If you can test your app on your device, you can share it with other people.

Please note that this approach does not require any kind of jailbreaking and as far as I can tell, it is accepted by Apple. Alternatively, you can use TestFlight to invite people to test your beta application. Personally, I found the approach presented in this article easier to setup and use.

►  Continue reading


Compiling GCC 6 on OS X

Posted on May 10, 2016 by Sol

UPDATE 22 September 2016

If you are using macOS Sierra check the new tutorial.

In this tutorial, I will show you how to compile from source and install the current stable version of GCC with Graphite loop optimizations on your OS X computer. The instructions from this tutorial were tested with Xcode 7.3 and El Capitan (OS X 10.11).

Clang, the default compiler for OS X, supports only C, C++ and Objective-C. If you are interested in a modern Fortran compiler, e.g. you will need gfortran that comes with GCC. Another reason to have the latest stable version of GCC on your Mac is that it provides you with an alternative C and C++ compiler. Testing your code with two different compilers is always a good idea.

►  Continue reading


How to upgrade Node.js on Mac OS X

Posted on April 29, 2016 by Sol

If you already have Node.js installed on your Mac you will need to upgrade it when a new version comes up. There are basically two ways to achieve this goal download the installer from Node.js or use the command line to upgrade Node.js.

A simple way to upgrade Node.js from the Terminal is to use the n version manager:

►  Continue reading


Compiling Boost with GCC 5 or Clang on Mac OS X

Posted on March 6, 2016 by Sol

In this article I will show you how to build the Boost libraries under Mac OS X with GCC 5 or Clang. Once the libraries are installed, we’ll test the build with a short demo of using Boost Filesystem.

The next C++ standard, C++17, will probably include a much needed Filesystem specification based on Boost Filesystem. Some compilers like Visual Studio 2015 already include the filesystem header as an experimental feature. In the meantime, if your preferred C++ compiler doesn’t include filesystem, you can use the Boost implementation and update your code later.

►  Continue reading


OpenCV video editing tutorial

Posted on June 4, 2015 by Sol

The code for this post is on GitHub: https://github.com/sol-prog/opencv-video-editing.

I’ve always knew that OpenCV can be used to do some video editing, however when I’ve actually tried to use it to open a video file, a few weeks ago, I was amazed at the quantity of misleading or incomplete tutorials you find on the web. I wrote this tutorial to save some time for others like me that need to do some quick and dirty video editing with C++ and OpenCV.

Simplest thing that you could try is to read frames from your computer’s webcam. OpenCV uses the same function, VideoCapture, for opening a video file or a camera attached to your computer, the only difference is that for a camera you will feed the function a number, while for an actual video file you will use the video path.

►  Continue reading


OpenMP on OS X

Posted on May 14, 2015 by Sol

At the time of this writing Clang, the default C++ compiler on OS X, doesn’t have an OpenMP implementation. GCC however supports OpenMP 4, but you need to install it yourself if you want to use it. GCC 5 can be built from sources for OS X if you want to have the latest and greatest or, you can install it with Homebrew.

OpenMP ads threading support to a C or C++ code through pragmas, this has the advantage that you can take a serial code and parallelize it with minimal code modifications.

As a side node, starting with C++11, you can directly use the thread header if you want to explicitly parallelize your code and this approach is supported by Clang.

►  Continue reading


Detect red circles in an image using OpenCV

Posted on May 8, 2015 by Sol

The code for this post is on GitHub: https://github.com/sol-prog/OpenCV-red-circle-detection.

A few days ago someone asked me, in an email, if it is possible to detect all red circles in an image that contains circles and rectangles of various colors. I thought this problem could be of certain interest to the readers of this blog, hence the present article.

From the many possible approaches to the problem of red circles detection, two seem straightforward:

  • Detect all circles from the input image and keep only the ones that are filled with red.
  • Threshold the input image in order to keep only the red pixels, search for circles in the result.

I found the second approach to be slightly better than the first one (less false positives), so I am going to present it in this post.

►  Continue reading


Raspberry Pi - Building SDL 2 on Raspbian

Posted on January 22, 2015 by Sol

This is a short tutorial on how to get started with SDL 2 programming on a Raspberry Pi device that has Raspbian installed. If you want to write C++, or C, games that are easily portable to other platforms SDL 2 is the way to go on Raspbian. Unfortunately, at the time of this writing Raspbian comes with the outdated SDL 1.2 installed.

Let’s start by updating our Raspbian installation, feel free to skip this step if your system was recently updated:

1 sudo apt-get update
2 sudo apt-get upgrade

►  Continue reading


Getting started with JOGL (OpenGL bindings for Java) in Eclipse

Posted on December 8, 2014 by Sol

Recently, a reader of my OpenGL 101 series emailed me about how to get started with OpenGL in Java. More specifically, he was interested in JOGL the Java bindings for OpenGL. I thought his question was general enough to write a small post about creating a Java OpenGL getting started project.

JOGL is a good fit for a Java programmer that wants to learn OpenGL, it is particularly useful if you follow some OpenGL intro book or article. If you are more interested in writing Java games, you should check a more game friendly library like LWJGL or, even better, libGDX.

►  Continue reading


C++14 lambda tutorial

Posted on August 28, 2014 by Sol

The last iteration of C++, C++14 was approved this month. C++14 brings a few much anticipated changes to the C++11 standard, like allowing auto to be used as the return type of a function, or generic lambdas - the subject of this article.

Lambdas, in C++, were introduced by the C++11 standard. They were meant to let the coder write short, anonymous functions, that could be used instead of a function object, avoiding the need to create a separate class and a function definition. Here is a typical example of C++11 lambda usage, that returns the square of a number:

1 int result = [](int input) { return input * input; }(10);
2 cout << result << endl;

If you need to reuse the same piece of code in more than one place, you can save the function in a variable:

1 auto func = [](int input) { return input * input; };
2 
3 // first use
4 std::cout << func(10) << std::endl;
5 
6 // second use
7 std::cout << func(23) << std::endl;

►  Continue reading