Tag Archives: Linux

Tech Book: Linux Kernel Development, Robert Love

LinuxKernelDevelopmentLinux Kernel Development (Robert Love)
I picked up this book at the ACCU 2012 conference from their Charity Book stall (for a small donation). This is the 2005 version, so slightly out of date. I’m finding the mix of low-level detail (down to names of data types and methods) in amongst high-level theory (memory management, process scheduling) hard – but there’s certainly plenty of useful detail.

ThreeStars

Leave a comment

Filed under Tech Book

Writing C++11 concurrency code on Linux Mint with gcc 4.7.2

I’ve written some C++11 concurrency code in VS2012 with the November CTP and wanted to test if it would also run on Linux compiled with gcc – hence the effort to upgrade my laptop over the last couple of days. The upgrade worked fine – I’m quite impressed with Linux Mint and with CodeBlocks. Unfortunately, gcc 4.7.2 has left me disappointed.

Firstly, I tried to compile my whole concurrency project – I was expecting a few minor tweaks (gcc was stricter on how I declare my template functions), then I hit this Internal Compiler Error:

Concurrency.cpp:156:1: internal compiler error: in get_expr_operands, at tree-ssa-operands.c:1035

Apparently, this bug has been fixed but not yet released – it’s due to calling a member function from a lambda in a templated class. So I thought I’d cut my code down, eliminate the lambdas and focus on std::thread and std::condition_variable. Still no joy, this time the program aborted:

LinuxAbort1

In fact, it seems this is a long standing issue. And the code to provoke it is hardly pushing the boundaries of threading:

void sayHelloWorld()
{
    std::cout << "Hello World\n";
}

int main()
{
    std::thread talk( sayHelloWorld );
    talk.join();
    return 0; 
}

Looking on the bright side, gcc 4.8 should be along soon and I’m sure the support for std::thread and lambdas will be working by then. In the meantime, I’ll be hanging out with VS2012 Nov CTP.

1 Comment

Filed under C++ Code

Programming C++ on Linux Mint

First of all, let me say how easy it was to install CodeBlocks and CodeLite on Linux Mint using the Software Manager.  The user guide makes a terrific case for the Linux package management approach, but putting this UI on top (instead of using the command line as I was in Kubuntu) takes it to the next level.  For a start, it’s browsable and you can read reviews from other users.  I’ve installed CodeBlocks, CodeLite and g++.  I really like the way that the sections in Software Manager match the groupings from the start menu (so that my programming related applications are together and easily visible).

CodeBlocks
First impressions – not bad, it detected that I wanted to use gcc as my compiler.  I created a simple Hello World project and it compiled first time.  When I tried to add C++11 features, I got compile errors – but those were resolved by editing the Project build options and enabling “Have g++ follow the coming C++0x ISO C++ language standard”, i.e. -std=c++0x.  I rather like this dialog – it offers other useful compiler options too like “-Weffc++” to turn on Effective C++ warnings, with each compiler flag neatly explained.  As soon as I’d enabled -std=c++0x, the lambda and auto that I’d added compiled and ran just fine.

CodeLite

Oh dear.  Firstly, it offered to download a new version of CodeLite for me.  Given that I only just did it in Software Manager, that seemed a bit odd.  Next, I tried to create a new workspace – it crashed.  I tried to open the workspace it had created – crashed again.  This is probably because Software Manager needs to be updated to download the latest version, but I’ve uninstalled it for now.

Leave a comment

Filed under C++, Programming

Installing Linux Mint

I’ve decided to install a new flavour of Linux, as mentioned in my earlier post. Even choosing Mint ahead of Fedora and Bodhi hasn’t narrowed down the choices sufficiently – I then had to choose between the KDE, Xfce and vanilla versions. Then for the vanilla, you have to choose MATE or Cinnamon!

Having opted for the vanilla, Cinnamon version, I downloaded the ISO file and burned it to a DVD. Now the fun part – my Sony Vaio does not have an optical drive, but I have an external one so wired it up. Then, I had to boot up the laptop, press F2 to edit the BIOS and a) enable booting from external device b) put external device before the hard disk in the boot order. But I still couldn’t install from the Boot disk – it just wasn’t recognized when booting.

Instead, I used MagicISO CD/DVD manager, which virtually mounts an ISO as a CD/DVD drive. That took me to an option to install Linux Mint as part of Windows. Unfortunately, it forced me to uninstall the Wubi Kubuntu that I’d previously installed, but since that was broken anyway, I went ahead. I had to manually re-run mint4win.exe due to the kubuntu uninstall, then I could start the installation onto my local c:\.

LinuxMint - install1

This installation only took a couple of minutes(*), then a mandatory re-boot, then voila. If I’d just run the installation directly from the ISO image instead of trying to burn a DVD and boot from it, this would have taken 10 minutes rather than 2 hours.

LinuxMint - install2

The Linux Mint desktop started without any manual editing in blacklist files (unlike when I installed Kubuntu last year). I didn’t have any trouble hooking up to Wifi either, just worked out of the box. My laptop is now dual-boot with Linux Mint v Windows 7 – not bad.

LinuxMint - install3

(*)Except – looks like that was only to run in Live mode (as if from the DVD). The give away was that it forgot my Wifi settings when I next booted into Linux. To actually install, I clicked on the “Install Linux Mint” desktop icon. The instructions were well explained in the handy user guide and only took about 15 minutes.

2 Comments

Filed under Programming, Technology

Choosing a new brand of Linux

I started trying to upgrade my Kubuntu installation so that I could use gcc 4.7 and test the portability of some C++11 code I’ve been writing. So far, it’s not good news – despite having upgraded gcc and Eclipse, the standard library hasn’t upgraded (/usr/lib/c++ only contains 4.6) and trying to install libstdc++ results in obscure error messages.

So the time has come to try a new Linux distribution. Going back a year or so, installing Kubuntu was a chore – my Vaio laptop’s graphics driver wasn’t recognised and I recall making some low-level changes to get it working. Therefore, my main priority is to pick a Linux distribution with easy installation and that hints at good hardware support.

This article talks about Fedora, Mint and Bodhi. Funny that this could be a case of ‘better the devil you know’ – I know an Ubuntu derivative was a pain last time, but at least I did find examples of other people having the same issue as me! I’d never heard of Bodhi before, but it sounds ideal – very fast to install and is an Ubuntu derivative so should support my Vaio hardware.

As for an IDE, I was never very impressed with Eclipse, so I’ll try something else. Each of Codeblocks, NetBeans and CodeLite get good comments.

Leave a comment

Filed under Programming, Technology