sane-backends
#1
sane-backends
Hi,

I have the nekoware sane-backeds 1.0.19 but it doesn't seem to work with my scanner (it just sits there in wait_4_light but the light is already on) so I'm trying to build the latest 1.0.27.

I have a working toolchain (MIPSpro 7.4.4 + nekoware gmake on 6.5.30) and I've managed to take the nekoware 1.0.19 sources and rebuild them into something that works by using the tips in /usr/nekoware/relnotes/neko_sane_backends.txt:

-----
setenv AR_FLAGS "cru -o"  
setenv AR "CC -ar -ptused -quiet_prelink "
setenv CC /usr/bin/cc
setenv LDFLAGS "-L/usr/nekoware/lib -L/usr/lib32/mips4 -L/usr/local/lib -L/usr/lib32 "
setenv CFLAGS " -DIP32 -O3 -n32  -mips4 -OPT:Olimit=0:roundoff=3  -TARG:platform=IP27:proc=r10000  -L/usr/local/lib -L/usr/lib32"  
setenv CPPFLAGS " -DIP32 -I/usr/nekoware/include/freetype2 -I/usr/nekoware/include/ -I/usr/nekoware/include/SDL"
setenv CCFLAGS " -DIP32 -O3 -n32  -mips4 -OPT:Olimit=0:roundoff=3  -TARG:platform=IP27:proc=r10000  -L/usr/lib32/mips4 -L/usr/nekoware/lib -L/usr/local/lib -L/usr/lib32"

configure --prefix=/usr/nekoware
gmake
gmake install
-----


1.0.27 has had 10 years of development since 1.0.19 and is not as simple.
I removed the 1.0.19 package so that it doesn't interfere.
I eventually wrangled something that builds but it fails at runtime (during dlopen) with some unresolved symbols. scanimage bombs out immediately. saned bombs out when scanimage connects to it across the network.

Both give an error similar to this:

-----
scanimage: rld: Fatal Error: attempted access to unresolvable symbol in .../libsane.so.1: sane_dll_init
-----


To isolate the problem I tried to rebuild entirely statically and get a similar error message at link time during the build:

-----
/bin/ksh ../libtool  --tag=CC   --mode=link /usr/bin/c99  -DIP32 -O3 -n32  -mips4 -OPT:Olimit=0:roundoff=3  -TARG:platform=IP27:proc=r10000  -L/usr/local/lib -L/usr/lib32  -L/usr/nekoware/lib -L/usr/lib32/mips4 -L/usr/local/lib -L/usr/lib32  -o scanimage
libtool: link: /usr/bin/c99 -DIP32 -O3 -n32 -mips4 -OPT:Olimit=0:roundoff=3 -TARG:platform=IP27:proc=r10000 -o scanimage scanimage.o sicc.o stiff.o  -L/usr/local/lib -L/usr/lib32 -L/usr/nekoware/lib -L/usr/lib32/mips4 ../backend/.libs/libsane.a -ldl -lm .
ld32: WARNING 84 : /usr/lib32/libdl.so is not used for resolving any symbol.
ld32: WARNING 84 : /usr/lib32/libm.so is not used for resolving any symbol.
ld32: WARNING 84 : ../sanei/.libs/libsanei.a is not used for resolving any symbol.
ld32: WARNING 84 : /usr/lib32/libpng.so is not used for resolving any symbol.
ld32: ERROR   33 : Unresolved text symbol "sane_dll_init" -- 1st referenced by ../backend/.libs/libsane.a(libsane_la-dll-s.o).
       Use linker option -v to see when and which objects, archives and dsos are loaded.  
ld32: ERROR   33 : Unresolved text symbol "sane_dll_get_devices" -- 1st referenced by ../backend/.libs/libsane.a(libsane_la-dll-s.o).
       Use linker option -v to see when and which objects, archives and dsos are loaded.  
ld32: ERROR   33 : Unresolved text symbol "sane_dll_open" -- 1st referenced by ../backend/.libs/libsane.a(libsane_la-dll-s.o).
       Use linker option -v to see when and which objects, archives and dsos are loaded.  
ld32: ERROR   33 : Unresolved text symbol "sane_dll_get_option_descriptor" -- 1st referenced by ../backend/.libs/libsane.a(libsane_la-dll-s.o).
       Use linker option -v to see when and which objects, archives and dsos are loaded.  
ld32: ERROR   33 : Unresolved text symbol "sane_dll_control_option" -- 1st referenced by ../backend/.libs/libsane.a(libsane_la-dll-s.o).
       Use linker option -v to see when and which objects, archives and dsos are loaded.  
ld32: ERROR   33 : Unresolved text symbol "sane_dll_get_parameters" -- 1st referenced by ../backend/.libs/libsane.a(libsane_la-dll-s.o).
       Use linker option -v to see when and which objects, archives and dsos are loaded.  
ld32: ERROR   33 : Unresolved text symbol "sane_dll_start" -- 1st referenced by ../backend/.libs/libsane.a(libsane_la-dll-s.o).
       Use linker option -v to see when and which objects, archives and dsos are loaded.  
ld32: ERROR   33 : Unresolved text symbol "sane_dll_read" -- 1st referenced by ../backend/.libs/libsane.a(libsane_la-dll-s.o).
       Use linker option -v to see when and which objects, archives and dsos are loaded.  
ld32: ERROR   33 : Unresolved text symbol "sane_dll_set_io_mode" -- 1st referenced by ../backend/.libs/libsane.a(libsane_la-dll-s.o).
       Use linker option -v to see when and which objects, archives and dsos are loaded.  
ld32: ERROR   33 : Unresolved text symbol "sane_dll_get_select_fd" -- 1st referenced by ../backend/.libs/libsane.a(libsane_la-dll-s.o).
       Use linker option -v to see when and which objects, archives and dsos are loaded.  
