programming interview questions

Top 15 programming interview questions

37314 Jobs openings for programming

Valgrind does debug error

I have been trying to follow the online tutorial for Learn C The Hard Way.

However after setting up valgrind (I followed other links that help setting up valgrind on ubuntu 12.04), when I try to debug the c executable, I find the following errors.

ayusman@ayusman-ubuntu:~/lcthw$ valgrind ./ex4
==1984== Memcheck, a memory error detector
==1984== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==1984== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==1984== Command: ./ex4

valgrind:  Fatal error at startup: a function redirection
valgrind:  which is mandatory for this platform-tool combination
valgrind:  cannot be set up.  Details of the redirection are:
valgrind:  A must-be-redirected function
valgrind:  whose name matches the pattern:      strlen
valgrind:  in an object with soname matching:   ld-linux-x86-64.so.2
valgrind:  was not found whilst processing
valgrind:  symbols from the object with soname: ld-linux-x86-64.so.2
valgrind:  Possible fixes: (1, short term): install glibc's debuginfo
valgrind:  package on this machine.  (2, longer term): ask the packagers
valgrind:  for your Linux distribution to please in future ship a non-
valgrind:  stripped ld.so (or whatever the dynamic linker .so is called)
valgrind:  that exports the above-named function using the standard
valgrind:  calling conventions for this platform.  The package you need
valgrind:  to install for fix (1) is called
valgrind:    On Debian, Ubuntu:                 libc6-dbg
valgrind:    On SuSE, openSuSE, Fedora, RHEL:   glibc-debuginfo
valgrind:  Cannot continue -- exiting now.  Sorry.


Is there something that I can do to make valgrind finally work?

I have ubuntu 12.04 on virtual box. My laptop is a Windows 7 64 bit OS.

Source: (StackOverflow)

Wanting to start development for Ubuntu (and most Linux distributions in general), which is suitable? Python or Vala? [closed]

I'm a computer science graduate, and learned languages like C, C++, C# and Java. Though I have more experience with Java. I want to develop for Linux and I'd prefer to develop for GNOME, I'm confused between choosing one from the Python and Vala.

After going through some documentation on Vala on GNOME Live pages, it seems more familiar to me compared to Python, which is quite a different syntactically compared to most languages I've learned during my graduation. While learning curve in Vala seems smaller to me. So, which language should I choose to begin development, which has better support in variety of distributions. A recommended IDE for suggested language will be appreciated.


Source: (StackOverflow)

Can I write programs in C# on Ubuntu?

I am forced to learn and practice C#, is there any applications that support and can be used to write programs in C#?

Source: (StackOverflow)

Putting an arbitrary gtk.Widget into an appindicator.Indicator

Putting any gtk.Widget inside a gtk.Menu works, somewhat, by putting an empty gtk.MenuItem in first. It doesn't seem to be reliable - but it basically works. With an appindicator.Indicator, it doesn't work. The entry just stays empty. Even if you set the child[border_size] to 32, for example.

The only widget that works is a gtk.Label (plus the MenuItem, ImageMenuItem and so on of course).

Now the Me Menu has got a gtk.Entry in it, so it must surely be possible to do this Properly. How do I do it?

Here's some example code to explain what I'm on about:

    self.item = gtk.MenuItem()
    self.item.add(gtk.Label("hello world!"))

The above code works, this however doesn't:

    self.item = gtk.MenuItem()

Where self.menu is an appindicator.Indicator, if it were a gtk.Menu, the Entry would be at least displayed.

Here's some working code:

import gtk
import appindicator

class AppIndicator (object):

    def __init__(self):
        self.ind = appindicator.Indicator("hello world client",
            "distributor-logo", appindicator.CATEGORY_APPLICATION_STATUS)
        self.ind.set_status (appindicator.STATUS_ACTIVE)
        self.menu = gtk.Menu()
        item = gtk.MenuItem()

        item.add(gtk.Label("hello world"))
        # item.add(gtk.Entry())


indicator = AppIndicator()

Source: (StackOverflow)

Why won't strace/gdb attach to a process even though I'm root?

  • I logged in as root but strace gives me this:

    root@kyznecov-System:/home/kyznecov# ps -e | grep 111
     3807 pts/2    00:00:00 111
     3810 pts/2    00:00:00 111
    root@kyznecov-System:/home/kyznecov# strace -p 3810
    attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted
    Could not attach to process.  If your uid matches the uid of the target
    process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
    again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
    root@kyznecov-System:/home/kyznecov# cat /proc/sys/kernel/yama/ptrace_scope
  • I then tried to use gdb to debug a multiprocess program in Eclipse CDT with forking, and it gave me the same result/error:

    enter image description here

