I tried to make a simple program from zbar example code and compiled it 
successfully. However, when I try to run, it throws Segmentation fault 
(core dumped) error though I try with same code on laptop, it just works 
fine. Any suggestions?

Extra information:
*I have installed zbar

My code (demo.c): 


#include <stdio.h>
#include <zbar.h>

static void my_handler (zbar_image_t *image,
                        const void *userdata)
{
    /* extract results */
    const zbar_symbol_t *symbol = zbar_image_first_symbol(image);
    for (; symbol; symbol = zbar_symbol_next(symbol))
    {
        /* TODO do something useful with results */
        zbar_symbol_type_t typ = zbar_symbol_get_type(symbol);
        const char *data = zbar_symbol_get_data(symbol);
        printf("decoded %s symbol \"%s\"\n",
               zbar_get_symbol_name(typ), data);
    }
}

int main (int argc, char **argv)
{
    
    /* TODO find out the default device */
    const char *device = "/dev/video0";

    /* setup zbar library standalone processor */
    zbar_processor_t *proc = zbar_processor_create(1);
    
    /* configure the processor */
    zbar_processor_set_config(proc, 0, ZBAR_CFG_ENABLE, 1);

    /* initialize the processor */
    if (argc > 1)
        device = argv[1];
    zbar_processor_init(proc, device, 1);
    /* resolution is limited to 240x320 */
    zbar_processor_request_size(proc, 320, 240);

    /* setup a callback */
    zbar_processor_set_data_handler(proc, my_handler, NULL);

    /* disable the preview window */
    zbar_processor_set_visible(proc, 0);
    /* start video */
    zbar_processor_set_active(proc, 1);

    /* keep scanning until user provides key/mouse input */
    zbar_processor_user_wait(proc, -1);

    /* clean up */
    zbar_processor_destroy(proc);

    return (0);
}


Compile with gcc (on board):
gcc -Wall -g -O2 -lzbar -mtune=cortex-a8 -march=armv7-a demo.c -o demo


Also try 
gcc -Wall -g -lzbar demo.c -o demo



gdb

(gdb) run
Starting program: /root/zbar_demo/demo 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0xb6d0fa68 in XUnmapWindow () from /usr/lib/libX11.so.6
(gdb) backtrace 
#0  0xb6d0fa68 in XUnmapWindow () from /usr/lib/libX11.so.6
#1  0xb6fbde18 in ?? () from /usr/lib/libzbar.so.0
Backtrace stopped: previous frame identical to this frame (corrupt stack?)


Thanks in advance 
P/s Sorry for my bad english.

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to