Setting Up a Test Environment for C++14
When I wrote this week's feature article on the new features of C++14, I needed to set up a test environment where I could use the new features, without any of that work becoming accidentally intermingled with my production toolchain. The obvious solution to this problem is to use a virtual machine and set it up with the test environment. As I have an MSDN subscription that entitles me to many hours per month on a free Microsoft Azure instance, I chose that path.
Interestingly, I did all my development using clang from the LLVM project running on a ubuntu-14.04 LTS system hosted on Microsoft Azure, using the monthly MSDN credits. I'm never sure how much those free credits really mean, but I haven't used them up yet, and it's pleasant to experiment on a well-managed VM.
My first step after creating the VM and using puTTY for an SSH connection was to install Dropbox using the generic installer from the Dropbox site:
cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf - ~/.dropbox-dist/dropboxd
This gives me a URL I can use to authenticate this Dropbox account. I go to my browser to enable this VM as a legitimate user of my Dropbox account. After that, I want to use the Dropbox CLI script to control it, so I kill
dropboxd with CTRL-C, then:
wget -O ~/dropbox.py https://www.dropbox.com/download?dl=packages/dropbox.py chmod u+x ~/dropbox.py ~/dropbox.py start
I can now check up on the status with
~/dropbox.py status, as my source files are linked to this computer. Meanwhile, I need to install the components of clang that are going to give a 3.4 compatible workstation:
sudo apt-get update sudo apt-get install clang-3.4 sudo apt-get install libc++-dev sudo apt-get install binutils # create helloworld.cpp then test clang++ -stdlib=libc++ -std=c++1y helloworld.cpp
After installing clang-3.4, libc++, and binutils, a typical example is built using this command line on Linux:
clang++ -std=c++1y -stdlib=libc++ example.cpp
Overall, it's a remarkably simple process that delivers on one of the clearest use cases for VMs.