Re: convutf8.cpp:236: error: invalid conversion from 'const char**' to 'char**'

Mark Craig <[email protected]> Wed, 26 Jan 2011 09:59:58 +0100
Newsgroups gmane.comp.mozilla.devel.directory
Message-ID <[email protected]>
Thanks Rich,

Anton, (if you are still following these discussions) does what I have
done inline look like the right thing to be doing on Mac OS X?

In mozilla/directory/c-sdk/ldap/clients/tools/convutf8.cpp, I made a
small change based on your suggestion, Rich.

=A0/* Type used for the src parameter to iconv() (the 2nd parameter) */
-#if defined(_HPUX_SOURCE) || defined(__GLIBC__)
+#if defined(_HPUX_SOURCE) || defined(__GLIBC__) || defined(DARWIN)

That fixed my compilation problem. Yet I found another issue with the binar=
ies.

$ cd /Users/mark/NetBeansProjects/mozilla/dist
$ export DYLD_LIBRARY_PATH=3D/Users/mark/NetBeansProjects/mozilla/dist/Darw=
in9.8.0_DBG.OBJ/lib
$ ./bin/ldapsearch -p 1389 -b dc=3Dexample,dc=3Dcom uid=3Duser.0
ldapsearch: conversion from 646 to UTF-8 is not supported
ldapsearch: warning: no conversion of filter to UTF-8
ldapsearch: conversion from 646 to UTF-8 is not supported
ldapsearch: warning: no conversion of base DN to UTF-8

So I made an additional change to convutf8.cpp. Here's the diff
showing both changes.

$ hg diff ldap/clients/tools/convutf8.cpp
diff -r 3f7d52e53a9d c-sdk/ldap/clients/tools/convutf8.cpp
--- a/c-sdk/ldap/clients/tools/convutf8.cpp Thu Jan 06 12:12:22 2011 +0000
+++ b/c-sdk/ldap/clients/tools/convutf8.cpp Wed Jan 26 09:47:53 2011 +0100
@@ -83,13 +83,15 @@
=A0#elif defined(_WIN32)
=A0#define LDAPTOOL_CHARSET_DEFAULT "windows-1252" /* Windows */
=A0#define LDAPTOOL_CHARSET_WINANSI "ANSI" /* synonym */
+#elif defined(DARWIN)
+#define LDAPTOOL_CHARSET_DEFAULT "UTF-8" /* Mac OS X */
=A0#else
=A0#define LDAPTOOL_CHARSET_DEFAULT "646" /* all others */
=A0#endif

=A0/* Type used for the src parameter to iconv() (the 2nd parameter) */
-#if defined(_HPUX_SOURCE) || defined(__GLIBC__)
-#define LDAPTOOL_ICONV_SRC_TYPE char ** /* HP/UX and glibc (Linux) */
+#if defined(_HPUX_SOURCE) || defined(__GLIBC__) || defined(DARWIN)
+#define LDAPTOOL_ICONV_SRC_TYPE char ** /* HP/UX, glibc (Linux), and
Mac OS X */
=A0#else
=A0#define LDAPTOOL_ICONV_SRC_TYPE const char ** /* all others */
=A0#endif

Now, after I compile again, at least ldapsearch seems to work.

$ ./bin/ldapsearch -p 1389 -b dc=3Dexample,dc=3Dcom uid=3Duser.0
version: 1
dn: uid=3Duser.0,ou=3DPeople,dc=3Dexample,dc=3Dcom
postalAddress: Aaccf Amar$01251 Chestnut Street$Panama City, DE=A0 50369
postalCode: 50369
uid: user.0
description: This is the description for Aaccf Amar.
employeeNumber: 0
initials: ASA
givenName: Aaccf
objectClass: person
objectClass: inetorgperson
objectClass: organizationalperson
objectClass: top
pager: +1 779 041 6341
mobile: +1 010 154 3228
cn: Aaccf Amar
telephoneNumber: +1 685 622 6202
sn: Amar
street: 01251 Chestnut Street
homePhone: +1 225 216 5900
mail: [email protected]
l: Panama City
st: DE

Again, thanks for getting me unstuck. Hope you're having a good new year.

Regards,
Mark

On Wed, Jan 26, 2011 at 4:19 AM, Rich Megginson
<[email protected]> wrote:
>
> On 01/25/2011 11:00 AM, Mark Craig wrote:
>>
>> Hello,
>>
>>
>> I am trying to compile the LDAP C SDK, but failing to compile convutf8.c=
pp
>> as shown inline. What should I do differently to get the C SDK to compil=
e?
>>
>>
>> Mac OS X 10.5.8
>>
>> Xcode 3.1.4 developer tools
>>
>> I put all the code next to my NetBeans projects. Yet I am compiling from=
 the
