Setting up cppcheck

To install pre-built cppcheck: http://cppcheck.sourceforge.net/

sudo apt-get update
sudo apt-get install cppcheck

In case, you want to use latest cppcheck, download and build it from the source code

wget https://github.com/danmar/cppcheck/archive/2.1.tar.gz
tar zxvf 2.1.tar.gz
cd cppcheck-2.1
mkdir build
cd build
cmake ..

P.S: In case you are interested for cppcheck GUI use cmake -DBUILD_GUI=ON ..

make
sudo make install

Once installation is complete.

which cppcheck
/usr/local/bin/cppcheck

cppcheck --version
Cppcheck 2.1

Build your cpp project with cmake and pass on an extra parameter -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE to cmake. It will produceĀ  compile_commands.json file in your build folder for the project.

Execute cppcheck -p </path/to/folder/having/compile_command.json>.

To use it in VSCode add following to the tasks.json

{
    "label": "Run cppCheck",
    "command": "/usr/local/bin/cppcheck",
    "args": [
       "--project=${workspaceRoot}/build/compile_commands.json"
    ],
    "problemMatcher": "$gcc",
}

Ref: https://gist.github.com/aakbar5/268a2072138345893b7f82590dcc3d26

Create .desktop file

To create .desktop file in Ubuntu

[Desktop Entry]
Type=Application
Name=EclipseC++
GenericName=Eclipse
Comment=Eclipse for development
Exec=/path/to/eclipse
Icon=/path/to/icon.xpm
Terminal=false
MimeType=text/plain;
Categories=Development;IDE
StartupNotify=true
# If you won't specify following line you may end having duplicate icons
# in Ubuntu Dock bar where first is the one you have added to Dock and the
# other one is showing the running application. To avoid this issue you need
# to add following line in .desktop file
StartupWMClass=Eclipse
# How to determine value of StartWMClass for any application:
# – Run your application
# – Run xprop WM_CLASS from the commandline
# – Your mouse cursor will be in different shape
# – Click the window bar of the your application
# – Note down the value(s) printed on the console where you executed xprop
# – These printed values will be WM_CLASS(STRING) = "ABC", "RST", "XYZ"
# – Use any of the string shown in "xxx" for StartupWMClass in .desktop file. For example
# you can use ABC or RST or XYZ.

view raw
.desktop
hosted with ❤ by GitHub

symlinks in virtualbox

If you are using Windows in Virtualbox ontop of Linux based (i.e: Ubuntu) machine, you might have seen this problem that accessing symlinks in windows does not work. Instead of showing contents after resolving Linux symlinks, you will end up with “Protocol error”.

This error can be fixed using vBoxManage by setting a boolean property (SharedFoldersEnableSymlinksCreate) against each folder shared with VirtualBox based machine.

VBoxManage setextradata <VirtualMachineName> VBoxInternal2/SharedFoldersEnableSymlinksCreate/<SharedFolderName> 1

After executing above command, verify your change with following:

VBoxManage getextradata <VirtualMachineName> enumerate