Just Code it!

Update: Written for OSX El Capitan. Works for macOS Sierra as well.

While VirtualBox is a great product easy to use to create Virtual Machines and configure in few minutes, trying to create a Virtual Machine with a OSX system could be very tricky.

With this guide I will explain a procedure you can follow if you want to install a Mac OS X system on VirtualBox, running on Max OS X as well.

I wanted to describe this because the information available are often confused, missing and too many times they require the download of extra software or installer (generally to avoid the very common issue where the UEFI Interactive Shell is displayed or the text “Fatal: no bootable medium found! System Halted”, that you can see if you selected EFI support for your Virtual Machine).

If you find this useful or interesting please share and comment for more to come!

Time to start!

Create ISO from installer

The very first thing to do is to download the OS X Installer.

I wrote a dedicated post for this and you can find it here:

Create Mac OS X Installer USB Disk

Time to do some magic!

As it stand the installer will not work on the Virtual Machine (and you will experience the error I mentioned at the start of the article).

What we’ll need to do is manipulate the installer disk in order to make it ready for our Virtual Machine to understand.

I will put the whole list of commands at the end of this article, but I will explain every line to make it clear what’s going on.

We’ll make heavy use of the “hdiutil” tool.

It is a command used to manipulate disk images and you can find detailed about this command here:



1. Attach the installer image

First thing we need to do is attaching the image of the installer (that we downloaded) as a device. Effectively simulating a device (the installation disk in this case) attached to our mac.

We achieve this using the “hdiutil” command: “attach“.

The disk we want to attach is contained in the app you downloaded from the App Store: “/Applications/Install OS X El Capitan.app

Inside its content: “/Contents/SharedSupport/InstallESD.dmg

(So essentially in: “/Applications/Install OS X El Capitan.app/Contents/SharedSupport/InstallESD.dmg“)

We’ll then proceed to attach this disk image and at the same time:

  • We’ll tell the system to hide the content of this disk from Finder with: “-nobrowse
  • We’ll no verify the image (with the checksums): “-noverify
  • and we’ll instruct it to mount it in a location where we will then intend to access its content. Let’s choose: “/Volumes/esd

That’s the full command:

2. Create new image

We want now to create a new image.

For this we’ll use the “hdiutil” command: “create”

  • We give the image an output file: “-o Installer.cdr
  • I’ll set the size to 7.5GB (you can increase it if you’ll need to): “-size 7.5g
  • Then we specify the layout of the image. We’ll use “SPUD“, that from the documentation: “SPUD causes a DDM and an Apple Partition Scheme partition map with a single entry to be written.”
  • For the filesystem (of the image) we’ll use the standard HFS+J: “-fs HFS+J

3. Attach the new disk image

We now attach the newly created disk image (still empty) to another volume. The command is conceptually identical to what we did before with “InstallESD.dmg”, but this time we attach the disk we just created “OSXInstaller.cdr.dmg”:

4. Copy the System Installer to the new disk image

The real installer is inside the disk image “BaseSystem.dmg” contained in “InstallESD.dmg” (that we attached to the volume “/Volumes/esd/“).

What we need to do is copy the content of this disk image (so the content of “BaseSystem.dmg”) into the root of our new installer disk (that we attached to “/Volumes/iso/“).

For this we use now the command “asr” that copies disk images into volumes and we just tell it to restore the image from “/Volumes/esd/BaseSystem.dmg” into “/Volumes/iso“.

The other options are to avoid verification and to skip the prompting of confirmation to continue (essentially to avoid to answer “yes” to the erase disk confirmation).

Note: the “-erase” option is now mandatory (or “asr” will refuse to run with the error: “File copy is not supported anymore.  Use the –erase flag.”).

This is the full command:

At the end of this passage the finder window pointing to our new “restored” disk (“Volumes/OS X Base System/“) should automatically popup:

and you can see that it is now mounted and available from the main finder as well:


5. Remove broken link

If you look inside “Volumes/OS X Base System/System/Installation/” you will see that there is a file “Packages” that is actually a link.

