[freetds] iconv identifier redefinition, iconv plug mode

Isak Johnsson isak at hypergene.com
Tue Apr 6 16:15:05 EDT 2004


Hello!

I've run into the iconv problems you touched upon a while ago 
(http://lists.ibiblio.org/pipermail/freetds/2004q1/015433.html). I've 
digged a little bit more into it, maybe this can be of some help...

Out of the box, it doesn't work...

$ cd freetds-0.63.dev.20040405
$ ./configure --enable-msdblib --with-iodbc=/ --with-tdsver=8.0
$ make
gcc -DHAVE_CONFIG_H -I. -I. -I../../include -I../../include 
-D_FREETDS_LIBRARY_SOURCE -I/usr/local/include -DIODBC -DMSDBLIB 
-D_REENTRANT -D_THREAD_SAFE -DDEBUG=1 -Wall -Wstrict-prototypes 
-Wmissing-prototypes -Wno-long-long -g -O2 -MT token.lo -MD -MP -MF 
.deps/token.Tpo -c token.c  -fno-common -DPIC -o .libs/token.o
token.c: In function `tds7_get_data_info':
token.c:1426: error: structure has no member named `libiconv'


The cause is apparently these lines in the system iconv.h file:

#ifndef LIBICONV_PLUG
#define iconv libiconv
#endif
extern size_t iconv (iconv_t cd, const char* * inbuf, size_t 
*inbytesleft, char* * outbuf, size_t *outbytesleft);


This can be used to work around the compilation problem:

$ export CFLAGS=-DLIBICONV_PLUG
$ ./configure --enable-msdblib --with-iodbc=/ --with-tdsver=8.0
$ make


...but it doesn't feel like the "right" way... The iconv homepage says 
this:

	This library can be built and installed in two variants:
		• 	 The library mode. This works on all systems, and uses a library  
libiconv.so and a header file <iconv.h>. (Both are installed  through 
"make install".)
		...
		• 	 The libc plug/override mode. This works on GNU/Linux, Solaris and 
OSF/1  systems only.
			It is a way to get good iconv support without having  glibc-2.1.  It 
installs a library
			libiconv_plug.so. This library can be used with  LD_PRELOAD, to 
override the
			iconv* functions present in the C library.


To me, it sounds like the first method is the way to go. But the 
workaround above seemingly uses the second, or maybe a mix of the two.


It looks quite dangerous to redefine the identifier 'iconv' in the 
header file, as they are doing, but I guess there is some thought 
behind it. Can FreeTDS take some action to remedy this? Such as 
undef-ing iconv right after the include directive, or using another 
name for the member...

BTW, how come this have stopped working? It must have been working once?

Isak




More information about the FreeTDS mailing list