# Libiconv: iconv\_open is missing?

**URL:** https://rubytalk.org/t/libiconv-iconv-open-is-missing/32107
**Category:** ruby-talk
**Created:** [19 October 2006 23:13 UTC](https://rubytalk.org/t/libiconv-iconv-open-is-missing/32107 "2006-10-19T23:13:46Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Matt\_Wynne2](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@Matt\_Wynne2](https://rubytalk.org/u/Matt_Wynne2)
#### Post date: [19 October 2006 23:13 UTC](https://rubytalk.org/t/libiconv-iconv-open-is-missing/32107/1 "2006-10-19T23:13:46Z")

</div>

I'm relatively new to unix/osx/ruby so please be as gentle as you  
can...!

I'm running Mac OSX Tiger.

When I run ruby extconf.rb to try and install net-geoip-0.06 I keep  
getting the error 'extconf failure: need libiconv.'

I'm pretty stuck with this. I have un-installed ruby and libiconv then  
reinstalled, all using DarwinPorts. If I run port installed i see the  
following:  
Vigor10:~/Documents/Downloads/net-geoip-0.06 matt$ port installed  
The following ports are currently installed:  
&nbsp;&nbsp;libiconv @1.11\_0+darwin\_8 (active)  
&nbsp;&nbsp;openssl @0.9.8b\_0+darwin\_8 (active)  
&nbsp;&nbsp;readline @5.1.004\_0 (active)  
&nbsp;&nbsp;ruby @1.8.5\_0 (active)  
&nbsp;&nbsp;sqlite2 @2.8.17\_0+darwin\_8 (active)  
&nbsp;&nbsp;sqlite3 @3.3.7\_0+darwin\_8 (active)  
&nbsp;&nbsp;swig @1.3.29\_0+darwin\_8 (active)  
&nbsp;&nbsp;zlib @1.2.3\_0 (active)

So that looks OK, right?

In irb, if I require('mkmf') first, I can call  
have\_library('iconv','libiconv') and return true, but the line that  
fails in extconf.rb is looking for a function 'iconv\_open', and indeed  
if i call find\_library('iconv','iconv\_open') in that same irb session, I  
get back false.

I saw another discussion on here[1] about the lib-xml component that  
also requires this iconv\_open function, and someone who seemed to have  
it missing, though I couldn't see a resolution on that thread (at least  
not one that I understood!)

Any help immensely appreciated, this is my brick wall right now.

cheers,  
Matt

