Category Archives: linux

Problem with #define from other libraries

While building a qt project with libxdo xdo.h I faced some strange problems with qt enum names conflicting with X #define macros.

There is no standard way of including headers the one which works is the best. For Qt I think it is recommended to include qt headers first then your files and other library files. This worked for me. To begin with I started to do #undef before include for each terms for which compiler was complaining. It was becoming really messy as there were many conflicts.

Another issue was below error

undefined reference to `xdo_new(char*)'

Inline with xdo.h I was including it in C++ project. libxdo is C project and it doesn’t have extern “C” declaration as other libraries have.

To fix above just use below:

extern "C" {
#include <xdo.h>



Running DHCP client manually

dhclient: Dynamic Host Configuration Protocol Client

dhclient eth0

I have to put above in init.d to make it run at startup. In my system something was screwed and eth0 was not getting the IP address.

dhclient is also used for renewing IP address

dhclient -r && dhclient

Running application just with X11

I have ubuntu core on my system without any UI just the bare bone minimum ubuntu core. I want the system to run some qt application nothing else.

There was two ways to it either I can take the Ubuntu mate and remove useless stuff and make my process run at startup with auto-login or to use bare bone ubuntu core and then just add the things needed to run my application.

Actually I would not have needed anything else for qt application and just used –platform linuxfb flag to run the Qt app with gun on the frame buffer. I actually did that but the problem was frame buffer approach was too slow I can actually see the screen restoring from top to bottom and for my application there was some times where screen was updated quite frequently. So I needed some other windowing system library like Wayland or X11 to handle the slow Frame buffer approach.

I chose X11 first and with some hiccups I made it work woohoo!!

You just need to install xorg and then use startx. I have put this in startup script inside /etc/init.d I will cover application starting at boot up in some other post.

apt-get install  libqt5declarative5  
# for my qt application this will install qt5-default and other qt related dependencies

It was quite a great learning and good experience to make everything work. Now the ubuntu core boots with my splash and starts all three of my qt apps with Gui and works well. It is very fast and no extra processes consuming my processor or hogging the system’s RAM. No window manager no session manager no desktop manager.

You can start any application simply by

startx application_name

How to give permissions to devices

Many a time you face with this challenge that as a user you do not have permission to read write a device file in Linux without becoming sudoer.

Example: Let us say you have a USB device say a camera or any other device file let us say /dev/uinput the file for multi touch.
You want to read write these files in your program.

You can only run this program with sudo as the device files will not be accessible otherwise.

There is a workaround to make these files read/writable once and for all by doing something like:

sudo chmod 777 /dev/uinput

But You need to do above on each restart and also not a great way to handle this problem.

There is an easy way by creating rules file inside /etc/udev/rules.d.
For example:

# DVP sensor driver rule

KERNEL=="video0", SUBSYSTEM=="video4linux", ATTRS{name}=="vfe_0", GROUP="video", MODE:="766"

All ip assigned within a network

Many a time you wanted to know the assigned ip addresses in your LAN. My use cases:

I was working on nano pi neo cheapest things can be!!

You don’t want to move from your ass but this is more of a reason when you already know how to do this 🙂

Okay so on windows you have Advanced ip scanner. You can even log into your router and get to see the client list this is always the easiest way but (ohh but again)..   what if you have reset your router password. Most of the time you will forgot it!! It is not often that you need to login into your router so reset password means forgot. Do you want to reset the router password now just for this with router’s reset button. Or you are in office or you don’t own the router.

Anyway whatever your cause is here is a very easy command to get the list of all assigned ip using linux system:

sudo apt-get install nmap

:~$ sudo nmap -sP

Starting Nmap 6.40 ( ) at 2017-01-04 18:23 IST
Nmap scan report for (
Host is up (0.00024s latency).
MAC Address: 1C:5F:2B:4D:05:71 (Unknown)
Nmap scan report for
Host is up (0.00028s latency).
MAC Address: FA:7B:DE:ED:46:55 (Unknown)
Nmap scan report for
Host is up.
Nmap done: 256 IP addresses (3 hosts up) scanned in 3.27 seconds

If there are not much of machines in your LAN you will figure out which machine has what ip or you can ssh to each to verify. Without nmpa also you can ping all the ip and get the list but nmpa also tells you the friendly name of the machine.