If you check where it’s pointing at (with “ls -l /Volumes/OS\ X\ Base\ System/System/Installation/Packages“), you will see that it points to:

/Volumes/OS X Base System/System/Installation/Packages -> /System/Installation/PackagesLink

That doesn’t exist.

In order to fix this we need to remove this link and put the real file in there.

We can remove it simply with:

6. Put back what the link was pointing to

Now it’s just a question to replace the link we just removed with the a real folder physically containing the files.

This is the folder “Packages” in the disk “InstallESD.dmg” (that we mounted in “/Volumes/esd/“).

Let’s copy it, preserving the property of the files (mode,ownership,timestamps) with the parameter “-p” and copying the directories recursively “-r“:

At the end of this the “Pakages” folder should be back in place (but for real this time, not anymore as a link) in the disk we are manually creating (the folder will be therefore in “/Volumes/OS\ X\ Base\ System/System/Installation/Packages“).

7. Copy the remaining missing files

If you look again in the original InstallESD disk, you can see other files in the root:

Ignore the two AppleDiagnostic files (we don’t care about these).

We need to copy the two BaseSystem files in the root of our disk:

8. Detach the volumes

We can now detach the source disk (“/Applications/Install OS X El Capitan.app/Contents/SharedSupport/InstallESD.dmg“) that we mounted in “/Volumes/esd“:

And the one we created (from “/Volumes/esd/BaseSystem.dmg“) and found in “Volumes/OS X Base System/“:

9. Create ISO disk

To use the installer in VirtualBox we need to convert our disk to iso, otherwise you would receive an “VERR_NOT_SUPPORTED” error.

To convert our dmg disk in iso we’ll use again the “hdiutil” tool with the command “convert“:

The format we’ll use is: “UDTO – DVD/CD-R master for export”:

The generated file will contain the extra extension “cdr” that we need to remove if we want to see the disk from VirtualBox in order to select it later on.

We can get rid of it simply renaming the file with “mv“:

you can get rid of OSXInstaller.cdr.dmg at any point now (thanks to Brian for noticing this missing detail in a comment).

10. Done – Summary of the commands

The image is ready to use in VirtualBox. It’s name is now: “OSXInstaller.iso

This is the summary of the commands we run to create it for an easy reference:

Create the Virtual Machine

Open now VirtualBox (you can download it there: “https://www.virtualbox.org/“). I’m using version 5.0.20.

1. Creation

Proceed creating a new Virtual Machine. You can do this by clicking the blue icon (“new”) at the top:

Give a name. If you name it something like “OSX” VirtualBox will automatically select the type of Virtual Machine you want to create (“Mac OSX”):

Click “Continue” and select then the memory size in the next screen. I pick 4096MB:

Create a virtual hard disk:

Select the default VDI (VirtualBox Disk Image) disk type:

Go ahead and pick (if you want) Dynamically allocated:

Select then the file location (the name really) and size (I will create a 40GB HD):

At this point the creation procedure will complete and you should be able to locate your newly created Virtual Machine:

2. Configuration

Select it and click on the “Settings” button:

Select the “Display” section (subsection “Screen”) and fix the amount of Video Memory if it is something like 1MB or 8MB. Move it to the max 128MB:

Enter then the “Storage” section and select the “Empty” disk. Click the CD icon on the right and pick the “Choose Virtual Optical Disk File…” from the menu that will pop-up:

Locate and select the iso we created in the previous chapter (“OSXInstaller.iso“):

At this point press “OK” and we are ready!

Install OSX on the VM

We can now start the real OSX installation procedure!

1. Start the VM

Time to run our Virtual Machine for the first time! Click on the green “Start” arrow:

It should now start and you should see the console printing out a lot of data… wait patiently:

… and more…

Finally start the installation procedure selecting your language:

Click “Continue: on the next screen:

2. Create an HDD partition

To install the system we need to create an Hard Disk first. As you can see in the following image in fact the only visible drive is the CD with the installer:

This video will show how to create the disk and start the installation process that I will describe step by step immediately after:

To create it run the tool “Disk Utility” that you can find in the top menu under “Utilities”:

Select the Hard Disk on the left side (without any partition at the moment) and click “Erase”:

In the new window that will pop-up set a name (I named it “HDD”) and click the “Erase” button:

Wait for the procedure to complete and click “Done”:

You can the close Disk Utility:

3. Install OSX!

And you’ll have your new HDD ready to select and click “Continue” to finally start the installation procedure:

Time to wait…

4. Restart the VM

At the end of the installation the system will shut down.

At this point we can remove the installation disk from our virtual drive.

Go in Settings, Storage and then select the “OSXInstaller.iso” drive. Click on the disk icon at the right of “Optical Drive” and this time select “Remove Disk from Virtual Drive”:

The drive should now be empty again:

You can now run again the Virtual Machine and this time the second part of the OSX installation procedure should kick in:

Go ahead and complete the installation.

This video shows this procedure:

At the end you should finally be able to boot into your brand new freshly installed OSX Virtual Machine! :)


