On Mar 25, 2011, at 14:11 , Iain Barnett wrote:

>=20
> On 25 Mar 2011, at 18:44, Ryan Davis wrote:
>=20
>>=20
>>=20
>> On Mar 25, 2011, at 8:19, Iain Barnett <iainspeed / gmail.com> wrote:
>>=20
>>> conftest.c: In function =91t=92:
>>> conftest.c:7: error: too few arguments to function =91libiconv_open=92=

>>> checked program was:
>>> /* begin */
>>> 1: #include "ruby.h"
>>> 2:=20
>>> 3: #include =
</Library/Frameworks/Libiconv.framework/Versions/1.13.1/include/iconv.h>
>>> 4:=20
>>> 5: /*top*/
>>> 6: int main() {return 0;}
>>> 7: int t() { iconv_open(); return 0; }
>>> /* end */
>>=20
>> The error is here and is pretty clear whether it were C or ruby. It =
failed because it wasn't called with the right number of args.
>=20
> It's one thing to be able to read it, it's another thing to =
understand, which I why I said I didn't really understand what I was =
looking at. Since I don't use C and this is the first time I've used the =
mkmf library I was hoping for a hint at *why* this came out the way it =
did.

My point is that f() when it should be f(arg1, ...) is understandable in =
any language.

> I was calling the arguments the way the nokogiri gem does in order to =
try and fix a problem I'm having with it.
>=20
> In the meantime I've found that using `find_library` brought back more =
positive results.

Yeah. Looking at nokogiri is a good idea:

> asplode "libiconv" unless have_func('iconv_open', 'iconv.h') or =
have_library('iconv', 'iconv_open', 'iconv.h')

which produces:

> have_func: checking for iconv_open() in iconv.h... =
-------------------- no
>=20
> "gcc -o conftest -I. =
-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/=
universal-darwin10.0 -I. -I-I-I/opt/local/include =
-I-I-I/usr/local/include =
-I-I-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/include =
-I-I-I/usr/include -I-I-I/usr/include/libxml2 =
-I/opt/local/include/libxml2 -I/usr/local/include/libxml2 =
-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/include/libxm=
l2 -I-I/opt/local/include -I-I/usr/local/include =
-I-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/include =
-I-I/usr/include -I-I/usr/include/libxml2 -I/opt/local/include =
-I/usr/local/include =
-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/include =
-I/usr/include -I/usr/include/libxml2  -D_XOPEN_SOURCE =
-D_DARWIN_C_SOURCE    -g -Os -pipe -fno-common -DENABLE_DTRACE  =
-fno-common  -pipe -fno-common    -g -DXP_UNIX -O3 -Wall -Wcast-qual =
-Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c  -L. =
-L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib =
-L/opt/local/lib -L/usr/local/lib =
-L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib =
-L/usr/lib -L.       -lruby  -lpthread -ldl   "
> ld: warning: directory '/opt/local/lib' following -L not found
> Undefined symbols:
>   "_iconv_open", referenced from:
>       _t in ccFFqxiP.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
> checked program was:
> /* begin */
> 1: #include <iconv.h>
> 2:=20
> 3: /*top*/
> 4: int main() { return 0; }
> 5: int t() { void ((*volatile p)()); p =3D (void ((*)()))iconv_open; =
return 0; }
> /* end */
>=20
> "gcc -o conftest -I. =
-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/=
universal-darwin10.0 -I. -I-I-I/opt/local/include =
-I-I-I/usr/local/include =
-I-I-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/include =
-I-I-I/usr/include -I-I-I/usr/include/libxml2 =
-I/opt/local/include/libxml2 -I/usr/local/include/libxml2 =
-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/include/libxm=
l2 -I-I/opt/local/include -I-I/usr/local/include =
-I-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/include =
-I-I/usr/include -I-I/usr/include/libxml2 -I/opt/local/include =
-I/usr/local/include =
-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/include =
-I/usr/include -I/usr/include/libxml2  -D_XOPEN_SOURCE =
-D_DARWIN_C_SOURCE    -g -Os -pipe -fno-common -DENABLE_DTRACE  =
-fno-common  -pipe -fno-common    -g -DXP_UNIX -O3 -Wall -Wcast-qual =
-Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c  -L. =
-L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib =
-L/opt/local/lib -L/usr/local/lib =
-L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib =
-L/usr/lib -L.       -lruby  -lpthread -ldl   "
> conftest.c: In function 't':
> conftest.c:5: error: too few arguments to function 'iconv_open'
> checked program was:
> /* begin */
> 1: #include <iconv.h>
> 2:=20
> 3: /*top*/
> 4: int main() { return 0; }
> 5: int t() { iconv_open(); return 0; }
> /* end */
>=20
> --------------------
>=20
> have_library: checking for iconv_open() in -liconv... =
-------------------- yes
>=20
> "gcc -o conftest -I. =
-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/=
universal-darwin10.0 -I. -I-I-I/opt/local/include =
-I-I-I/usr/local/include =
-I-I-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/include =
-I-I-I/usr/include -I-I-I/usr/include/libxml2 =
-I/opt/local/include/libxml2 -I/usr/local/include/libxml2 =
-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/include/libxm=
l2 -I-I/opt/local/include -I-I/usr/local/include =
-I-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/include =
-I-I/usr/include -I-I/usr/include/libxml2 -I/opt/local/include =
-I/usr/local/include =
-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/include =
-I/usr/include -I/usr/include/libxml2  -D_XOPEN_SOURCE =
-D_DARWIN_C_SOURCE    -g -Os -pipe -fno-common -DENABLE_DTRACE  =
-fno-common  -pipe -fno-common    -g -DXP_UNIX -O3 -Wall -Wcast-qual =
-Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c  -L. =
-L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib =
-L/opt/local/lib -L/usr/local/lib =
-L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib =
-L/usr/lib -L.       -lruby -liconv  -lpthread -ldl   "
> ld: warning: directory '/opt/local/lib' following -L not found
> checked program was:
> /* begin */
> 1: #include <iconv.h>
> 2:=20
> 3: /*top*/
> 4: int main() { return 0; }
> 5: int t() { void ((*volatile p)()); p =3D (void ((*)()))iconv_open; =
return 0; }
> /* end */
>=20
>=20