Any ideas?

Source: (StackOverflow)

What's the difference between GTK and QT?

Please bear with me as I'm a newcomer to Linux. I've been writing GUI programs in REALbasic on a Mac for several years. I'm trying to learn Python and I want to write GUI apps for Linux (primarily Ubuntu and Mint since they are the distros I have access to and they seem to be the most popular). I basically have three questions:

  1. Are there any significant differences between GTK and QT
  2. I've toyed with quickly and Glade on Ubuntu but I understand that they are based on GTK 2 and this is now obsolete. Is that correct?
  3. Are there any all-in-one editors that let me design a GUI and then add Python code to it? (for instance, add a button to a window in the editor, double click the button and then add the Python code that is to execute when the button is pressed)

Sorry if these are really dumb questions but I want to start learning the 'right' tools from the start.

Source: (StackOverflow)

What is a command to compile and run C++ programs?

I am new to Linux. I am using Ubuntu 11.04 and do not know how to compile and execute C++ program in it. I need to know the commands to Compile and Execute a C++ program in Linux.

Source: (StackOverflow)

C programing suites/IDEs [duplicate]

Possible Duplicate:
What IDEs are available for Ubuntu?

I know that asking for something like Visual Studio is too much but something that will let me write, debug and compile in a GUI instead of the command line is good enough for me. (Not that I'm lazy, but I don't have time to learn the necessary commands...)

Source: (StackOverflow)

I am looking for a small (Ubuntu) open-source-project for which I can code

I have basic C and C++ programming skills as well as a little bit experience with gtkmm and Linux-programming in general (not to forget I have lots of spare time). I want to participate in an Ubuntu project which is small and not too complex in order to improve my programming sills and of course support Ubuntu.

Can you give me pointers in the right direction and do you know of a project where I could start?

Source: (StackOverflow)

Is there a Visual Studio style tool/IDE?

I have been developing in the windows space with Visual Studio for a while now with work, but I have also been using Ubuntu for a while and am keen to get into some software development for linux.

I should also note. I am not looking for .NET and I am aware of mono. I am also familiar with c++ development and some python, so the language isn't so much relevant as the "all in one" aspect.

I was interested to know if there is a useful all in one code/debug/design(gui) IDE similar to something like Visual Studio but for linux?

Source: (StackOverflow)

Native, FOSS GUI prototyping tools? [duplicate]

This question already has an answer here:

As part of my job as a web developer, I spend an amount of time doing UI prototypes to show the client. It's a pain in the behind but sometimes it has to be done.

I've seen Shuttleworth (and the design team) pump out images like this:

Balsamiq Mockups example

That's made by something called Balsamiq Mockups... Something that balances on top of Adobe Air (yack!) and costs $79.

I've tried it but it kept falling over. I think it had something to do with Air not the app itself. My point is if I'm paying out for something, I want it to be native.

Source: (StackOverflow)

I want to fix a bug. Where do I start?

Although I am not a professional programmer, I have written a program or two. Yet, nowadays every engineer and scientist learns to program a bit as well, and as such I am used to writing programs in Python, C and MATLAB. Now I want to give back a bit to Ubuntu and its great folks and fix a bug!

I had a look at the list of the bitesize campaign and had to find that most of them are not that easy for me to fix as I suspect they require a lot of time to get into the matter, and I do not have that. Still I discovered this one and it looks manageable and like a cool feature to me.

As I have never written a patch or released a program to the wild before though, I have no idea where to start. What should be my first step to tackle that problem?

Bottom line: Where and how do I start fixing that guy?

Source: (StackOverflow)

How could I begin C++ programming on Ubuntu?

I recently switched to Ubuntu from Windows 7. I was previously learning C++ with Microsoft's IDE, Visual Studio.

  • How would I go about programming C++ on Ubuntu, preferably with an IDE?

Source: (StackOverflow)

Multiple terminal windows

I develop code. I use terminal alot. I use many terminal windows alot. I hate how tabs look.

Any useful applications that allow for multiple terminal use, and streamline my development. allow me to keep multiple terminals in focus?

Please and thank you.

Source: (StackOverflow)

What BASIC intepreters are available?

Was asked by a new Ubuntu user - who also wants to learn about programming - what he could use to run BASIC code. He was working through a BASIC book before trying out Ubuntu, and he'd like to continue without having to switch back to Windows.

It looks like there are a few BASIC packages in the standard repositories, as well as projects like Mono which may include some kind of BASIC support.

What would be a good recommendation from the standard repositories - or from a deb package - for someone learning the basics of BASIC and new to Ubuntu?

Source: (StackOverflow)