That’s all!

comment and share if this helped you or if you have any questions! :)


This post is actually part of a more specific article I wrote that explains how to install OSX on a Virtual Machine in VirtualBox. You can find this other article here:
Install OS X on VirtualBox (on OS X)

This guide will show how to create an installer of your OSX system. Once done, you will be able to use it if you want for example wipe your current system and start fresh with a brand new OSX Installation, or proceed and use it to install it on a VM as I mentioned before.

I will show how to download the latest version of OSX (El Capitan at the time of this article) or an older one you previously owned (Yosemite for example).

Download the latest OS X Version (El Capitan)

To download it, you can pass through a web browser going there:

and clicking then “View in Mac App Store”:

To select then “Launch Application” and land in the App page on the App Store:

Or open directly the App Store on your mac:

and search for “El Capitan”:

Despite how you reach this stage, you will have then click on the App or just select “download” and…

… wait and wait…

Once the download is complete you can see the installer in the Application folder:

Prepare the USB

In order to create the installer you need to insert a USB stick (I will use a 16GB drive).

It is not strictly required to wipe the whole content of the USB drive but it is something I prefer to do anyway… and it takes really few seconds to do so (feel free to skip this section if you really want to).

Open “Disk Utility“.

You can find this app in the Applications/Utilities folder:

Or use Spotlight search (that you can open with CMD⌘ + SPACE) and start typing “Disk Utility”:

Once started, locate your drive on the left side (it should be easy to identify in the “External” section).

Select it and click the “Erase”:

At this point give the drive a label (it will not really matter if you are going to create an installer because it will be automatically changed later on), select the Format “OS X Extended (Journaled)” and “GUID Partition Map” for the Scheme:

Click “Erase” and wait for the operation to complete. Then click “Done”:

Time to create the installer.

Create a Bootable USB Installer

We need now to put the installer on this USB drive and make it bootable.

Open the Terminal window.

You can find it again in the Applications/Utilities folder or as usual with Spotlight (CMD⌘ + SPACE) search for “Terminal”:

NOTE: Assuming you named the USB drive “OSX”, the volume will be in “/Volume/OSX“. If you gave it a different name you will need to change the following command in order to point it to the correct location of your volume.

Type the following command:

Type your password (you will require root privileges), type “Y” when required to confirm your action and wait for the configuration to complete… it could take some time, so be patient (I’m talking even over 30 mins!):

Note that this procedure will erase the content of the USB and change its label to “Install OS X El Capitan“.


Install OSX!

You can now restart your computer. Make sure you keep the key ALT⌥ pressed while the mac is booting up!

Doing so you should see a startup selection screen similar to this one:

where you can select your newly created installer USB and follow the installation procedure.

Enjoy :)

Download a previous OS X Version (Yosemite)

If you want to download a previous version of OS X you will soon notice that it will not be available on the App Store for download.

There is still a way though if you already purchased it in the past.

To access it open the App Store, and click the “Purchased” section:

Scan through your list and locate Yosemite:

Click the “Download” button and confirm your intention to Apple clicking “Continue” on the popup:

Wait then for the download to complete:

At the end of the download:

you could receive another message from Apple that just says that this is an old version of the OS. Just ignore it:

