Checking for a working iconv in with Samba 3.0.0

Richard Sharpe rsharpe at
Sat Jul 5 00:27:24 GMT 2003


currently in Samba 3.0.0, checks for an iconv library in a 
number of places, and then checks for a working iconv. Here is the code:

# check for iconv in libc
AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
#include <iconv.h>
main() {
       iconv_t cd = iconv_open("ASCII", "UCS-2LE");
       if (cd == 0 || cd == (iconv_t)-1) return -1;
       return 0;
if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
    AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])

Now, the problem is that the comment says checking for it in libc, while 
the AC_CACHE_CHECK message says it is checking for a working iconv.

Further, all over the actual code that needs iconv, there are 



So, if iconv is found in some other library than libc, it will still not 
get used because of these things.

I propose to change the test above to check for a working iconv where ever 
it was found on the system.

I have such a small change that works on FreeBSD (which has two different 
ways to get iconv, GNU libiconv and iconv from the ports collection, which 
both install different libraries).

However, there is also the problem with that define, which should probably 

Does anyone have any issues with me applying the changes?

It also works on Linux (RedHat 9.0). I haven't tested on slowaris yet.
Richard Sharpe, rsharpe[at], rsharpe[at], 

More information about the samba-technical mailing list