From owner-freebsd-questions@freebsd.org Tue Jul 14 16:40:42 2015 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9CD979A1CC2 for ; Tue, 14 Jul 2015 16:40:42 +0000 (UTC) (envelope-from freebsd@pki2.com) Received: from btw.pki2.com (btw.pki2.com [IPv6:2001:470:a:6fd::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 60348CF8 for ; Tue, 14 Jul 2015 16:40:42 +0000 (UTC) (envelope-from freebsd@pki2.com) Received: from localhost (localhost [IPv6:::1]) by btw.pki2.com (8.14.9/8.14.9) with ESMTP id t6EGeTGw051871 for ; Tue, 14 Jul 2015 09:40:29 -0700 (PDT) (envelope-from freebsd@pki2.com) DMARC-Filter: OpenDMARC Filter v1.3.1 btw.pki2.com t6EGeTGw051871 Authentication-Results: btw.pki2.com; dmarc=none header.from=pki2.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=pki2.com; s=pki2; t=1436892029; bh=rJvt5+jDV4UM8ii3B7Ci/NIP4MhrrwqVGaO5FYAl9/s=; h=Subject:From:To:Date; z=Subject:=20What's=20the=20magic=20of=20linking=20against=20iconv= 20(clang/gcc5)?|From:=20Dennis=20Glatting=20|To: =20freebsd-questions@freebsd.org|Date:=20Tue,=2014=20Jul=202015=20 09:40:29=20-0700; b=aq0KVUi10aWmia7vflGV7ZCQ33KFHzjTXXadxVTqtbBbmFAqHHMFwEgLZkkPxGt0m 0SAog5kgAxYj8Th+ItBUAAxWmqPGHJIHMG/1YGmlPBKlM/siYm8TsVnrBnfleCbvha FyHtp/J3wgK+TTOx29EipTl11PGtCAJtkJsaoO2gpdLU3R7/8fx+dy79PqJmcdPILs 2Cp6RgLYBlQif65cjj6y45jU7j37ftAfxOW3gliNRdXHAQPeGXvFIJits/+KtacssA nIwqfw/aQN8ofExP0hcWZ9p6KH1e1xD2zPN9ZilC1vWfwLP7PTW+GhVlzpSu7WMyk8 C1PZxvMcGb6Pg== Message-ID: <1436892029.68808.8.camel@pki2.com> Subject: What's the magic of linking against iconv (clang/gcc5)? From: Dennis Glatting To: freebsd-questions@freebsd.org Date: Tue, 14 Jul 2015 09:40:29 -0700 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.11 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-SoftwareMunitions-MailScanner-Information: Dennis Glatting X-SoftwareMunitions-MailScanner-ID: t6EGeTGw051871 X-SoftwareMunitions-MailScanner: Found to be clean X-MailScanner-From: freebsd@pki2.com X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jul 2015 16:40:42 -0000 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 #include 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. (BTW, I'm compiling GNURadio 3.7.8git. There are two patches and everything compiles except where iconv is referenced.) root@Tasha# cc -v foo.c FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512 Target: x86_64-unknown-freebsd10.2 Thread model: posix Selected GCC installation: "/usr/bin/cc" -cc1 -triple x86_64-unknown-freebsd10.2 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name foo.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -v -resource-dir /usr/bin/../lib/clang/3.4.1 -fdebug-compilation-dir /lib -ferror-limit 19 -fmessage-length 80 -mstackrealign -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o /tmp/foo-2bbf11.o -x c foo.c clang -cc1 version 3.4.1 based upon LLVM 3.4.1 default target x86_64-unknown-freebsd10.2 ignoring nonexistent directory "/usr/bin/../lib/clang/3.4.1/include" #include "..." search starts here: #include <...> search starts here: /usr/include/clang/3.4.1 /usr/include End of search list. "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o a.out /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib /tmp/foo-2bbf11.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o root@Tasha# gcc5 -v foo.c -lc Using built-in specs. COLLECT_GCC=gcc5 COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/lto-wrapper Target: x86_64-portbld-freebsd10.2 Configured with: ./../gcc-5.1.0/configure --with-build-config=bootstrap-debug --disable-nls --enable-gnu-indirect-function --libdir=/usr/local/lib/gcc5 --libexecdir=/usr/local/libexec/gcc5 --program-suffix=5 --with-as=/usr/local/bin/as --with-gmp=/usr/local --with-gxx-include-dir=/usr/local/lib/gcc5/include/c++/ --with-ld=/usr/local/bin/ld --with-pkgversion='FreeBSD Ports Collection' --with-system-zlib --with-ecj-jar=/usr/local/share/java/ecj-4.5.jar --enable-languages=c,c++,objc,fortran,java --prefix=/usr/local --localstatedir=/var --mandir=/usr/local/man --infodir=/usr/local/info/gcc5 --build=x86_64-portbld-freebsd10.2 Thread model: posix gcc version 5.1.0 (FreeBSD Ports Collection) COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64' /usr/local/libexec/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/cc1 -quiet -v foo.c -quiet -dumpbase foo.c -mtune=generic -march=x86-64 -auxbase foo -version -o /tmp//ccIJPCLY.s GNU C11 (FreeBSD Ports Collection) version 5.1.0 (x86_64-portbld-freebsd10.2) compiled by GNU C version 5.1.0, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.3 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/usr/local/lib/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/../../../../../x86_64-portbld-freebsd10.2/include" #include "..." search starts here: #include <...> search starts here: /usr/local/lib/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/include /usr/local/include /usr/local/lib/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/include-fixed /usr/include End of search list. GNU C11 (FreeBSD Ports Collection) version 5.1.0 (x86_64-portbld-freebsd10.2) compiled by GNU C version 5.1.0, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.3 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: d704dda7d1acf1756f63bafb76e30605 COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64' /usr/local/bin/as -v -o /tmp//cc2Z6z3x.o /tmp//ccIJPCLY.s GNU assembler version 2.25 (x86_64-portbld-freebsd10.2) using BFD version (GNU Binutils) 2.25 COMPILER_PATH=/usr/local/libexec/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/:/usr/local/libexec/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/:/usr/local/libexec/gcc5/gcc/x86_64-portbld-freebsd10.2/:/usr/local/lib/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/:/usr/local/lib/gcc5/gcc/x86_64-portbld-freebsd10.2/:/usr/local/lib/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/../../../../../x86_64-portbld-freebsd10.2/bin/ LIBRARY_PATH=/usr/local/lib/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/:/usr/local/lib/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/../../../../../x86_64-portbld-freebsd10.2/lib/:/usr/local/lib/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64' /usr/local/libexec/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/collect2 -plugin /usr/local/libexec/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/liblto_plugin.so -plugin-opt=/usr/local/libexec/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/lto-wrapper -plugin-opt=-fresolution=/tmp//ccMod0QF.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -V -dynamic-linker /libexec/ld-elf.so.1 /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/crtbegin.o -L/usr/local/lib/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0 -L/usr/local/lib/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/../../../../../x86_64-portbld-freebsd10.2/lib -L/usr/local/lib/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/../../.. /tmp//cc2Z6z3x.o -lc -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/local/lib/gcc5/gcc/x86_64-portbld-freebsd10.2/5.1.0/crtend.o /usr/lib/crtn.o GNU ld (GNU Binutils) 2.25 Supported emulations: elf_x86_64_fbsd elf_i386_fbsd elf_x86_64 elf_i386 elf_l1om elf_l1om_fbsd elf_k1om elf_k1om_fbsd /tmp//cc2Z6z3x.o: In function `main': foo.c:(.text+0x18): undefined reference to `libiconv_close' collect2: error: ld returned 1 exit status