The installer will be placed in the “Applications” folder:

You can now proceed with the same procedure described above for El Capitan if you want to create a USB Installer.

That’s all!

Once again, please share and comment if you found this article interesting or useful.



This post is a tutorial that will explain hot to write a simple C++ code that can be considered the starting point for any other program you intend to write in C++ with the intention to use a MySQL Database.

In order to connect to MySQL from C++ we will use some libraries specifically designed for this purpose.

Despite the concept seems simple, there are a series of gotchas and configurations that can put off the task many people, increasing the amount of work needed and not necessarily forecasted.

This tutorial will reach the goal starting essentially from scratch, where the environment needs to be completely configured… even without Visual Studio!

While writing this tutorial, I decided to split it in multiple sub-posts because of the amount of information I ended up collecting. Doing this will remove some of the noise around the main topic and will allow to follow the post and the specific sections even for people with different requirements that have already available some of the systems I am going to describe.

As a reference, these are the additional posts:


Enough said, let’s start the journey! See you at the end of this. Happy reading.

mysql-connector (1.1.4) – Download

First things first… let’s immediately download what we are really interested in, the C++ libraries (source) that will allow us to connect and interact with a MySQL database.

Open the browser to the MySQL website and navigate to the page with the information about the connector:


Select the “Source Code” option from the drop-down menu:

Download the generic Windows version:

In the following page select your preferred download option or just download it using the link at the bottom of the page:

Let’s remember the warning reported on the website:

One problem that can occur is when the tools you use to build your application are not compatible with the tools used to build the binary versions of MySQL Connector/C++. Ideally, you need to build your application with the same tools that were used to build the MySQL Connector/C++ binaries. 


Create a folder, for example “C:\libs\” and extract the archive in there.

The structure should look like this:

In order to build the source code for the connector libraries we need to download CMake.

It’s time to switch to the first sub-post if you need to perform this step and install CMake (CMake Installation and usage (Command Prompt Console and GUI)).

Jump to this post and see you here once you are ready to continue (I would suggest you to follow just the initial part of the tutorial, limited to installing it. The remainder will be useful later on and will probably not work on your system if you don’t have everything else already configured): CMake Installation and usage

Back from CMake Installation

I will assume that you have CMake installed on your system now.

mysql-connector 1.1.4 – Build – First Potential Problem (Missing Visual Studio)

If we try to run the CMake command to generate the Visual Studio solution from the mysql-connector code we could potentially immediately receive an error.
Let’s try this using the Command line:

C:\libs\mysql-connector-c++-1.1.4>cmake -G “Visual Studio 10”

If you don’t have the C/C++ compiler then you will see this error:

Pay particular attention to the lines:

If that’s the case, what you need to do is installing Visual Studio.

Visual Studio (C++ 2010 Express)

Let’s download Visual Studio (Visual C++ 2010 Express is ok for us)
Go to the website:
and find the Install Now link:
Install it executing the installation file (vc_web.exe) downloaded.
Then try again!

mysql-connector (1.1.4) – Build – Second Potential Problem (Missing Boost Libraries)

If we try again now:
C:\libs\mysql-connector-c++-1.1.4>cmake -G “Visual Studio 10”
This time it should go further and complain about the (potential) next problem:


The main issue is now:

The problem now is that in order to build this code you need to have installed the BOOST libraries.
If that’s the problem you see as well, then you can happily jump to the next sub-post where is explained in detail how to install and configure boost libraries: Boost Libraries Installation
See you when you are ready to proceed!

Back from Boost Libraries Installation

You should now have a system with CMake, Visual Studio and Boost Libraries installed and configured. Time to continue!

mysql-connector (1.1.4) – Build – Third Potential Problem (MySQL not installed)

Go back into the connector folder and execute again:
C:\libs\mysql-connector-c++-1.1.4>cmake -G “Visual Studio 10”


If you decided at any point to move the folder after executing cmake the first time you will potentially see an error:

To quickly fix this, just remove the file “CMakeCache.txt” and run cmake again.

If you don’t have MySQL installed on your system, then you will probably see this error:

