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

> 
> On 25 Mar 2011, at 18:44, Ryan Davis wrote:
> 
>> 
>> 
>> On Mar 25, 2011, at 8:19, Iain Barnett <iainspeed / gmail.com> wrote:
>> 
>>> conftest.c: In function ┴Ň
>>> conftest.c:7: error: too few arguments to function ┴═ibiconv_open> checked program was:
>>> /* begin */
>>> 1: #include "ruby.h"
>>> 2: 
>>> 3: #include </Library/Frameworks/Libiconv.framework/Versions/1.13.1/include/iconv.h>
>>> 4: 
>>> 5: /*top*/
>>> 6: int main() {return 0;}
>>> 7: int t() { iconv_open(); return 0; }
>>> /* end */
>> 
>> 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.
> 
> 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.
> 
> 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
> 
> "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/libxml2 -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: 
> 3: /*top*/
> 4: int main() { return 0; }
> 5: int t() { void ((*volatile p)()); p = (void ((*)()))iconv_open; return 0; }
> /* end */
> 
> "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/libxml2 -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: 
> 3: /*top*/
> 4: int main() { return 0; }
> 5: int t() { iconv_open(); return 0; }
> /* end */
> 
> --------------------
> 
> have_library: checking for iconv_open() in -liconv... -------------------- yes
> 
> "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/libxml2 -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: 
> 3: /*top*/
> 4: int main() { return 0; }
> 5: int t() { void ((*volatile p)()); p = (void ((*)()))iconv_open; return 0; }
> /* end */
> 
>