ld32: ERROR   33 : Unresolved text symbol "sane_dll_cancel" -- 1st referenced by ../backend/.libs/libsane.a(libsane_la-dll-s.o).
       Use linker option -v to see when and which objects, archives and dsos are loaded.  
ld32: ERROR   33 : Unresolved text symbol "sane_dll_close" -- 1st referenced by ../backend/.libs/libsane.a(libsane_la-dll-s.o).
       Use linker option -v to see when and which objects, archives and dsos are loaded.  
ld32: ERROR   33 : Unresolved text symbol "sane_dll_exit" -- 1st referenced by ../backend/.libs/libsane.a(libsane_la-dll-s.o).
       Use linker option -v to see when and which objects, archives and dsos are loaded.  
ld32: INFO    152: Output file removed because of error.
gmake[1]: *** [scanimage] Error 2
gmake[1]: Leaving directory `/usr/andyjpb/backends-RELEASE_1_0_27/frontend'
gmake: *** [all-recursive] Error 1
-----


These sane_dll_* symbols do not appear *anywhere* in the source tree. Similar sane_* symbols do tho'.


...so I suspect I'm doing something wrong with the linker.


Here's how I'm building:

I start with the setenvs from the 1.0.19 relnotes and then add

-----
gunzip backends-RELEASE_1_0_27.tar.gz
tar xvf backends-RELEASE_1_0_27.tar
cd backends-RELEASE_1_0_27
setenv BACKENDS avision
setenv AR "CC -ar -ptused -quiet_prelink cru -o "
setenv AR_FLAGS
setenv CC /usr/bin/c99
setenv PATH /usr/nekoware/bin:$PATH
# Add #include "../lib/getopt.c" and #include "../lib/getopt1.c" to frontend/scanimage.c frontend/saned.c tools/sane-desc.c
# ./configure --prefix=/usr/andyjpb/sane --without-gphoto2
./configure --prefix=/usr/andyjpb/sane --without-gphoto2 --disable-shared --enable-static
vim include/sane/config.h # Change HAVE_LIB_PNG to undef
gmake
-----


I had to include AR_FLAGS directly in AR otherwise configure wouldn't accept the archiver as one it understood the interface for. I also had to directly include the sane supplied getopt_long stuff as the build failed to realise it needed to build or link that source. Finally I needed to change config.h to tell it that we really didn't want to use the system libpng: it's too old.
We have to use c99 rather than cc as the project has moved to using C99.

This results in the error message above.

This is the offending command:

-----
cd frontend

/bin/ksh ../libtool  --tag=CC   --mode=link /usr/bin/c99   $CFLAGS  -o scanimage scanimage.o sicc.o stiff.o ../backend/libsane.la ../sanei/libsanei.la ../lib/liblib.la -lpng -ljpeg
-----

(Also, I have to write it like that, with $CFLAGS, because if I write it out long-form then the shell runs out of characters for the command line!)


This seems similar to the problem that gijoe77 was experiencing here: http://forums.irix.cc/thread-486.html?highlight=sudoers


Can anyone shed any light on how to debug this further or even what I need to do to fix it?

Indigo | Indy | Indigo2 | O2 | Octane | Fuel
andyjpb
Indigo

Trade Count: (0)
Posts: 7
Threads: 2
Joined: Oct 2018
Website Find Reply
10-15-2018, 08:55 PM
#2
RE: sane-backends
Some observations

- You are using C codebase and are building static archives with 'CC -ar' , but that is the invocation of the archiver for C++ object. Try using 'ar' instead.
- Can you try the command 'ldd scanimage' ? This will tell you what dynamic shared objects are needed for running the scanimage program. It could be that the linker finds other obscure or older versions of sane libraries or dependencies.
dexter1
Administrator

Trade Count: (1)
Posts: 297
Threads: 17
Joined: May 2018
Location: The Netherlands
Find Reply
10-15-2018, 09:18 PM
#3
RE: sane-backends
Thanks for your reply dexter1!

`ldd scanimage` showed the /usr/andyjpb/sane/ version of libsane and everything else was a system library. I removed other version of sane to make sure and am also now trying an entirely static build to ensure that this is not an issue. This static build now fails at build time with the same unresolved symbols.

using

-----
setenv AR ar
-----

results in the following error:

-----
/bin/ksh ../libtool --tag=CC --mode=link /usr/bin/c99 -DIP32 -O3 -n32 -mips4 -OPT:Olimit=0:roundoff=3 -TARG:platform=IP27:proc=r10000 -L/usr/local/lib -L/usr/lib32 -L/usr/nekoware/lib -L/usr/lib32/mips4 -L/usr/local/lib -L/usr/lib32 -o liblib.la
libtool: link: ar .libs/liblib.a liblib_la-md5.o isfdtype.o strcasestr.o strndup.o strsep.o
Illegal option -- .
gmake[1]: *** [liblib.la] Error 1
gmake[1]: Leaving directory `/usr/andyjpb/backends-RELEASE_1_0_27/lib'
gmake: *** [all-recursive] Error 1
-----

quite early on in the build process.

I'm not familiar with the MIPSpro linker so I'm not really sure how to reconcile

-----
CC -ar -ptused -quiet_prelink cru -o
-----

with

-----
ar
-----

...but setting it thus:

-----
setenv AR "c99 -ar -ptused -quiet_prelink cru -o "
-----

results in the unresolved symbols error that I get with CC.

Indigo | Indy | Indigo2 | O2 | Octane | Fuel
andyjpb
Indigo

Trade Count: (0)
Posts: 7
Threads: 2
Joined: Oct 2018
Website Find Reply
10-15-2018, 09:59 PM


Forum Jump:


Users browsing this thread: 1 Guest(s)