Pages

Tuesday, August 30, 2011

Comapre File Line By Line

 1. Check whether tool "diff" is installed in your system by typing "diff" in terminal.
    If the output is similar to the below one then diff tool is not installed in your system

   diff: missing operand after `diff'
   diff: Try `diff --help' for more information.

2. If the tool diff is not installed, install it using synaptic or terminal(sudo apt-get install diff)

3. Type the following command in the terminal

   diff filename1 filename2

  The above command will print the difference between the two files on the screen.
 You can also direct the output to another file using following command.

  diff filename1 filename2 >> filename3

  You can also ignore case of file contents using follwoing command

  diff -i --ignore-case filename1 filename2 >>filename3

4. For more options of diff
    Type(in terminal) :

    man diff




Fixing GPG Keys in UBUNTU


NOTE: Your hexadecimal numbers may be different then mine, so make sure to use the hexadecimals numbers in your error, not mine.

W: GPG error: http://ppa.launchpad.net jaunty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6D975C4791E7EE5E
W: A error occurred during the signature verification. The repository is not updated and the previous index files will be used.GPG error: http://ppa.launchpad.net jaunty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5A9BF3BB4E5E17B5

W: GPG error: http://ppa.launchpad.net jaunty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7FB8BEE0A1F196A8
W: Failed to fetch http://ppa.launchpad.net/chromium-da...jaunty/Release
W: Some index files failed to download, they have been ignored, or old ones used instead.




The fix for this is to re-download the keys using the hexidecimal numbers given in the error .
Type this command into the terminal ("Applications > Accessories > Terminal" OR press "Ctrl-Alt-Del")
Code:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys

And then add the hexadecimal numbers to the command (again, these are my keys from my error. Make sure to use your own):

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6D975C4791E7EE5E 5A9BF3BB4E5E17B5 7FB8BEE0A1F196A8


The output should look like this:

"gpg: requesting key 437D05B5 from hkp server keyserver.ubuntu.com"


NOTE: Your hexadecimal numbers may be different then mine, so make sure to use the hexadecimals numbers in your error, not mine.











http://ubuntuforums.org/showthread.php?t=1221323

Sunday, February 6, 2011

Configuring Codeblocks to compile Gtk based programs

Problem: Getting "ERROR: gtk/gtk.h: No such file or directory" while trying to compile code using Gtk library.

Information: The problem with above error is that the code which you have written asks to insert gtk/gtk.h contents, but the preprocessor is unable to find that file. The compiler goes through the search path defined by your IDE and could not find the file.
This problem can come when either your system does not contain these files and/or the search path is not defined properly.To solve the first issue, you need to download the Gtk+-2.0 development package. Then add search path to find the gtk.h file.
Once you have done this, expect it to work as far as compiling process. The linker will then complain about "undefined references". This will indicate that the compiler correctly understood the name and prototypes of all the functions, but now the linker cannot actually find the libraries (actual already compiled libraries) that contain those functions.
At this point, you will have to find the setting in your IDE that dictates which libraries you are linking against. Then you need to add search path to find the necessary libraries in LIKER option.
To help in searching path a toll called pkg-config can be used.pkg-config will automatically look for the Gtk libraries and will provide an easy mechanism to compile the Gtk programs.


Steps:
1) Downloading the gtk+-2.0 development package:
    Open the synaptic manager and install the 'libgtk2.0-dev' package from it.
2)
  2.1) If you want to compile the code from the terminal type the following command(in red color)
         gcc `pkg-config --cflags --libs gtk+-2.0` 1.c -o hello to compile the .c file

        There should not be any error after this.

 2.2) Configuring Code::blocks
        I set up options globally since I wanted to use codeblocks just to practice gtk.
        Go to Settings->Compilers and Debuggers and added:
        To edit compiler search path, go to Other options in compiler setting and add this
        `pkg-config --cflags gtk+-2.0 `

        To edit linker search path, go to Other link options inlinker setting and add this
        `pkg-config --libs gtk+-2.0 `

        Note : bactick`` substitues its output before executing the whole command

Screenshots :

Compiler setting



Linker Setting:
























References :
Information about compiling GTK+ applications-- :  http://library.gnome.org/devel/gtk/stable/gtk-compiling.html
Codeblok configuration(Commnet no #3) :   http://ubuntuforums.org/showthread.php?t=498306
More information about compilers and linker (Read first comment of Moschops) :  http://www.cplusplus.com/forum/beginner/34141/