Dear Stef,
Thanks a lot for a provided example. From your code I have made a program (see 
attachment) whichcompiles. However, I can not link it with the libsane-genesys. 
apparently I miss something.
I have compiled SANE libraries as following:> export BACKENDS=genesys> export 
CFLAGS="-D UNIT_TESTING"> ./configure --prefix=.....
The program compiles perfectly as:> gcc -I ./compile/include/ -I 
./compile/backend/ -c tst_scan.c
But when trying to link against libsane-genesys library gcc complains:> gcc -I 
./compile/include/ -I ./compile/backend/ -L ./local/lib/sane/ -l sane-genesys 
tst_scan.c -o tst_scan/tmp/cc958m4x.o: In function `sanei_debug_genesys_call':
tst_scan.c:(.text+0xad): undefined reference to `sanei_debug_msg'
/tmp/cc958m4x.o: In function `main':
tst_scan.c:(.text+0xcd): undefined reference to `sanei_init_debug'
tst_scan.c:(.text+0xe0): undefined reference to `sane_genesys_init'
tst_scan.c:(.text+0xf3): undefined reference to `sane_strstatus'
tst_scan.c:(.text+0x120): undefined reference to `sane_genesys_open'
tst_scan.c:(.text+0x133): undefined reference to `sane_strstatus'
tst_scan.c:(.text+0x14a): undefined reference to `sane_genesys_exit'
tst_scan.c:(.text+0x188): undefined reference to `sanei_genesys_compute_dpihw'
tst_scan.c:(.text+0x2b0): undefined reference to `gl843_init_scan_regs'
tst_scan.c:(.text+0x2ec): undefined reference to `sane_strstatus'
tst_scan.c:(.text+0x32c): undefined reference to `gl843_begin_scan'
tst_scan.c:(.text+0x33f): undefined reference to `sane_strstatus'
tst_scan.c:(.text+0x3b8): undefined reference to 
`sanei_genesys_read_data_from_scanner'
tst_scan.c:(.text+0x3d4): undefined reference to `gl843_end_scan'
tst_scan.c:(.text+0x3e7): undefined reference to `sane_strstatus'
tst_scan.c:(.text+0x42b): undefined reference to `sanei_genesys_write_pnm_file'
tst_scan.c:(.text+0x45b): undefined reference to `sane_genesys_close'
tst_scan.c:(.text+0x460): undefined reference to `sane_genesys_exit'
If I try to use libtool, it complains that I am linking against loadable module

Apparently I am doing something wrong.Please let me know what is the proper way 
of compiling a  unit testing program.
Thanks a lot,Myroslav

#define UNIT_TESTING 1

#define BACKEND_NAME genesys

#include "genesys.h"
#include "genesys_gl843.h"


int main(int argc, char **argv){
    
    DBG_INIT();
    
    
    SANE_Int vc;
    SANE_Auth_Callback cb;
    SANE_Status status;
    SANE_Handle handle;
    Genesys_Scanner *session;
    Genesys_Device *dev;
    
    /* backend init */
    status = sane_genesys_init (&vc, cb);
    if (status != SANE_STATUS_GOOD){
	printf ("sane_init()=%s\n", sane_strstatus (status));
	return 1;
    }
    
    status = sane_genesys_open ("genesys", &handle);
    if (status != SANE_STATUS_GOOD){
	printf ("sane_open()=%s\n", sane_strstatus (status));
	sane_genesys_exit ();
	return 1;
    }
    
    session = (Genesys_Scanner *) handle;
    dev = session->dev;
    
    /* zone de test */
    /*dev->settings.scan_method=SCAN_METHOD_FLATBED;
    status = dev->model->cmd_set->move_to_ta (dev);
    if (status != SANE_STATUS_GOOD){
	DBG (DBG_error, "move_to_ta failed: %s\n", sane_strstatus (status));
    }*/
    
    /* scan */
    float dpi = 100;
    int dpihw = sanei_genesys_compute_dpihw (dev, dpi);
    unsigned int channels = 3;
    unsigned int depth=8;
    unsigned int lines = 1200;
    float startx = 10; // in inches
    unsigned int pixels = 200*dpihw/MM_PER_INCH;
    
    int size= (int)pixels*channels*lines*(depth/8);
    unsigned char *data = malloc (size);
    
    /* round down pixel number */
    unsigned int factor=pixels;
    factor=(factor/2)&0xfffe;
    pixels=factor;
    
    gl843_init_scan_regs (dev,
	    dev->reg,
	    dpi,
	    dpi,
	    startx,
	    0,
	    pixels,
	    lines,
	    depth,
	    channels,
	    SCAN_MODE_COLOR,
	    0,
	    SCAN_FLAG_USE_XPA |
	    SCAN_FLAG_DISABLE_SHADING |
	    SCAN_FLAG_DISABLE_GAMMA |
	    SCAN_FLAG_IGNORE_LINE_DISTANCE);
    
    //......

    Genesys_Register_Set *r;
    
    /*r = sanei_genesys_get_address (dev->reg, 0x98);
    r->value = 0x02;
    r = sanei_genesys_get_address (dev->reg, 0x99);
    r->value = 0xe0;
    r = sanei_genesys_get_address (dev->reg, 0x9b);
    r->value = 0x90;*/
    
    RIE (dev->model->cmd_set->bulk_write_register (dev, dev->reg, GENESYS_GL843_MAX_REGS));
    
    RIE (gl843_begin_scan (dev, dev->reg, SANE_FALSE));
    DBG (DBG_proc, "XXX STEF XXX\n");
    DBG (DBG_proc, "sanei_genesys_start_motor\n");
    DBG (DBG_proc, "ZZZ STEF ZZZ\n");
    sanei_genesys_read_data_from_scanner (dev, data, size);
    RIE (gl843_end_scan (dev, dev->reg, SANE_TRUE));
    sanei_genesys_write_pnm_file ("image.pnm", data, depth, channels, pixels, lines);
    
    /* on gare et on ferme */
    status = dev->model->cmd_set->slow_back_home (dev, SANE_TRUE);
    sane_genesys_close (handle);
    sane_genesys_exit ();
    return 0;
}
-- 
sane-devel mailing list: sane-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to sane-devel-requ...@lists.alioth.debian.org

Reply via email to