Thursday, October 28, 2010

To find function declaration in static library

The following command finds a reference to function "gtk_widget_get_pango_context" in static library libwxOil.a:

linux-bvhg:~/> nm -l -C libwxOil.a  | grep gtk_widget_get_pango_context
                 U gtk_widget_get_pango_context(_GtkWidget*)  /home/myname/src/XaraLX/wxOil/ftfonts.cpp:868

GLIB and wxWidget Class conflict

When compiling XaraLX, there is a conflict between GLIB-2.0 and  wxWidget 2.8 as shown below:

/usr/local/include/glib-2.0/gio/giotypes.h:127:47: error: conflicting declaration `typedef struct _GSocket GSocket'
/usr/include/wx-2.8/wx/unix/gsockunx.h:41:1: error: `class GSocket' has a previous declaration as `class GSocket'

The quick solution is to modify <XaraLX directory>/wxOil/ftfonts.cpp.  Edit this file and change from:

#ifdef __WXGTK20__
#include <gtk/gtk.h>
extern GtkWidget *wxGetRootWindow();
#endif

to:

#ifdef __WXGTK20__
//#include <gtk/gtk.h>
extern PangoContext *gtk_widget_get_pango_context    (GtkWidget   *widget);
extern GtkWidget *wxGetRootWindow();
#endif

Microsoft is officially all out to promote Windows 7 mobile

Check this out:

http://create.msdn.com/en-US/home/about/how_it_works_create
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=04704acf-a63a-4f97-952c-8b51b34b00ce&displaylang=en
https://microsoft.promo.eprize.com/windowsphone7/

Thursday, October 14, 2010

To find dependency in Linux dynamic object file/library

linux-bvhg:~> objdump -x `which ffmpeg`

/usr/local/bin/ffmpeg:     file format elf64-x86-64
/usr/local/bin/ffmpeg
architecture: i386:x86-64, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x0000000000405360

Program Header:
PHDR off    0x0000000000000040 vaddr 0x0000000000400040 paddr 0x0000000000400040 align 2**3
filesz 0x00000000000001f8 memsz 0x00000000000001f8 flags r-x
INTERP off    0x0000000000000238 vaddr 0x0000000000400238 paddr 0x0000000000400238 align 2**0
filesz 0x000000000000001c memsz 0x000000000000001c flags r--
LOAD off    0x0000000000000000 vaddr 0x0000000000400000 paddr 0x0000000000400000 align 2**21
filesz 0x0000000000017124 memsz 0x0000000000017124 flags r-x
LOAD off    0x00000000000179c8 vaddr 0x00000000006179c8 paddr 0x00000000006179c8 align 2**21
filesz 0x0000000000001e18 memsz 0x00000000000038a0 flags rw-
DYNAMIC off    0x0000000000018d10 vaddr 0x0000000000618d10 paddr 0x0000000000618d10 align 2**3
filesz 0x0000000000000240 memsz 0x0000000000000240 flags rw-
NOTE off    0x0000000000000254 vaddr 0x0000000000400254 paddr 0x0000000000400254 align 2**2
filesz 0x000000000000005c memsz 0x000000000000005c flags r--
EH_FRAME off    0x0000000000015db0 vaddr 0x0000000000415db0 paddr 0x0000000000415db0 align 2**2
filesz 0x0000000000000304 memsz 0x0000000000000304 flags r--
STACK off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**3
filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw-
RELRO off    0x00000000000179c8 vaddr 0x00000000006179c8 paddr 0x00000000006179c8 align 2**0
filesz 0x0000000000001638 memsz 0x0000000000001638 flags r--

Dynamic Section:
NEEDED               libavdevice.so.52
NEEDED               libavfilter.so.1
NEEDED               libavformat.so.52
NEEDED               libavcodec.so.52
NEEDED               libpostproc.so.51
NEEDED               libswscale.so.0
NEEDED               libavcore.so.0
NEEDED               libavutil.so.50
NEEDED               libpthread.so.0
NEEDED               libm.so.6
NEEDED               libc.so.6
INIT                 0x0000000000404670
FINI                 0x00000000004124e8
HASH                 0x00000000004002b0
GNU_HASH             0x0000000000400960
STRTAB               0x0000000000401f48
SYMTAB               0x00000000004009d0
STRSZ                0x0000000000000f0d
SYMENT               0x0000000000000018
DEBUG                0x0000000000000000
PLTGOT               0x0000000000618fe8
PLTRELSZ             0x0000000000001320
PLTREL               0x0000000000000007
JMPREL               0x0000000000403350
RELA                 0x00000000004031a0
RELASZ               0x00000000000001b0
RELAENT              0x0000000000000018
VERNEED              0x0000000000403020
VERNEEDNUM           0x000000000000000b
VERSYM               0x0000000000402e56