[1][http://www.ruby-forum.com/topic/55709#39835](http://www.ruby-forum.com/topic/55709#39835)

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

### Author: ![Bill\_Kelly](https://avatars.discourse-cdn.com/v4/letter/b/cc9497/32.png) [@Bill\_Kelly](https://rubytalk.org/u/Bill_Kelly)
#### Post date: [19 October 2006 23:29 UTC](https://rubytalk.org/t/libiconv-iconv-open-is-missing/32107/2 "2006-10-19T23:29:46Z")

</div>

> In irb, if I require('mkmf') first, I can call have\_library('iconv','libiconv') and return true, but the line that fails in extconf.rb is looking for a function 'iconv\_open', and indeed if i call find\_library('iconv','iconv\_open') in that same irb session, I get back false.

Sorry, I don't know the answer, but - have you tried just commenting  
out that line in the extconf.rb, and seeing if it might build anyway?

(The thinking was, if you're lucky, if just might build anyway; otherwise  
it may fail later in the build, possibly giving additional clues about why  
it won't build...)

Regards,

Bill

> **···**
>
> From: "Matt Wynne" \<mattwynne@fastmail.fm\>

---

<div class="post-metadata">

### Author: ![Nobuyoshi\_Nakada1](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@Nobuyoshi\_Nakada1](https://rubytalk.org/u/Nobuyoshi_Nakada1)
#### Post date: [20 October 2006 00:58 UTC](https://rubytalk.org/t/libiconv-iconv-open-is-missing/32107/3 "2006-10-20T00:58:06Z")

</div>

Hi,

At Fri, 20 Oct 2006 08:13:46 +0900,  
Matt Wynne wrote in [ruby-talk:220713]:

> In irb, if I require('mkmf') first, I can call  
> have\_library('iconv','libiconv') and return true, but the line that

have\_library('iconv', 'iconv') fails, right?

> fails in extconf.rb is looking for a function 'iconv\_open', and indeed  
> if i call find\_library('iconv','iconv\_open') in that same irb session, I  
> get back false.

Then try  
&nbsp;&nbsp;find\_library('iconv','libiconv')  
or  
&nbsp;&nbsp;find\_library('iconv','libiconv\_open')

find\_library should take headers parameter as well as have\_library,  
but it'd be too late.

> **···**
>
> --  
> Nobu Nakada

---

<div class="post-metadata">

### Author: ![Matt\_Wynne2](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@Matt\_Wynne2](https://rubytalk.org/u/Matt_Wynne2)
#### Post date: [20 October 2006 06:34 UTC](https://rubytalk.org/t/libiconv-iconv-open-is-missing/32107/4 "2006-10-20T06:34:51Z")

</div>

thanks Nobuyoshi,

> Then try  
> &nbsp;&nbsp;find\_library('iconv','libiconv')  
> or  
> &nbsp;&nbsp;find\_library('iconv','libiconv\_open')

yes, both of those work.

Does this mean the extconf.rb file for net-geoip-0.06[1] is incorrect  
then? If I hack it to change the 'iconv\_open' in that file to  
'libiconv\_open' instead, will the program still build ok?

> find\_library should take headers parameter as well as have\_library,  
> but it'd be too late.

I'm sorry I don't understand what you've said here - are you saying it  
would be nice to change find\_library to have this extra functionality?

cheers,  
Matt

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

### Author: ![Matt\_Wynne2](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@Matt\_Wynne2](https://rubytalk.org/u/Matt_Wynne2)
#### Post date: [20 October 2006 06:58 UTC](https://rubytalk.org/t/libiconv-iconv-open-is-missing/32107/5 "2006-10-20T06:58:53Z")

</div>

> Sorry, I don't know the answer, but - have you tried just commenting  
> out that line in the extconf.rb, and seeing if it might build anyway?
> 
> (The thinking was, if you're lucky, if just might build anyway;  
> otherwise  
> it may fail later in the build, possibly giving additional clues about  
> why  
> it won't build...)

Hey Bill, thanks, I kindof did that by taking Nobuyoshi's suggestion and  
hacking the extconf.rb file, which now runs. The make fails though, like  
this:

Vigor10:~/Documents/Downloads/net-geoip-0.06 matt$ make  
gcc -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin8.8.1 -I.  
-DRUBY\_EXTCONF\_H=\"extconf.h\" -O -pipe -I/opt/local/include -fno-common  
-g -Wall-O -pipe -I/opt/local/include -fno-common -pipe -fno-common  
-I/opt/local/include -c geoip.c  
cc1: error: unrecognized command line option "-Wall-O"  
make: \*\*\* [geoip.o] Error 1

bummer. I don't expect anyone here on the ruby forums to help me with  
this, the link to ruby is rather tenuous now! I'm guessing maybe MaxMind  
haven't tried building this on OSX. I've emailed MaxMind support so I'll  
see what they say.

Any tips on where else I might be able to ask for help with this gcc  
issue?

cheers,  
Matt

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

### Author: ![Bill\_Kelly](https://avatars.discourse-cdn.com/v4/letter/b/cc9497/32.png) [@Bill\_Kelly](https://rubytalk.org/u/Bill_Kelly)
#### Post date: [20 October 2006 07:28 UTC](https://rubytalk.org/t/libiconv-iconv-open-is-missing/32107/6 "2006-10-20T07:28:09Z")

</div>

> Hey Bill, thanks, I kindof did that by taking Nobuyoshi's suggestion and hacking the extconf.rb file, which now runs. The make fails though, like this:
> 
> Vigor10:~/Documents/Downloads/net-geoip-0.06 matt$ make  
> gcc -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin8.8.1 -I. -DRUBY\_EXTCONF\_H=\"extconf.h\" -O -pipe -I/opt/local/include -fno-common -g -Wall-O -pipe -I/opt/local/include -fno-common -pipe -fno-common -I/opt/local/include -c geoip.c  
> cc1: error: unrecognized command line option "-Wall-O"  
> make: \*\*\* [geoip.o] Error 1

It looks like part of your compiler flags string was appended to itself, for  
some reason. Or sort of, anyway:

See how "-O -pipe -I/opt/local/include -fno-common" appears twice?  
But it was appended the second time without a space, so that the "-O"  
is touching the "-Wall".

At the very least, you'd want a space between the "-Wall" and the "-O",  
to prevent them from touching and combining to form an unrecognized  
option.

Hard to guess from here how that compiler command line string is being  
generated... it contains a fair amount of duplication. But anyway, the  
immediate problem is that the "-O" is touching the "-Wall", instead of  
being separated by a space.

HTH,

Bill

> **···**
>
> From: "Matt Wynne" \<mattwynne@fastmail.fm\>

---

<div class="post-metadata">

### Author: ![Matt\_Wynne2](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@Matt\_Wynne2](https://rubytalk.org/u/Matt_Wynne2)
#### Post date: [20 October 2006 19:29 UTC](https://rubytalk.org/t/libiconv-iconv-open-is-missing/32107/7 "2006-10-20T19:29:57Z")

</div>

> See how "-O -pipe -I/opt/local/include -fno-common" appears twice?  
> But it was appended the second time without a space, so that the "-O"  
> is touching the "-Wall".
> 
> At the very least, you'd want a space between the "-Wall" and the "-O",  
> to prevent them from touching and combining to form an unrecognized  
> option.

Very sharp Bill, I should have spotted that myself. It turns out I don't  
need this component for my project after all, so I'm just dropping the  
problem. Thanks again for your friendly assistance though guys!

cheers,  
Matt

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