The main indicator for this problem is the line:
If that’s what you see as well… well, you know what’s coming. Yep, another sub-post: MySQL Service, Workspace, Users and Tables
Jump to this post and you can read for now just the initial part that covers the download and installation of MySQL.
The rest of that post will show how to create a database, user and table that we will here, but you can go back to that section later on.

Back from MySQL installation

If everything went as planned until this point you should have CMake, Boost libraries,Visual Studio and MySQL installed and ready to rock.

mysql-connector (1.1.4) – Build – Creating the Visual Studio Solution

Now we can go back into our connector folder and try once again to recreate our Visual Studio Solution.
Yhou can follow this step in the CMake tutorial if you want (where it is explained how to obtain the same result using the command line or the GUI).
This is an extract of it, where I will show only the command line option.
If you run the same command again:
C:\libs\mysql-connector-c++-1.1.4>cmake -G “Visual Studio 10”

You should finally succeed in this step, obtaining:
Now, if everything went as planned, you should be able to see a solution file (and other files as well) into your connector’s folder:
Now we can finally open the created solution (MYSQLCPPCONN.sln) with Visual Studio!
Simply double-click on:

Build MySqlCppConn.sln – Debug

In Visual studio, set the configuration to DEBUG and try to Build.
What should happen is that you will see a series of errors:

Open the properties for the project “mysqlcppconn“. Right-click on it and select “Properties”:

We can do this using different techniques, but I want to use one (even if it is not my preferred one) just for a change :).


Make sure to be in the configuration “Debug” and go in the section:

Common Properties -> Linker -> Input


Open the “Additional Dependencies” drop-down list and click on “<Edit…>”:

Substitute the entry:

  • C:\Program Files\MySQL\MySQL Server 5.6\lib\mysqlclient.lib
  •  C:\Program Files\MySQL\MySQL Server 5.6\lib\debug\mysqlclient.lib

If you build now you could receive another error:

Open the project properties for the project “mysqlcppconn-static

Go in the section:
Common Properties -> Librarian -> Command Line
and change the additional options from:
  • C:/Program Files/MySQL/MySQL Server 5.6/lib/mysqlclient.lib
  •  “C:/Program Files/MySQL/MySQL Server 5.6/lib/debug/mysqlclient.lib”
including the quotes
Build again and everything should be ok now!

Build MySqlCppConn.sln – Release

For the release build the only fix I had to do was only the “Additional Options” section in the Librarian -> Command Line

section for the “mysqlcppconn-static” project (in Release configuration).

Add the quotes to:

  • C:/Program Files/MySQL/MySQL Server 5.6/lib/mysqlclient.lib
Also in this case you should receive a successful compilation:



If you open now the window explorer in the connector folder, in the sub-folder “driver”:
you should see the two build folders “Debug” and “Release”:
Inside these you should find at least the three files:
  • mysqlcppconn.dll
  • mysqlcppconn.lib
  • mysqlcppconn-static.lib
We are ready to use it finally!

Creating a DB

It is finally time to create a database in MySQL that we will use in C++.
You can refer back to the post already highlighted previously (MySQL installation and Usage) and continue to follow it from where you left it until the end.
In that tutorial I explain how to create a sample DB with a sample user that will have access rights and a sample table that we will be able access from code.
When that system is ready, is time to jump into the final step!

Coding – Create a new Visual Studio Solution

In Visual Studio create a new project (I selected a simple Win32 Console Application)
Right click on the source folder and add a new cpp file:
Let’s give it a simple name (the very original “main.cpp” :P):
You should see the new file added:
Before writing any code, let’s configure our environment setting up the folder and libraries that we need to use/reference in order to successfully build our app.

Coding – Configure the Environment

Open the properties window of the project and go to the settings page:
Configuration Properties -> VC++ Directories
And edit the entry:
Include Directories
Make sure you are in the “All Configurations” configuration:

Edit it adding the lines:



Edit then the Library Directories property, adding the line:


Edit then the property in:

Configuration Properties -> Linker -> Input -> Additional Dependencies

adding the line:


