Linux Mint 15 CodeLite Unit Tests

When I created my first Unit Test in CodeLite it would not compile because UnitTest++.h was not available.

I loaded libunittest with:

sudo apt-get install libunittest++-dev


Then added /usr/include/unittest++ to the CodeLite compiler includes by opening the Build Settings dialog which is on the Settings menu.


printf format strings

I copied this excellent quick reference guide from Pádraig Brady at PixelBeat lest it should go offline at some point in the future.


%[flags][min field width][precision][length]conversion specifier
  -----  ---------------  ---------  ------ -------------------
   \             #,*        .#, .*     /             \
    \                                 /               \
   #,0,-,+, ,',I                 hh,h,l,ll,j,z,L    c,d,u,x,X,e,f,g,s,p,%
   -------------                 ---------------    -----------------------
   # | Alternate,                 hh | char,           c | unsigned char,
   0 | zero pad,                   h | short,          d | signed int,
   - | left align,                 l | long,           u | unsigned int,
   + | explicit + - sign,         ll | long long,      x | unsigned hex int,
     | space for + sign,           j | [u]intmax_t,    X | unsigned HEX int,
   ' | locale thousands grouping,  z | size_t,         e | [-]d.ddde±dd double,
   I | Use locale's alt digits     t | ptrdiff_t,      E | [-]d.dddE±dd double,
                                   L | long double,  ---------=====
   if no precision   => 6 decimal places            /  f | [-]d.ddd double,
   if precision = 0  => 0 decimal places      _____/   g | e|f as appropriate,
   if precision = #  => # decimal places               G | E|F as appropriate,
   if flag = #       => always show decimal point      s | string,
                                             ..............------
                                            /          p | pointer,
   if precision      => max field width    /           % | %

Linux Mint 15 Codelite C++11 gcc 4.7.3

I'm experimenting with C++11 using CodeLite 5.1 and gcc 4.7.3

The support for C+11 is experimental and has to be turned on with a compiler switch. This page describes the alternatives.

I used -std=c++11


which I set in the Project Settings dialog. Common Settings / Compiler / C++ Compiler Options, like this:


I also made the compiler switch available to all build configurations by adding to the Build Settings dialog which is on the Settings option of the main menu:

Linux Mint 15 Launch Browser with Function Key

On my Compaq 6820s (UK keyboard) the F3 key should have launched the default web browser but didn't.

I used the Keyboard Shortcuts app to redefine the key used to launch the browser:

Linux Mint 15 Suspend when power button is pressed

I wanted my Compaq 6820s to Suspend when the power button was pressed. Using the Power Management application I set the General tab options like this:


But the results were unreliable, something along the lines of:
Press Power -> Laptop Suspends
Press Power -> Laptop Resumes, briefly, then Shuts Down
Press Power -> Laptop boots

I looked at the /etc/acpi/powerbtn.sh

I don't know how this script works but the last two lines caught my eye:

# If all else failed, just initiate a plain shutdown.
/sbin/shutdown -h now "Power button pressed"


Which makes it quite difficult to catch problems. So I commented out the last line:

sudo pluma /etc/acpi/powerbtn.sh

# If all else failed, just initiate a plain shutdown.
#/sbin/shutdown -h now "Power button pressed"


And that was sufficient to give me the result I was looking for. Now the power button consistently follows the actions in the Power Management settings.

Linux Mint 15 Suspend when laptop lid is closed

I tried to use Power Management to set my laptop to Suspend when the lid is closed but instead it simply blanked the screen.

I found a workaround here, thanks to Unrealist.

In the file /etc/acpi/lid.sh comment out this line . /usr/share/acpi-support/screenblank something like this:


sudo pluma /etc/acpi/lid.sh

