[sane-devel] Compiling test program against libsane
Jeffrey Ratcliffe
jeffrey.ratcliffe at gmail.com
Fri Jul 6 20:28:40 UTC 2012
I'm trying to track down a bug, which I think is in HPLIP, and I have
this test program, which compiles and runs fine on my gentoo box:
#include <stdio.h>
#include <sane/sane.h>
int
main (int argc, char **argv) {
SANE_Status status;
SANE_Int version_code;
SANE_Auth_Callback authorize;
SANE_Handle h;
const SANE_Device **device_list;
int i = atoi(argv[2]);
printf("initialising sane... ");
status = sane_init(&version_code, authorize);
printf("%s\n", sane_strstatus (status));
printf("opening %s, %d times\n", argv[1], i);
while (i-- > 0) {
printf("opening %s... ", argv[1]);
status = sane_open(argv[1], &h);
printf("%s\n", sane_strstatus (status));
sane_close(h);
}
sane_exit;
}
However, on my Ubuntu Precise box, I'm getting:
$ gcc -lsane -L/usr/lib/i386-linux-gnu/ -I/usr/include/
hplip_segfault.c -o hplip_segfault
/tmp/cciw9jNN.o: In function `main':
hplip_segfault.c:(.text+0x3a): undefined reference to `sane_init'
hplip_segfault.c:(.text+0x4a): undefined reference to `sane_strstatus'
hplip_segfault.c:(.text+0xa6): undefined reference to `sane_open'
hplip_segfault.c:(.text+0xb6): undefined reference to `sane_strstatus'
hplip_segfault.c:(.text+0xca): undefined reference to `sane_close'
collect2: ld returned 1 exit status
where the contents of /usr/lib/i386-linux-gnu/pkgconfig/sane-backends.pc is
prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib/i386-linux-gnu
includedir=${prefix}/include
ldflags=-Wl,-Bsymbolic-functions
libs=
Name: SANE Backends
Description: Backends for SANE, the universal scanner interface
Version: 1.0.22
Requires:
Libs: -L${libdir} -lsane
Libs.private: ${ldflags} ${libs}
Cflags: -I${includedir}
Has anyone any insight on how to get this linking properly?
Regards
Jeff
More information about the sane-devel
mailing list