>> command line for now.
>>
>>
>> First I do the NSS step, getting the code from CVS. This all seems to wo=
rk
>> fine.
>>
>>
>> export CVSROOT=3D:pserver:[email protected]:/cvsroot
>>
>> cvs co mozilla/nsprpub
>>
>> cvs co mozilla/security/coreconf mozilla/security/nss mozilla/security/d=
bm
>> mozilla/dbm
>>
>> cd mozilla/security/nss/
>>
>> make nss_build_all
>>
>>
>> Autoconf for the C SDK seems to find NSS and NSPR. But then something go=
es
>> haywire with convutf8.cpp...
>>
>>
>> hg clone http://hg.mozilla.org/projects/ldap-sdks/ mozilla/directory
>>
>> cd mozilla/directory/c-sdk
>>
>> ./configure --with-nss --with-nspr --enable-clu
>>
>> make
>>
>> c++ -o convutf8.o -c =A0 =A0 -pipe -Wmost -fno-common -pthread -O =A0 -U=
DEBUG
>> -DNDEBUG=3D1 -DXP_UNIX=3D1 -DDARWIN=3D1 -DHAVE_BSD_FLOCK=3D1 -Di386=3D1
>> -DHAVE_LCHOWN=3D1 -DHAVE_STRERROR=3D1 -DHAVE_GETADDRINFO=3D1 -DHAVE_GETN=
AMEINFO=3D1
>> =A0 =A0 -DNET_SSL =A0-DNO_LIBLCACHE -DLDAP_REFERRALS =A0 =A0 -DNS_DOMEST=
IC
>> -DFORCE_PR_LOG -D_PR_PTHREADS -UHAVE_CVAR_BUILT_ON_SEM
>> -I/Users/mark/NetBeansProjects/mozilla/dist/public/nss
>> -I/Users/mark/NetBeansProjects/mozilla/dist/Darwin9.8.0_DBG.OBJ/include
>> -I../../../../../dist/public/ldap -I../../../ldap/include =A0convutf8.cpp
>>
>> convutf8.cpp: In function 'char* convert_to_utf8(const char*, const char=
*)':
>>
>> convutf8.cpp:236: error: invalid conversion from 'const char**' to 'char=
**'
>>
>> convutf8.cpp:236: error: =A0 initializing argument 2 of 'size_t iconv(vo=
id*,
>> char**, size_t*, char**, size_t*)'
>>
>> convutf8.cpp:239: error: invalid conversion from 'const char**' to 'char=
**'
>>
>> convutf8.cpp:239: error: =A0 initializing argument 2 of 'size_t iconv(vo=
id*,
>> char**, size_t*, char**, size_t*)'
>>
>> convutf8.cpp:242: error: invalid conversion from 'const char**' to 'char=
**'
>>
>> convutf8.cpp:242: error: =A0 initializing argument 2 of 'size_t iconv(vo=
id*,
>> char**, size_t*, char**, size_t*)'
>>
>> make[2]: *** [convutf8.o] Error 1
>>
>> make[1]: *** [export] Error 2
>>
>> make: *** [export] Error 2
>>
>>
>> Thanks for your help.
>
> Looks like convutf8.cpp was not ported to this platform. =A0Note that --e=
nable-clu is not used for Thunderbird builds which is probably why no one h=
as seen this before. =A0The problem is here beginning on line 90:
> /* Type used for the src parameter to iconv() (the 2nd parameter) */
>
> #if defined(_HPUX_SOURCE) || defined(__GLIBC__)
> #define LDAPTOOL_ICONV_SRC_TYPE char ** =A0 =A0 =A0 =A0 /* HP/UX and glib=
c (Linux) */
> #else
> #define LDAPTOOL_ICONV_SRC_TYPE const char ** =A0 /* all others */
> #endif
>
> Looks like on this platform the iconv() function expects char ** not cons=
t char **. =A0Since you're not using HPUX or GLIBC, LDAPTOOL_ICONV_SRC_TYPE=
 is being defined as const char **.
>
> If you can edit the source or add a patch, you could add an
> #ifndef LDAPTOOL_ICONV_SRC_TYPE
> ...
> #endif
>
> block around this code, and add a define of
> #define LDAPTOOL_ICONV_SRC_TYPE char **
> wherever you set your defines/build flags for your project.
>
>>
>> Regards,
>>
>> Mark
>
> Cheers, Mark!
> _______________________________________________
> dev-tech-ldap mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-tech-ldap