if [ $? = 0 ]
then
    for x in /tmp/.X11-unix/*; do
 displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
 getXuser;
 if [ x"$XAUTHORITY" != x"" ]; then
     export DISPLAY=":$displaynum"     
     #. /usr/share/acpi-support/screenblank
 fi
    done


Recompiling Xorg Radeon on Mint 15

As part of my efforts to get my Compaq 6820 ATI Radeon Rv516 video to run at full resolution of 1440x900 I attempted to recompile the Xorg Radeon driver. Ultimately this proved to be a dead end but this blog entry records the useful tidbits I learned along the way. (The working solution is here.)


I'm following the instructions at X.org to recompile Radeon.


apt-get build-dep xserver-xorg-video-ati


fails with:

E: You must put some 'source' URIs in your sources.list


In Mint 15 the new Software Sources screen makes updating the 'sources.list' simple by checking the "Enable source code repositories" checkbox.



The Python script used by the Software Sources screen can be found here:

/usr/lib/linuxmint/mintSources/mintSources.py


The mintSources.py script updates

/etc/apt/sources.list.d/official-source-repositories.list
and a quick 'cat' reveals the source URIs:

cat /etc/apt/sources.list.d/official-source-repositories.list
deb-src http://packages.linuxmint.com/ olivia main upstream import 

deb-src http://archive.ubuntu.com/ubuntu/ raring main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ raring-updates main restricted universe multiverse

deb-src http://security.ubuntu.com/ubuntu/ raring-security main restricted universe multiverse
deb-src http://archive.canonical.com/ubuntu/ raring partner


Back to the x.org instructions:

./autogen.sh --prefix=/opt/xorg


which failed because libdrm was out of date, it required version 2.4.44.

checking for LIBDRM... no
configure: error: Package requirements (libdrm >= 2.4.44) were not met:

Requested 'libdrm >= 2.4.44' but version of libdrm is 2.4.43

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBDRM_CFLAGS
and LIBDRM_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.


I tracked down libdrm.pc using:

find / -name "libdrm.pc"


and manually changed the version number using:

pluma /usr/local/lib/pkgconfig/libdrm.pc


That seemed unlikely to work but it was sufficient to get past ./autogen.sh

However the subsequent "make" command then failed because of a new flag that was used introduced in libdrm 2.4.44:

surface->flags |= RADEON_SURF_HAS_TILE_MODE_INDEX;


So next I downloaded the 2.4.44 source for libdrm:

http://dri.freedesktop.org/libdrm/libdrm-2.4.44.tar.bz2


And following its README that compiled first time.

Back to the x.org instructions and now "make" and "make install" are successful.

But the resolution is still showing only 1152x864.

Running inxi -G reports:

Graphics:  Card: Advanced Micro Devices [AMD] nee ATI RV516/M62-S [Mobility Radeon X1350] 
           X.Org: 1.13.3 drivers: ati,vesa,radeon (unloaded: fbdev) FAILED: fglrx Resolution: 1152x864@60.0hz 
           GLX Renderer: Gallium 0.4 on llvmpipe (LLVM 3.2, 128 bits) GLX Version: 1.4 (2.1 Mesa 9.1.1)


Linux Mint (Mate) Restarting X Server

Making an error in xorg.conf invariably leaves me at the command prompt. To reset xorg.conf and get the X server working again I login and run:

su
service mdm stop
X -configure
cp /root/xorg.conf.new /etc/X11/xorg.conf
service mdm start

Linux Mint System Info

To get the details of the video graphics use:

inxi -G

and for full system info use:

inxi -F

Linux Mint 15 XORG Compaq 6820s ATI Radeon Rv516

I've spent a lot of time trying to get the video to run at its native resolution of 1440x900 and failed miserably finally succeeded.

Step 1
Change grub to use NOMODESET as described in Installing Mint 14 or Mint 15 Compaq 6820s

Step 2
Add these lines to /etc/init.d/rc.local
modprobe -r radeon
modprobe -r drm
modprobe radeon modeset=1

To give something like this:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          rc.local
# Required-Start:    $remote_fs $syslog $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Run /etc/rc.local if it exist
### END INIT INFO

modprobe -r radeon
modprobe -r drm
modprobe radeon modeset=1


Step 3
Reboot



Credits
I got the solution from this Redhat kernel thread, specifically Comment #104 so thanks to Lyonel Vincent.

Linux Mint get release version code name

The code name is used in some of the Python scripts to access version specific directories. They use this command:

lsb_release -sc

Linux Mint updating an Environment Variable

To list all the environment variables:

env


To extend the contents of an existing one:

export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH

Linux Mint Find command

JJ helped me to track down libdrm with:

sudo find / -name "*libdrm*"

Or starting in a more specific directory:

sudo find ./Documents -name "*libdrm*"

Or starting in the current directory:

sudo find -name "*libdrm*"

And no need for wildcards if you know the file name:

sudo find / -name "libdrm.pc"

grep and or case insensitive file contents

A reminder of the common ways I use grep

Case insensitive
grep -i

OR
grep "pattern1\|pattern2\|pattern3"

AND
grep "pattern1" | grep "pattern2"

NOT
grep -v "pattern"

Within Files
grep "pattern" filename

For example:
grep "pattern" *.htm
grep "pattern" *.c