Debug a Program

From PCLinuxOSHelp Knowledge Base
Jump to: navigation, search

How you can try debug programs / apps:

Debug with terminal / console.

Linux about errors in the windows informs us very rarely. If you want to see what hurts the program you have to run it from the terminal/console a corresponding command.


  • I walk to the directory of the application.
  • I open terminal here.
  • I open application
  $ ./blockattack_nonet.i386
  ./blockattack_nonet.i386: error while loading shared libraries: 
  cannot open shared object file: No  such file or directory

This error says: application cannot find file. Now you can try searching for the answer or help on the forum,19.0.html

We can try use command or search in google what package provide this library.

Command: apt-cache searchfile name_file

   [gg@localhost ~]$ apt-cache searchfile libphysfs
   libphysfs-devel-2.0.3-1pclos2013: /usr/lib/
   libphysfs1.0-1.0.1-2pclos2007: /usr/lib/
   libphysfs1.0-1.0.1-2pclos2007: /usr/lib/
   libphysfs2-2.0.3-1pclos2013: /usr/lib/
   libphysfs2-2.0.3-1pclos2013: /usr/lib/

Now we know two things.

  1. This lib should be in package libphysfs
  2. libphysfs package have files in /usr/lib/

On 64 bit systems this command maybe not will work very well, probably "index" package is stopped for repository, so I created own script, maybe help you.

If missing lib exist in this package your problem is probably solved, you can install package and application should working. But in this case this library with this name not exist.

So if we don't have package with missed lib, we need install it. ( In this case, latest is libphysfs2-2.0.3-1pclos2013 )

But app still does not work because there is no needed file.
Most similar files are:


You can try redirect application from to

  • How do this ?

Try create symbolic link (click link if you don't know what it is) In this case.

cd /usr/lib
ln -s


  • If lib exist in old package but not in new,

Sometimes you need read documentation on package website which files link.
( example search home page physfs )
( not lib-physfs, because lib is only suggestion --> " this is only library " )

Ok, In this case this application now working. :)

But what we can do if have installed missed lib ( with the same name ) but application don't working ? :(

You can try use strace or ltrace tool

Debug with strace command.

strace or ltrace -> this is very simple but useful debugging tool working in terminal, if you see from terminal error about missing dependencies / libs.

  • If you want use this tool you need install this first.

How use ?


   [gg@localhost ~]$ strace -e open firefox
   open("/etc/", O_RDONLY|O_CLOEXEC) = 3
   open("/lib/i686/", O_RDONLY|O_CLOEXEC) = 3
   open("/lib/", O_RDONLY|O_CLOEXEC) = 3
   open("/lib/i686/", O_RDONLY|O_CLOEXEC) = 3
   open("/usr/lib/", O_RDONLY|O_CLOEXEC) = 3
   open("/lib/i686/", O_RDONLY|O_CLOEXEC) = 3
   . . .

Now you know what libs in this example firefox use, and where this libs firefox looking. You can compare this with result "apt-cache searchfile" and if application looking lib in another place, you can create symbolic link to redirect lib.

How use this output with grep ?


   $ strace  -e open firefox 2>&1 | grep font
     open("/usr/lib/", O_RDONLY|O_CLOEXEC) = 4
     open("/usr/lib/", O_RDONLY) = 4

2>&1 this is redirection output you can more find about redirection in google, in bash tutorials, example

Other example:

  $ strace -y /usr/bin/firefox 2>&1 | grep acces | grep -v search | grep plugins
    access("/home/user_name/.mozilla/firefox/dqh2nb5k.default-1441864569209/plugins", F_OK) = -1 ENOENT (No such file or directory)
    access("/home/user_name/.mozilla/plugins", F_OK) = -1 ENOENT (No such file or directory)
    access("/usr/lib64/firefox/browser/plugins", F_OK) = -1 ENOENT (No such file or directory)
    access("/usr/lib/mozilla/plugins", F_OK) = 0

This example show paths where firefox searching plugins. This example working for firefox-41.0.2, in older firefox worked strace -e open firefox

Check on new user account.

  • Try create user account, and login to new user account, then try run program.
  • If program working, problem exist in settings in old user account.
  • You can try find and delete this settings file and reboot computer, or use new user account.
Useful link for KDE users: 


Missing / empty icons.

try change theme , try change icons in system (sometimes package icons do not contain everything)

Useful commands.

How find name installed package.

You can check from Synaptic (Package Manager) You can also sometimes from shortcuts and from terminal, for example how find firefox

     $ rpm -qa | grep firefox 

How list files from package.

  $ rpm -ql firefox | grep "bin"

rpm -ql show all files from package, grep show from this output only lines which contain word "bin". You can list package like this, if you have installed.

How find package which provide path.

   $ rpm -qf /usr/lib/os-probes/mounted/90linux-distro

Some paths / files are not owned by any package, because sometimes packages contain commands which create files or folders and rpm not provide this paths.