Version References:
required from libpostproc.so.51:
0x0826df11 0x00 14 LIBPOSTPROC_51
required from libavcore.so.0:
0x0a34bd40 0x00 12 LIBAVCORE_0
required from libm.so.6:
0x09691a75 0x00 11 GLIBC_2.2.5
required from libavfilter.so.1:
0x0ececed1 0x00 10 LIBAVFILTER_1
required from libavdevice.so.52:
0x07b11f22 0x00 09 LIBAVDEVICE_52
required from libavcodec.so.52:
0x035ff8b2 0x00 08 LIBAVCODEC_52
required from libavutil.so.50:
0x0f818430 0x00 07 LIBAVUTIL_50
required from libswscale.so.0:
0x027973e0 0x00 05 LIBSWSCALE_0
required from libavformat.so.52:
0x0c7032c2 0x00 04 LIBAVFORMAT_52
required from libpthread.so.0:
0x09691a75 0x00 03 GLIBC_2.2.5
required from libc.so.6:
0x0d696917 0x00 13 GLIBC_2.7
0x0d696913 0x00 06 GLIBC_2.3
0x09691a75 0x00 02 GLIBC_2.2.5

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
0 .interp       0000001c  0000000000400238  0000000000400238  00000238  2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .note.ABI-tag 00000020  0000000000400254  0000000000400254  00000254  2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .note.SuSE    00000018  0000000000400274  0000000000400274  00000274  2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .note.gnu.build-id 00000024  000000000040028c  000000000040028c  0000028c  2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .hash         000006b0  00000000004002b0  00000000004002b0  000002b0  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .gnu.hash     0000006c  0000000000400960  0000000000400960  00000960  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
6 .dynsym       00001578  00000000004009d0  00000000004009d0  000009d0  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
7 .dynstr       00000f0d  0000000000401f48  0000000000401f48  00001f48  2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
8 .gnu.version  000001ca  0000000000402e56  0000000000402e56  00002e56  2**1
CONTENTS, ALLOC, LOAD, READONLY, DATA
9 .gnu.version_r 00000180  0000000000403020  0000000000403020  00003020  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .rela.dyn     000001b0  00000000004031a0  00000000004031a0  000031a0  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
11 .rela.plt     00001320  0000000000403350  0000000000403350  00003350  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
12 .init         00000018  0000000000404670  0000000000404670  00004670  2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
13 .plt          00000cd0  0000000000404688  0000000000404688  00004688  2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
14 .text         0000d188  0000000000405360  0000000000405360  00005360  2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
15 .fini         0000000e  00000000004124e8  00000000004124e8  000124e8  2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
16 .rodata       000038b0  0000000000412500  0000000000412500  00012500  2**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
17 .eh_frame_hdr 00000304  0000000000415db0  0000000000415db0  00015db0  2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
18 .eh_frame     0000106c  00000000004160b8  00000000004160b8  000160b8  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
19 .ctors        00000010  00000000006179c8  00000000006179c8  000179c8  2**3
CONTENTS, ALLOC, LOAD, DATA
20 .dtors        00000010  00000000006179d8  00000000006179d8  000179d8  2**3
CONTENTS, ALLOC, LOAD, DATA
21 .jcr          00000008  00000000006179e8  00000000006179e8  000179e8  2**3
CONTENTS, ALLOC, LOAD, DATA
22 .data.rel.ro  00001310  0000000000617a00  0000000000617a00  00017a00  2**5
CONTENTS, ALLOC, LOAD, DATA
23 .dynamic      00000240  0000000000618d10  0000000000618d10  00018d10  2**3
CONTENTS, ALLOC, LOAD, DATA
24 .got          00000098  0000000000618f50  0000000000618f50  00018f50  2**3
CONTENTS, ALLOC, LOAD, DATA
25 .got.plt      00000678  0000000000618fe8  0000000000618fe8  00018fe8  2**3
CONTENTS, ALLOC, LOAD, DATA
26 .data         00000180  0000000000619660  0000000000619660  00019660  2**5
CONTENTS, ALLOC, LOAD, DATA
27 .bss          00001a88  00000000006197e0  00000000006197e0  000197e0  2**5
ALLOC
28 .comment.SUSE.OPTs 00000006  0000000000000000  0000000000000000  000197e0  2**0
CONTENTS, READONLY
29 .comment      00000042  0000000000000000  0000000000000000  000197e6  2**0
CONTENTS, READONLY
SYMBOL TABLE:
no symbols


Tuesday, October 12, 2010

To test Prime Number

#include <stdio.h>


typedef enum {
    FALSE = 0,
    TRUE = 1
} BOOL;

char *boolstr[] = {"FALSE", "TRUE"};

BOOL is_even(unsigned int k)
{
    if (k % 2) return FALSE;
    return TRUE;
}

BOOL is_prime(unsigned long k, unsigned long *divisor)
{
    unsigned long testnum,testlimit;
    BOOL ret = FALSE;

    if (k == 1) return FALSE; // 1 is neigher prime neither composite
    if (k == 2) return TRUE;
    if (is_even(k)) return FALSE; // even numbers are never prime, except 2
    testlimit = k;
    testnum = 3;
    while (testnum < testlimit) {
        //printf("highest prime divisor=%lu\n",*divisor);
        if ( (k % testnum) == 0)
        {
            *divisor = testnum;
            printf("div=%lu\n", *divisor);
            return FALSE; //return TRUE;
            // k is not prime as it is divisable by l

        }
        testlimit = k/testnum;
        testnum += 2;

    }
    return TRUE;
}


int main()
{
    unsigned long k,divisor;

    divisor=1;
    printf("Enter an integer: ");
    scanf("%lu", &k);
    printf("k=%lu is even? %s\n", k, boolstr[is_even(k)]);
    if (is_prime(k, &divisor))
    {
        printf("k=%lu is prime? %s\n", k, boolstr[TRUE]);
    }
    else
    {
        printf("%lu is NOT prime\n", k);
        //printf("highest prime divisor = %lu\n", divisor);
    }
}

Tuesday, October 5, 2010

3D Entertainment

While 3D televisions are more available in the stores, their price is still high and not many people are getting into it.  Perhaps because there is still few BD 3Dd movies.  But now 3D camcoders are going into the market.  We will see if this change how people buy LCD TVs.

Today, when I went to Costco, the 42" 120 Hz LED 3D TV is already below $2000.