One last step you may need to do is copying the “libmysql.dll” and “copy “mysqlcppconn.lib” into your output folder.

Just open the properties to:

Configuration Properties -> Build Events -> Post-Build Event

Then edit “Command Line” and type in this (or the equivalent line that you need in order to copy the missing dll to the output folder):

copy “C:\Program Files\MySQL\MySQL Connector C 6.1.5\lib\libmysql.dll” “$(OutDir)”

copy “C:\libs\mysql-connector-c++-1.1.4\driver\$(Configuration)\mysqlcppconn.dll”  “$(OutDir)”

Remember to edit All Configurations:

Finally it’s time to code!

Coding – Code: Connecting to MySQL

Open the “main.cpp” and let’s put some code.

The first simple code will just test the library, connecting to the DB (our one) using the user that we previously set-up in MySQL Workbench.
Remember to configure correctly:
  • The database address (and port)
  • The User and Password for your user
  • The Database name (that contains the “contacts” table)
That’s the simplest code with some error handling:

If your run this code and you didn’t set-up correctly one of the used parameters, then you will see the error text (without crashing). If that’s the case, check your parameters and verify that you will see the “Connection to the DB established!” string.

Coding – Code: Connecting and using the DB

For the final part of this post we are going to see how to connect now to our DB and retrieve and print the data from our table!
The new lines are the ones that follow the connection established message and few extra includes.
I will omit any exception handling to keep the code short and simple.
This is the final code:

If you build and run the code, you should be finally happily able to see the rows that we entered in our table using MySQL Workbench!


That’s all!


Of course you can now play around with it inserting, editing, removing entries. For these functionalities and more advanced one I point you to the official website and in particular to the Developer Zone:
Please Link and comment if you found this interesting or useful.

That post is exactly what the title says. We’ll install JBoss and configure the server in Eclipse.

From a chronological order, this post comes after:

And after or as an alternative to:

but I will assume that this is the first server you’ll configure in Eclipse.


JBoss – Downloading

Well, easy enough… just go to the website:
and download the version you want to use.

I’ll assume you will download the version 7.1.1  (zip):


JBoss – Installation

Just unzip the file in your preferred location. I’ll suggest to put it in the root of your HD. Ex: “C:\jboss-as-7.1.1.Final“.

That’s all… really!


JBoss – Configure Eclipse (JBoss Developer Studio)

Open Eclipse and navigate to Help->Eclipse Marketplace…:

In the windows that will pop up enter “jboss” in the search field and enter it.
The JBoss Development Studio should be easily visible.
When you spot it, just click on the Install button:

And just confirm it with Next:

Then finish it accepting the terms and clicking on Finish:

The installation will start…

You will be prompted to continue with the installation. Simply click on OK:

At the end of the Installation Eclipse will ask you to restart itself. Accept it.

When the restart will be complete JBoss Dev Studio will ask you to send them usage statistics.
Feel free to select any of the two options based on your personal preferences.

Now you can have access to the new JBoss Dev Studio Perspective!
Open Window->Open Perspective->Other…
Unless you can directly see it listed in the perspectives:

Then select JBoss in the new Pop up:

Now it’s done! And you can switch to the new perspective simply clicking on the JBoss button that you can see in the top right area of your screen:

This perspective is very useful especially because presents to you a nice portal that you can use to quickly start projects and documentation/examples.


JBoss – Adding the server to Eclipse

Click on the “Servers” tab that you should have visible in the bottom area of your screen:

You should see the other servers listed (if any) or a link that prompt you to add one server:

You can click on the link (if you see it) or right click in the white area and select the New->Server option:

In the new window select the JBoss server you intend to use. I’ll install the JBoss AS 7.1:

In the next window you will have to enter the path where you unzipped JBoss and make sure to select the correct JRE (the Java EE SDK we downloaded in another blog post):

You can the simply click on Finish (or continue with a couple of Next if you prefer).

After this you will see you server listed in the Servers tab:

Job done!


That’s all for this episode.

We’ll install more servers (just for fun) in other posts and will see how to write a Servlet to use with them. Stay tuned ;)