Date: Tue, 14 Jul 2015 16:52:35 -0700 From: Dennis Glatting <freebsd@pki2.com> To: Tijl Coosemans <tijl@FreeBSD.org> Cc: freebsd-questions@freebsd.org Subject: Re: What's the magic of linking against iconv (clang/gcc5)? Message-ID: <1436917955.52012.0.camel@pki2.com> In-Reply-To: <20150714200345.04354c5b@kalimero.tijl.coosemans.org> References: <1436892029.68808.8.camel@pki2.com> <20150714200345.04354c5b@kalimero.tijl.coosemans.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Thanks. I'll give it a shot. On Tue, 2015-07-14 at 20:03 +0200, Tijl Coosemans wrote: > On Tue, 14 Jul 2015 09:40:29 -0700 Dennis Glatting <freebsd@pki2.com> wrote: > > My system: > > > > root@Tasha# uname -a > > FreeBSD Tasha 10.2-BETA1 FreeBSD 10.2-BETA1 #0 r285434: Sun Jul 12 > > 16:57:18 PDT 2015 > > root@Tasha:/disk-2/obj/disk-1/src/sys/SMUNI-FreeBSD10-amd64 amd64 > > > > > > I have a very simple program: > > > > #include <iconv.h> > > #include <stdio.h> > > > > int > > main( void ) { > > > > iconv_t fd = 0; > > > > iconv_close( fd ); > > > > return 0; > > } > > > > > > If I compile with clang, I have no trouble: > > > > root@Tasha# cc foo.c > > root@Tasha# > > > > However, if I compiler with gcc5: > > > > root@Tasha# gcc5 foo.c > > /tmp//ccDHDghd.o: In function `main': > > foo.c:(.text+0x18): undefined reference to `libiconv_close' > > collect2: error: ld returned 1 exit status > > > > According to iconv(3), I should link against c yet I get the same error: > > > > root@Tasha# gcc5 foo.c -lc > > /tmp//ccsKwlf3.o: In function `main': > > foo.c:(.text+0x18): undefined reference to `libiconv_close' > > collect2: error: ld returned 1 exit status > > > > I'm confused why this doesn't work and have searched through the system > > libraries. (I have verbose output below). I /only/ have a problem with > > iconv. There is some difference between these compilers that I do not > > understand. > > > > Clue please. > > The lang/gcc* ports always compile with -I/usr/local/include, so they > end up including /usr/local/include/iconv.h which belongs to libiconv > while clang includes /usr/include/iconv.h. So with gcc you either > have to link with -liconv or compile with -DLIBICONV_PLUG which makes > /usr/local/include/iconv.h behave like /usr/include/iconv.h. > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1436917955.52012.0.camel>