Error while Compiling a printer Driver

Hi - I am looking for some guidance on basic C programming. It looks like it should be simple to fix but I have no knowledge of C and despite a lot of searching on the web i am still non the wiser on the finer details.

So the situation is I am planning on doing a lot of scanning so I have picked up a cheep Epson Perfection 1250 flatbed scanner which is supported within Linux. I thought it would be simple to download the drives - but it is proving problematical. As the driver needs to be compiled from the files provided. I have down loaded the Tar file from Epson ( http://download.ebz.epson.net/dsc/du/02/DriverDownloadInfo.do?LG2=EN&CN2=&DSCMI=15831&DSCCHK=dc314c7561f36b1e0796b28c20038ddc9fc14ff3 )and I am following the instructions to compile and load it. I have solved several issues on the way. I have identified and downloaded some missing dependence and made a minor tweek to the Configure file - it was telling me that it could not find GTK. The reason was it was looking for GTK+2.0 and I have GTK+3.0 on my system. Changes to the references from 2.0 to 3.0 resulted in the generation of the Makefiles.

However I have now have a set of errors that are beyond my abilities. The Make command produces errors regarding invalid conversions from 'const void*' to 'const dirent**'. What changes do I make to the script to resolve the errors.

My system is Kernel: 4.15.0-36-generic x86_64 (64 bit)
Desktop: Cinnamon 3.6.7 Distro: Linux Mint 18.3 Sylvia

I will post the output as sub items to this Question if I can.
The instructions I am following are from the readme file within the down load .
1
2
3
4
5
6
7
8
9
10
11
12
4-2  Installing a tar file

Execute the following command to complete the installation.

  # tar -zxvf iscan-${version}-${release}.tar.gz
  # cd iscan-${version}
  # ./configure
  # make
  # make install

Note that the installation of Image Scan! for Linux from tar requires 
that sane has been installed from tar as well.


The final part of the output from the Terminal showing the errors whilst Make is running is as follows.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"make all-recursive
make[1]: Entering directory '/home/roger/Documents/Downloaded_files/epson_scanner/iscan-2.10.0'
Making all in include
make[2]: Entering directory '/home/roger/Documents/Downloaded_files/epson_scanner/iscan-2.10.0/include'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/roger/Documents/Downloaded_files/epson_scanner/iscan-2.10.0/include'
Making all in libltdl
make[2]: Entering directory '/home/roger/Documents/Downloaded_files/epson_scanner/iscan-2.10.0/libltdl'
make all-am
make[3]: Entering directory '/home/roger/Documents/Downloaded_files/epson_scanner/iscan-2.10.0/libltdl'
make[3]: Leaving directory '/home/roger/Documents/Downloaded_files/epson_scanner/iscan-2.10.0/libltdl'
make[2]: Leaving directory '/home/roger/Documents/Downloaded_files/epson_scanner/iscan-2.10.0/libltdl'
Making all in lib
make[2]: Entering directory '/home/roger/Documents/Downloaded_files/epson_scanner/iscan-2.10.0/lib'
if /bin/bash ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I.. -I../include/sane -I../include -g -O2 -MT libimage_stream_la-imgstream.lo -MD -MP -MF ".deps/libimage_stream_la-imgstream.Tpo" -c -o libimage_stream_la-imgstream.lo `test -f 'imgstream.cc' || echo './'`imgstream.cc; \
then mv -f ".deps/libimage_stream_la-imgstream.Tpo" ".deps/libimage_stream_la-imgstream.Plo"; else rm -f ".deps/libimage_stream_la-imgstream.Tpo"; exit 1; fi
g++ -DHAVE_CONFIG_H -I. -I. -I.. -I../include/sane -I../include -g -O2 -MT libimage_stream_la-imgstream.lo -MD -MP -MF .deps/libimage_stream_la-imgstream.Tpo -c imgstream.cc -fPIC -DPIC -o .libs/libimage_stream_la-imgstream.o
imgstream.cc: In static member function 'static lt__handle* iscan::imgstream::find_dlopen(const char*)':
imgstream.cc:262:69: error: invalid conversion from 'int (*)(const void*, const void*)' to 'int (*)(const dirent**, const dirent**)' [-fpermissive]
int count = scandir (dir_name, &match, selector, reversionsort);
^
In file included from imgstream.hh:45:0,
from imgstream.cc:31:
/usr/include/dirent.h:254:12: note: initializing argument 4 of 'int scandir(const char*, dirent***, int (*)(const dirent*), int (*)(const dirent**, const dirent**))'
extern int scandir (const char *__restrict __dir,
^
imgstream.cc: In function 'int iscan::reversionsort(const void*, const void*)':
imgstream.cc:313:27: error: invalid conversion from 'const void*' to 'const dirent**' [-fpermissive]
return versionsort (b, a);
^
In file included from imgstream.hh:45:0,
from imgstream.cc:31:
/usr/include/dirent.h:379:12: note: initializing argument 1 of 'int versionsort(const dirent**, const dirent**)'
extern int versionsort (const struct dirent **__e1,
^
imgstream.cc:313:27: error: invalid conversion from 'const void*' to 'const dirent**' [-fpermissive]
return versionsort (b, a);
^
In file included from imgstream.hh:45:0,
from imgstream.cc:31:
/usr/include/dirent.h:379:12: note: initializing argument 2 of 'int versionsort(const dirent**, const dirent**)'
extern int versionsort (const struct dirent **__e1,
^
Makefile:353: recipe for target 'libimage_stream_la-imgstream.lo' failed
make[2]: *** [libimage_stream_la-imgstream.lo] Error 1
make[2]: Leaving directory '/home/roger/Documents/Downloaded_files/epson_scanner/iscan-2.10.0/lib'
Makefile:395: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/roger/Documents/Downloaded_files/epson_scanner/iscan-2.10.0'
Makefile:310: recipe for target 'all' failed
make: *** [all] Error 2
 

The script from imgstream.cc relating to Const Void to Const dirent is

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
//  imgstream.cc -- 
//  Copyright (C) 2004, 2005  SEIKO EPSON Corporation
//
//  This file is part of the 'iscan' program.
//
//  The 'iscan' program is free-ish software.
//  You can redistribute it and/or modify it under the terms of the GNU
//  General Public License as published by the Free Software Foundation;
//  either version 2 of the License or at your option any later version.
//
//  This program is distributed in the hope that it will be useful, but
//  WITHOUT ANY WARRANTY;  without even the implied warranty of FITNESS
//  FOR A PARTICULAR PURPOSE or MERCHANTABILITY.
//  See the GNU General Public License for more details.
//
//  You should have received a verbatim copy of the GNU General Public
//  License along with this program; if not, write to:
//
//      Free Software Foundation, Inc.
//      59 Temple Place, Suite 330
//      Boston, MA  02111-1307  USA
//
//  As a special exception, the copyright holders give permission
//  to link the code of this program with the esmod library and
//  distribute linked combinations including the two.  You must obey
//  the GNU General Public License in all respects for all of the
//  code used other then esmod.

#include <argz.h>

#include "imgstream.hh"

namespace iscan
{

imgstream::imgstream ()
  : imgstream_base_t (NULL), _fbuf (new filebuf (NULL)), _mine (true)
{
  rdbuf (_fbuf);
  init ();
}

imgstream::imgstream (FILE *fp)
  : imgstream_base_t (NULL), _fbuf (new filebuf (fp)), _mine (true)
{
  rdbuf (_fbuf);
  init ();
}

imgstream::imgstream (filebuf *fb)
  : imgstream_base_t (NULL), _fbuf (fb), _mine (false)
{
  rdbuf (_fbuf);
  init ();
}

imgstream::imgstream (const char * pathname, ios_base::openmode mode)
  : imgstream_base_t (NULL), _fbuf (new filebuf (NULL)), _mine (true)
{
  _fbuf->open (pathname, mode);
  rdbuf (_fbuf);
  init ();
}

void
imgstream::init ()
{
  exceptions (badbit | failbit);

  _h_sz = _v_sz = 0;
  _hres = _vres = 0;
  _bits = 0;
  _cspc = NONE;
}

imgstream::~imgstream ()
{
  if (_mine) {
    if (is_open ()) {
      close ();
    }
    delete _fbuf;
  }
}

bool
imgstream::is_open () const
{
  return _fbuf->is_open ();
}

void
imgstream::open (const char *pathname, ios_base::openmode mode)
{
  if (!_fbuf->open (pathname, mode)) {
    setstate (ios_base::failbit);
  }
}

void
imgstream::close ()
{
  if (!_fbuf->close ()) {
    setstate (ios_base::failbit);
  }
}

imgstream::filebuf *
imgstream::rdbuf () const
{
  return _fbuf;
}

imgstream::filebuf *
imgstream::rdbuf (filebuf *fb)
{
  return static_cast<filebuf *> (imgstream_base_t::rdbuf (fb));
}

imgstream::operator FILE * ()
{
  return *_fbuf;
}

imgstream&
imgstream::size (size_type h_sz, size_type v_sz)
{
  _h_sz = h_sz;
  _v_sz = v_sz;
  return *this;
}

imgstream&
imgstream::resolution (size_type hres, size_type vres)
{
  _hres = hres;
  _vres = vres;
  return *this;
}

imgstream&
imgstream::depth (size_type bits)
{
  _bits = bits;
  return *this;
}

imgstream&
imgstream::colour (colour_space space)
{
  _cspc = space;
  return *this;
}

imgstream::dl_handle
imgstream::dlopen (const char *libname) throw (std::runtime_error)
{
  if (0 != lt_dlinit ()) {
    throw std::runtime_error (lt_dlerror ());
  }

  dl_handle lib = lt_dlopenext (libname);
  if (!lib) {
    const char *message = lt_dlerror ();
    lib = find_dlopen (libname);
    if (!lib) {
      lt_dlexit ();
      throw std::runtime_error (message);
    }
  }
  return lib;
}

imgstream::dl_ptr
imgstream::dlsym (dl_handle lib, const char *funcname)
{
  return lt_dlsym (lib, funcname);
}

int
imgstream::dlclose (dl_handle lib)
{
  return lt_dlclose (lib);
}

static int reversionsort (const void*, const void*);
int selector (const dirent *);
				// forward declarations

//!
/*! A number of distributions seems to have switched to a policy where
    the lib*.so files are provided by their -devel packages.  Moreover,
    the typical workstation install does not include such packages and
    lt_dlopenext() will understandably have trouble finding your lib*.

    This function is a fallback for such cases.  It will look for your
    library in the exact same places as lt_dlopenext(), but with this
    difference that it will try to open any file that matches lib*.so,
    starting with the one with the highest version number.

    Actually, it is just as smart lt_dlopenext() and uses the correct
    shared library extension for your platform.  However, it does not
    try libtool's .la extension.

    The general policy for memory allocation and access problems is to
    ignore them and muddle on or return the current result rightaway.

    This function returns NULL if no suitable library could be found
    and a handle to library otherwise.
 */
imgstream::dl_handle
imgstream::find_dlopen (const char *libname)
{
  using std::bad_alloc;

  dl_handle result = NULL;

  try {				// prepping the selector()
    char *name = new char[ strlen (libname) + strlen (LTDL_SHLIB_EXT) + 1 ];
    name = strcpy (name, libname);
    name = strcat (name, LTDL_SHLIB_EXT);

    _libname = name;		// deleting _libname below, never mind
				// that name goes out of scope here
  }
  catch (bad_alloc& oops) {
    return result;
  }

  char   *pathz  = NULL;
  size_t  length = 0;
  bool    is_pathz_ok = true;
  {				// set up a library search path like
				// that used by lt_dlopen()
    int delimiter = ':';

    const char *path = NULL;

    if ((path = lt_dlgetsearchpath ())
	&& 0 != argz_add_sep (&pathz, &length, path, delimiter)) {
      is_pathz_ok = false;
    }
    if ((path = getenv ("LTDL_LIBRARY_PATH"))
	&& 0 != argz_add_sep (&pathz, &length, path, delimiter)) {
      is_pathz_ok = false;
    }
    if ((path = getenv (LTDL_SHLIBPATH_VAR))
	&& 0 != argz_add_sep (&pathz, &length, path, delimiter)) {
      is_pathz_ok = false;
    }
    if ((path = LTDL_SYSSEARCHPATH)
	&& 0 != argz_add_sep (&pathz, &length, path, delimiter)) {
      is_pathz_ok = false;
    }
  }

  if (is_pathz_ok) {				// go fetch!
    const char *dir_name = NULL;
    while (!result
	   && (dir_name = argz_next (pathz, length, dir_name))) {
      struct dirent **match;
      int count = scandir (dir_name, &match, selector, reversionsort);

      for (int i = 0; !result && i < count; ++i) {

	const char *file_name = match[i]->d_name;
	try {
	  char *abs_file_name
	    = new char[ strlen (dir_name) + strlen ("/") + strlen (file_name)
			+ 1 ];
	  strcpy (abs_file_name, dir_name);
	  strcat (abs_file_name, "/");
	  strcat (abs_file_name, file_name);

	  result = lt_dlopen (abs_file_name);
	  delete abs_file_name;
	}
	catch (bad_alloc& oops) {
	  // just ignore and (try to) continue with the next match
	}
      }
      free (match);		// malloc'd by scandir()
    }
  }

  delete _libname;		// we new'd a name for our selector()
  free (pathz);			// malloc'd by argz_add_sep()

  return result;
}

//! Library name we are looking for.
/*! The scandir() API does not allow for passing arbitrary data to the
    selector().  We use this variable to work around that limitation.

    Note that this makes users of selector() thread unsafe.
 */
const char *imgstream::_libname = NULL;

//! Selects relevant library filenames.
int
selector (const dirent *dir)
{
  return (0 == strncmp (dir->d_name, imgstream::_libname,
			strlen (imgstream::_libname)));
}

//! The C library's versionsort() function in reverse.
static
int
reversionsort (const void *a, const void *b)
{
  return versionsort (b, a);
}

}	// namespace iscan
The problem is reversionsort on line 186/311. Maby it is that simple the you just need to replace const void * with const dirent**. But there is no guarantee that it will work.

My suggestion would be to find a linux distro that supports GTK+2.0 and install it as a virtual machine.
Hi - Thanks for your comments - I will try to change to the script. As for the distro - I suspect that all the current Distros will have upgraded to GTK+2.0 - Whilst I don't understand the finer points between 2.0 and 3.0 I suspect that it would be backward compatible.

Is not the Conversion problem an issue with the script rather than GTK? .
It might be an issue of the c compiler. Older c compiler are less sensitive against pointer types. So that the newer compiler detects an error were the older didn't.
Thanks for that , sounds interesting. - perhaps it would be worth adding the dash instruct the compiler to ignore the error and see what happens. always worth a try particularly as this only relates to the Libary location.
Topic archived. No new replies allowed.