Tag Archives: C++

Build Paho MQTT c library on Mac OS X

This post describes how to build the Paho MQTT library on Mac OS X with MacPorts openssl.

Prepare your system

Install the compiler

You need Xcode or the Xcode command line utils. If you’re not sure if they are already installed open a terminal and try to run the gcc command. If you need to install the compiler a popup will appear to do so.

Install Mac Ports

If not done already download and install the MacPort system and install the openssl library by executing the following command:

sudo port install openssl

You need at least openssl-1.0.1g_0 to not be affected by heartbleed bug!

Clone the repository

Get the latest version because there are some improvements done the last weeks.

git clone git://git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.c.git

Prepare the build environment

Change to the build directory within the repository:

cd org.eclipse.paho.mqtt.c/build/

Now we need to export some environment variables:

export SSL_DIR=/opt/local/
export MQTTCLIENT_DIR=../src

If you want to build the samples:

export BUILD_SAMPLES=YES
export SAMPLES_DIR=../src/samples

Now give it a try and run make

make

There should now be some output shown and a darwin_ia64 folder should be created. There you find your paho c library files.

Hope this helps to build your paho library.

 

Install Eclipse C/C++ Juno on Mac OS X

Description

This tutorial will explain how to install and use Eclipse C/C++ with Mac OS X. I wrote a tutorial for Windows 7 some time ago because you need to install some additional software to be able to compile your programs. With Mac OS X this should be more easier if you already have Xcode installed.

Prepare your system

Apple offers you a free collection of development tools called Xcode. It although contains a IDE for Objective C and iOS development. Beside this it tools there are a lot of useful tools like different version control systems and console tools and very important the compilers. Because this is packed and very easy to install you should go to the AppStore and install Xcode if you don’t have it yet.

You will need to have Java installed on your Mac OS X as well but this is just a click if you try to run a Java application the first time.

Xcode Appstore Screenshot

 

Download Eclipse CDT for Mac OS X

Download the Eclipse CDT version of Eclipse from eclipse.org. I prefer the 64bit version.

Eclipse CDT MacOSX 64bit version

 

Extract the downloaded archive and move the eclipse folder to your Application directory. I renamed the folder to eclipse-cdt because I have different version of Eclipse in my Application folder. But the folder should contain the following files:

Eclipse CDT folder Mac OS X

 

Now you should be able to run the Eclipse IDE.

Eclipse Startscreen

First the Eclipse splashscreen will appear. Then you will be asked to define your workspace like the following prompt:

Eclipse define workspace prompt

Choose a folder or use the default value and continue with OK:

Eclipse CDT Mac OS X empty UI

You should get something like a welcome page or continue an empty overview over your new Eclipse C/C++ IDE.

Create a new C++ Project as shown below:

Eclipse Mac OS X create new C++ project

Eclipse CDT Mac OS X create new C++ project

Build the new project if it’s not done automatically after creation and run the binary:

Hello World programm C++ Max OSX Eclipse CDT

If everything went well you should see the Hello World message in your output console:

Eclipse C++ IDE Hello World on Mac OS X

How to find the eclipse.ini configuration file

Because the eclipse.ini file is hidden in the Mac package I wrote a blog post some time ago how to change it. You can find the post here. Should work for Eclipse Juno as well.

Maybe this helps you to get your IDE up and running to do awesome stuff with it. Feel free to add a comment if I missed a step.

Install Eclipse CDT on Windows 7

How to install Eclipse CDT on Windows 7.

First of all we need a c++ compiler for Windows. The most popular c++ compiler is mingw. You can download it on the sourceforge project page.

We need 2 packages from this page.

1. mingw installer

2. minsys installer

First step is to install mingw.

Just follow the Wizzard step by step. If you want to add some additional features like other compilers choose them when asked. If not the default values should work as shown here step by step.

Select the following packages. This is just my selection. If you need some additional packages feel free to select them. But if you want to do only C++ this selection is enough.

Install MINSYS.

Set correct system variables.

You need add some values to your system variables. If you never have done this just follow the process shown below.

Open your Contorl Panel:

Scroll down and search for the Path variable and click edit.

Edit the Path-Variable. Add the highlighted values: “C:\mysys\1.o\bin” and “C:\mingw\bin” separated by semicolons as shown in the next screenshot.

Now we are ready to start Eclipse. If you have Eclipse already in use you need only to install the CDT plugin. If you don’t use Eclipse yet, dowload the CDT – Version from eclipse projekt page. Now start Eclipse and create a new C++ Hello World Projekt.