From: Sam Roberts Date: 2003-04-14T07:58:19+09:00 Subject: Re: Having trouble getting iconv-0.5 ... on OS X (actually extconf.rb bug) --4Ckj6UjgE2iN1+kY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Quoteing nobu.nokada@softhome.net, on Sun, Apr 13, 2003 at 07:44:34PM +0900: > > Anynow, I went back to having my iconv installed in /sw (kind of the > > /opt of the OS X world). It allows iconv.h to be found, but the > > extconf.rb still isn't figuring out that it needs -liconv, but it works > > when I specify -liconv in the USER_LIBS. > > Can't you show me the mkmf.log? I think what is happening is that GNU iconv (ftp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.7.tar.gz), when not compiled as part of the system, is #defining iconv() to libiconv(). It appears that when extconf.rb looks for iconv(), the c file it generates doesn't include , so it never sees the define. What's odd is that earlier in mkmf.log, I see references to libiconv(). What's happening? Attached is mkmf.log, and iconv.h. Can you make sense of it? Thanks, Sam --4Ckj6UjgE2iN1+kY Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="mkmf.log" gcc -E -traditional-cpp -E -I/sw/include -I/usr/lib/ruby/1.6/powerpc-darwin6.0 -g -Os -pipe -no-cpp-precomp -pipe -pipe -no-precomp -I/usr/include conftest.c gcc: unrecognized option `-no-precomp' cpp0: warning: changing search order for system directory "/usr/include" cpp0: warning: as it has already been specified as a non-system directory # 1 "conftest.c" # 1 "" # 1 "" # 1 "conftest.c" # 1 "/sw/include/iconv.h" 1 # 25 "/sw/include/iconv.h" extern int _libiconv_version; # 47 "/sw/include/iconv.h" typedef void* libiconv_t; # 1 "/usr/include/stddef.h" 1 # 63 "/usr/include/stddef.h" # 1 "/usr/include/machine/types.h" 1 # 30 "/usr/include/machine/types.h" # 1 "/usr/include/ppc/types.h" 1 # 64 "/usr/include/ppc/types.h" # 1 "/usr/include/sys/cdefs.h" 1 # 65 "/usr/include/ppc/types.h" 2 typedef signed char int8_t; typedef unsigned char u_int8_t; typedef short int16_t; typedef unsigned short u_int16_t; typedef int int32_t; typedef unsigned int u_int32_t; typedef long long int64_t; typedef unsigned long long u_int64_t; typedef int32_t register_t; typedef long int intptr_t; typedef unsigned long int uintptr_t; # 31 "/usr/include/machine/types.h" 2 # 64 "/usr/include/stddef.h" 2 # 1 "/usr/include/machine/ansi.h" 1 # 33 "/usr/include/machine/ansi.h" # 1 "/usr/include/ppc/ansi.h" 1 # 92 "/usr/include/ppc/ansi.h" typedef union { char __mbstate8[128]; long long _mbstateL; } __mbstate_t; # 34 "/usr/include/machine/ansi.h" 2 # 65 "/usr/include/stddef.h" 2 typedef int ptrdiff_t; typedef long unsigned int size_t; typedef int rune_t; typedef int wchar_t; # 51 "/sw/include/iconv.h" 2 # 1 "/usr/include/errno.h" 1 # 22 "/usr/include/errno.h" # 1 "/usr/include/sys/errno.h" 1 # 68 "/usr/include/sys/errno.h" extern int * __error (void); # 23 "/usr/include/errno.h" 2 # 54 "/sw/include/iconv.h" 2 # 72 "/sw/include/iconv.h" extern libiconv_t libiconv_open (const char* tocode, const char* fromcode); # 82 "/sw/include/iconv.h" extern size_t libiconv (libiconv_t cd, const char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft); extern int libiconv_close (libiconv_t cd); # 97 "/sw/include/iconv.h" extern int libiconvctl (libiconv_t cd, int request, void* argument); # 2 "conftest.c" 2 gcc -o conftest -I/usr/lib/ruby/1.6/powerpc-darwin6.0 -g -Os -pipe -no-cpp-precomp -pipe -pipe -no-precomp -I/usr/include -I/sw/include -L/sw/lib conftest.c -liconv -lobjc gcc: unrecognized option `-no-precomp' cc1: warning: changing search order for system directory "/usr/include" cc1: warning: as it has already been specified as a non-system directory ld: Undefined symbols: _iconv gcc -o conftest -I/usr/lib/ruby/1.6/powerpc-darwin6.0 -g -Os -pipe -no-cpp-precomp -pipe -pipe -no-precomp -I/usr/include -I/sw/include -L/sw/lib conftest.c -lobjc gcc: unrecognized option `-no-precomp' cc1: warning: changing search order for system directory "/usr/include" cc1: warning: as it has already been specified as a non-system directory conftest.c: In function `t': conftest.c:3: too few arguments to function `rb_obj_freeze' gcc -o conftest -I/usr/lib/ruby/1.6/powerpc-darwin6.0 -g -Os -pipe -no-cpp-precomp -pipe -pipe -no-precomp -I/usr/include -I/sw/include -L/sw/lib conftest.c -lobjc gcc: unrecognized option `-no-precomp' cc1: warning: changing search order for system directory "/usr/include" cc1: warning: as it has already been specified as a non-system directory gcc -o conftest -I/usr/lib/ruby/1.6/powerpc-darwin6.0 -g -Os -pipe -no-cpp-precomp -pipe -pipe -no-precomp -I/usr/include -I/sw/include -L/sw/lib conftest.c -lobjc gcc: unrecognized option `-no-precomp' cc1: warning: changing search order for system directory "/usr/include" cc1: warning: as it has already been specified as a non-system directory ld: Undefined symbols: _rb_block_given_p gcc -o conftest -I/usr/lib/ruby/1.6/powerpc-darwin6.0 -g -Os -pipe -no-cpp-precomp -pipe -pipe -no-precomp -I/usr/include -I/sw/include -L/sw/lib conftest.c -lobjc gcc: unrecognized option `-no-precomp' cc1: warning: changing search order for system directory "/usr/include" cc1: warning: as it has already been specified as a non-system directory gcc -o conftest -I/usr/lib/ruby/1.6/powerpc-darwin6.0 -g -Os -pipe -no-cpp-precomp -pipe -pipe -no-precomp -I/usr/include -I/sw/include -L/sw/lib conftest.c -lobjc gcc: unrecognized option `-no-precomp' cc1: warning: changing search order for system directory "/usr/include" cc1: warning: as it has already been specified as a non-system directory ld: Undefined symbols: _rb_str_buf_new gcc -o conftest -I/usr/lib/ruby/1.6/powerpc-darwin6.0 -g -Os -pipe -no-cpp-precomp -pipe -pipe -no-precomp -I/usr/include -I/sw/include -L/sw/lib conftest.c -lobjc gcc: unrecognized option `-no-precomp' cc1: warning: changing search order for system directory "/usr/include" cc1: warning: as it has already been specified as a non-system directory conftest.c: In function `t': conftest.c:3: `rb_str_buf_new' undeclared (first use in this function) conftest.c:3: (Each undeclared identifier is reported only once conftest.c:3: for each function it appears in.) --4Ckj6UjgE2iN1+kY Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="iconv.h" /* Copyright (C) 1999-2001 Free Software Foundation, Inc. This file is part of the GNU LIBICONV Library. The GNU LIBICONV Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU LIBICONV Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU LIBICONV Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* When installed, this file is called "iconv.h". */ #ifndef _LIBICONV_H #define _LIBICONV_H #define _LIBICONV_VERSION 0x0107 /* version number: (major<<8) + minor */ extern int _libiconv_version; /* Likewise */ /* We would like to #include any system header file which could define iconv_t, 1. in order to eliminate the risk that the user gets compilation errors because some other system header file includes /usr/include/iconv.h which defines iconv_t or declares iconv after this file, 2. when compiling for LIBICONV_PLUG, we need the proper iconv_t type in order to produce binary compatible code. But gcc's #include_next is not portable. Thus, once libiconv's iconv.h has been installed in /usr/local/include, there is no way any more to include the original /usr/include/iconv.h. We simply have to get away without it. Ad 1. The risk that a system header file does #include "iconv.h" or #include_next "iconv.h" is small. They all do #include . Ad 2. The iconv_t type is a pointer type in all cases I have seen. (It has to be a scalar type because (iconv_t)(-1) is a possible return value from iconv_open().) */ /* Define iconv_t ourselves. */ #undef iconv_t #define iconv_t libiconv_t typedef void* iconv_t; /* Get size_t declaration. */ #include /* Get errno declaration and values. */ #include /* Some systems, like SunOS 4, don't have EILSEQ. On these systems, define EILSEQ ourselves, but don't define it as EINVAL, because iconv() callers want to distinguish EINVAL and EILSEQ. */ #ifndef EILSEQ #define EILSEQ ENOENT #endif #ifdef __cplusplus extern "C" { #endif /* Allocates descriptor for code conversion from encoding `fromcode' to encoding `tocode'. */ #ifndef LIBICONV_PLUG #define iconv_open libiconv_open #endif extern iconv_t iconv_open (const char* tocode, const char* fromcode); /* Converts, using conversion descriptor `cd', at most `*inbytesleft' bytes starting at `*inbuf', writing at most `*outbytesleft' bytes starting at `*outbuf'. Decrements `*inbytesleft' and increments `*inbuf' by the same amount. Decrements `*outbytesleft' and increments `*outbuf' by the same amount. */ #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); /* Frees resources allocated for conversion descriptor `cd'. */ #ifndef LIBICONV_PLUG #define iconv_close libiconv_close #endif extern int iconv_close (iconv_t cd); #ifndef LIBICONV_PLUG /* Nonstandard extensions. */ /* Control of attributes. */ #define iconvctl libiconvctl extern int iconvctl (iconv_t cd, int request, void* argument); /* Requests for iconvctl. */ #define ICONV_TRIVIALP 0 /* int *argument */ #define ICONV_GET_TRANSLITERATE 1 /* int *argument */ #define ICONV_SET_TRANSLITERATE 2 /* const int *argument */ #endif #ifdef __cplusplus } #endif #endif /* _LIBICONV_H */ --4Ckj6UjgE2iN1+kY--