Proper way to get base <iconv.h> with autoconf?

Marcin Cieslak saper at
Sun Jul 5 21:11:59 UTC 2015

[X-posted, replies set to ports at]


I have managed to upstream few things needed
to make mono work on FreeBSD without local patches.

Now I am stuck with the iconv detection code.

Mono (or it's dumbled-down glib called eglib) need
libiconv for two things - charset conversion:

and getting default charset information

The latter can be solved by using "nl_langinfo (CODESET);"
and avoiding the need to link

Mono uses "standard" iconv.m4 autoconf test, version 11

which is developed in the gettext and gnulib (The GNU portability

Whenever -I/usr/local/include is added to CPPFLAGS for
some reason (some other library, or jest using /usr/local as
default prefix) the configure script fails to use base header
and libc support and needs using GNU iconv as a dependency;
because this simple test fails:

configure:13910: checking for iconv
configure:13934: cc -o conftest -g -O2 -g -D_GNU_SOURCE -I/usr/local/include  conftest.c  >&5
/tmp/conftest-ee6d62.o: In function `main':
/home/saper/sw/mono/eglib/conftest.c:42: undefined reference to `libiconv_open'
/home/saper/sw/mono/eglib/conftest.c:43: undefined reference to `libiconv'
/home/saper/sw/mono/eglib/conftest.c:44: undefined reference to `libiconv_close'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
configure:13934: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "eglib"
| #define PACKAGE_TARNAME "eglib"
| #define PACKAGE_VERSION "0.3"
| #define PACKAGE_STRING "eglib 0.3"


| /* end confdefs.h.  */
| #include <stdlib.h>
| #include <iconv.h>
| int
| main ()
| {
| iconv_t cd = iconv_open("","");
|            iconv(cd,NULL,NULL,NULL,NULL);
|            iconv_close(cd);
|   ;
|   return 0;
| }
configure:13958: cc -o conftest -g -O2 -g -D_GNU_SOURCE -I/usr/local/include  conftest.c  /usr/local/lib/ -Wl,-rpath -Wl,/usr/local/lib >&5
configure:13958: $? = 0
configure:13968: result: yes

The <iconv.h> test fails because /usr/local/include/iconv.h
redefines iconv_open (and friends) to libiconv_open 

Any ideas how to fix/improve the iconv.m4 detection code
- to use the FreeBSD's base <iconv.h> and not require a library?


More information about the freebsd-ports mailing list