>Synopsis: libarchive's libarchive.pc lacks -liconv >Category: ports >Environment: System : OpenBSD 6.4 Details : OpenBSD 6.4 (GENERIC.MP) #3: Thu Dec 20 19:19:32 CET 2018 r...@syspatch-64-amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
Architecture: OpenBSD.amd64 Machine : amd64 >Description: When compiling a program and linking statically against libarchive, using pkg-config(1) will not work because -liconv is not included, the linker giving the following output: $ cc ar.c -o ar -static $(pkg-config --cflags --libs --static libarchive) /usr/local/lib/libarchive.a(archive_acl.o): In function `archive_acl_to_text_w': archive_acl.c:(.text+0x8f1): warning: wcscpy() is almost always misused, please use wcslcpy() /usr/local/lib/libarchive.a(archive_acl.o): In function `archive_acl_to_text_l': archive_acl.c:(.text+0x1a12): warning: strcpy() is almost always misused, please use strlcpy() /usr/local/lib/libarchive.a(archive_check_magic.o): In function `__archive_check_magic': archive_check_magic.c:(.text+0x1d4): warning: strcat() is almost always misused, please use strlcat() /usr/local/lib/libarchive.a(archive_string.o): In function `archive_string_conversion_to_charset': archive_string.c:(.text+0xbd7): undefined reference to `locale_charset' archive_string.c:(.text+0xbfc): undefined reference to `locale_charset' /usr/local/lib/libarchive.a(archive_string.o): In function `get_sconv_object': archive_string.c:(.text+0xe96): undefined reference to `libiconv_open' archive_string.c:(.text+0xee7): undefined reference to `libiconv_open' archive_string.c:(.text+0xf8c): undefined reference to `libiconv_close' archive_string.c:(.text+0xf9b): undefined reference to `libiconv_close' archive_string.c:(.text+0xfd9): undefined reference to `libiconv_open' /usr/local/lib/libarchive.a(archive_string.o): In function `archive_string_conversion_from_charset': archive_string.c:(.text+0x1027): undefined reference to `locale_charset' archive_string.c:(.text+0x104c): undefined reference to `locale_charset' /usr/local/lib/libarchive.a(archive_string.o): In function `archive_string_conversion_free': archive_string.c:(.text+0x1139): undefined reference to `libiconv_close' archive_string.c:(.text+0x1148): undefined reference to `libiconv_close' /usr/local/lib/libarchive.a(archive_string.o): In function `archive_mstring_get_utf8': archive_string.c:(.text+0x18e7): undefined reference to `locale_charset' archive_string.c:(.text+0x1912): undefined reference to `locale_charset' archive_string.c:(.text+0x19a6): undefined reference to `libiconv_close' archive_string.c:(.text+0x19b5): undefined reference to `libiconv_close' /usr/local/lib/libarchive.a(archive_string.o): In function `archive_mstring_update_utf8': archive_string.c:(.text+0x21af): undefined reference to `locale_charset' archive_string.c:(.text+0x21ea): undefined reference to `locale_charset' archive_string.c:(.text+0x228b): undefined reference to `libiconv_close' archive_string.c:(.text+0x229a): undefined reference to `libiconv_close' /usr/local/lib/libarchive.a(archive_string.o): In function `iconv_strncat_in_locale': archive_string.c:(.text+0x2a24): undefined reference to `libiconv' cc: error: linker command failed with exit code 1 (use -v to see invocation) >How-To-Repeat: First install libarchive with pkg_add, and create the simple C program below: $ doas pkg_add libarchive $ cat > ar.c #include <archive.h> int main() { struct archive *a; a = archive_read_new(); archive_read_free(a); return 0; } Then compile this code statically using pkg-config, to see the exact error: $ cc -static ar.c $(pkg-config --cflags --libs --static libarchive) /usr/local/lib/libarchive.a(archive_acl.o): In function `archive_acl_to_text_w': archive_acl.c:(.text+0x8f1): warning: wcscpy() is almost always misused, please use wcslcpy() /usr/local/lib/libarchive.a(archive_acl.o): In function `archive_acl_to_text_l': archive_acl.c:(.text+0x1a12): warning: strcpy() is almost always misused, please use strlcpy() /usr/local/lib/libarchive.a(archive_check_magic.o): In function `__archive_check_magic': archive_check_magic.c:(.text+0x1d4): warning: strcat() is almost always misused, please use strlcat() /usr/local/lib/libarchive.a(archive_string.o): In function `archive_string_conversion_to_charset': archive_string.c:(.text+0xbd7): undefined reference to `locale_charset' archive_string.c:(.text+0xbfc): undefined reference to `locale_charset' /usr/local/lib/libarchive.a(archive_string.o): In function `get_sconv_object': archive_string.c:(.text+0xe96): undefined reference to `libiconv_open' archive_string.c:(.text+0xee7): undefined reference to `libiconv_open' archive_string.c:(.text+0xf8c): undefined reference to `libiconv_close' archive_string.c:(.text+0xf9b): undefined reference to `libiconv_close' archive_string.c:(.text+0xfd9): undefined reference to `libiconv_open' /usr/local/lib/libarchive.a(archive_string.o): In function `archive_string_conversion_from_charset': archive_string.c:(.text+0x1027): undefined reference to `locale_charset' archive_string.c:(.text+0x104c): undefined reference to `locale_charset' /usr/local/lib/libarchive.a(archive_string.o): In function `archive_string_conversion_free': archive_string.c:(.text+0x1139): undefined reference to `libiconv_close' archive_string.c:(.text+0x1148): undefined reference to `libiconv_close' /usr/local/lib/libarchive.a(archive_string.o): In function `archive_mstring_get_utf8': archive_string.c:(.text+0x18e7): undefined reference to `locale_charset' archive_string.c:(.text+0x1912): undefined reference to `locale_charset' archive_string.c:(.text+0x19a6): undefined reference to `libiconv_close' archive_string.c:(.text+0x19b5): undefined reference to `libiconv_close' /usr/local/lib/libarchive.a(archive_string.o): In function `archive_mstring_update_utf8': archive_string.c:(.text+0x21af): undefined reference to `locale_charset' archive_string.c:(.text+0x21ea): undefined reference to `locale_charset' archive_string.c:(.text+0x228b): undefined reference to `libiconv_close' archive_string.c:(.text+0x229a): undefined reference to `libiconv_close' /usr/local/lib/libarchive.a(archive_string.o): In function `iconv_strncat_in_locale': archive_string.c:(.text+0x2a24): undefined reference to `libiconv' cc: error: linker command failed with exit code 1 (use -v to see invocation) >Fix: Adding -liconv to the compilation flags fixes the issue: $ cc -static ar.c $(pkg-config --cflags --libs --static libarchive) -liconv /usr/local/lib/libarchive.a(archive_acl.o): In function `archive_acl_to_text_w': archive_acl.c:(.text+0x8f1): warning: wcscpy() is almost always misused, please use wcslcpy() /usr/local/lib/libarchive.a(archive_acl.o): In function `archive_acl_to_text_l': archive_acl.c:(.text+0x1a12): warning: strcpy() is almost always misused, please use strlcpy() /usr/local/lib/libarchive.a(archive_check_magic.o): In function `__archive_check_magic': archive_check_magic.c:(.text+0x1d4): warning: strcat() is almost always misused, please use strlcat() However, -liconv is missing from Libs.private in /usr/local/lib/pkgconfig/libarchive.pc. Adding it there fixes the issue dmesg: OpenBSD 6.4 (GENERIC.MP) #3: Thu Dec 20 19:19:32 CET 2018 r...@syspatch-64-amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP real mem = 8558833664 (8162MB) avail mem = 8290172928 (7906MB) mpath0 at root scsibus0 at mpath0: 256 targets mainbus0 at root bios0 at mainbus0: SMBIOS rev. 2.8 @ 0x7f4cd000 (39 entries) bios0: vendor American Megatrends Inc. version "1.0b" date 08/11/2014 bios0: Supermicro A1SA2-2750F acpi0 at bios0: rev 2 acpi0: sleep states S0 S5 acpi0: tables DSDT FACP FPDT SPMI MCFG WDAT UEFI APIC BDAT HPET SSDT HEST BERT ERST EINJ acpi0: wakeup devices PEX1(S0) PEX2(S0) PEX3(S0) PEX4(S0) EHC1(S0) acpitimer0 at acpi0: 3579545 Hz, 24 bits acpimcfg0 at acpi0 acpimcfg0: addr 0xe0000000, bus 0-255 acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat cpu0 at mainbus0: apid 0 (boot processor) cpu0: Intel(R) Atom(TM) CPU C2750 @ 2.40GHz, 2400.45 MHz, 06-4d-08 cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,AES,RDRAND,NXE,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,SMEP,ERMS,SENSOR,ARAT,MELTDOWN cpu0: 1MB 64b/line 16-way L2 cache cpu0: smt 0, core 0, package 0 mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges cpu0: apic clock running at 100MHz cpu0: mwait min=64, max=64, C-substates=0.2.0.0.0.0.3, IBE cpu1 at mainbus0: apid 2 (application processor) cpu1: Intel(R) Atom(TM) CPU C2750 @ 2.40GHz, 2400.01 MHz, 06-4d-08 cpu1: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,AES,RDRAND,NXE,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,SMEP,ERMS,SENSOR,ARAT,MELTDOWN cpu1: 1MB 64b/line 16-way L2 cache cpu1: smt 0, core 1, package 0 cpu2 at mainbus0: apid 4 (application processor) cpu2: Intel(R) Atom(TM) CPU C2750 @ 2.40GHz, 2400.01 MHz, 06-4d-08 cpu2: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,AES,RDRAND,NXE,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,SMEP,ERMS,SENSOR,ARAT,MELTDOWN cpu2: 1MB 64b/line 16-way L2 cache cpu2: smt 0, core 2, package 0 cpu3 at mainbus0: apid 6 (application processor) cpu3: Intel(R) Atom(TM) CPU C2750 @ 2.40GHz, 2400.01 MHz, 06-4d-08 cpu3: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,AES,RDRAND,NXE,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,SMEP,ERMS,SENSOR,ARAT,MELTDOWN cpu3: 1MB 64b/line 16-way L2 cache cpu3: smt 0, core 3, package 0 cpu4 at mainbus0: apid 8 (application processor) cpu4: Intel(R) Atom(TM) CPU C2750 @ 2.40GHz, 2400.01 MHz, 06-4d-08 cpu4: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,AES,RDRAND,NXE,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,SMEP,ERMS,SENSOR,ARAT,MELTDOWN cpu4: 1MB 64b/line 16-way L2 cache cpu4: smt 0, core 4, package 0 cpu5 at mainbus0: apid 10 (application processor) cpu5: Intel(R) Atom(TM) CPU C2750 @ 2.40GHz, 2400.01 MHz, 06-4d-08 cpu5: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,AES,RDRAND,NXE,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,SMEP,ERMS,SENSOR,ARAT,MELTDOWN cpu5: 1MB 64b/line 16-way L2 cache cpu5: smt 0, core 5, package 0 cpu6 at mainbus0: apid 12 (application processor) cpu6: Intel(R) Atom(TM) CPU C2750 @ 2.40GHz, 2400.01 MHz, 06-4d-08 cpu6: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,AES,RDRAND,NXE,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,SMEP,ERMS,SENSOR,ARAT,MELTDOWN cpu6: 1MB 64b/line 16-way L2 cache cpu6: smt 0, core 6, package 0 cpu7 at mainbus0: apid 14 (application processor) cpu7: Intel(R) Atom(TM) CPU C2750 @ 2.40GHz, 2400.01 MHz, 06-4d-08 cpu7: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,AES,RDRAND,NXE,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,SMEP,ERMS,SENSOR,ARAT,MELTDOWN cpu7: 1MB 64b/line 16-way L2 cache cpu7: smt 0, core 7, package 0 ioapic0 at mainbus0: apid 2 pa 0xfec00000, version 20, 24 pins acpihpet0 at acpi0: 14318179 Hz acpiprt0 at acpi0: bus 0 (PCI0) acpiprt1 at acpi0: bus 1 (PEX1) acpiprt2 at acpi0: bus 2 (BR18) acpiprt3 at acpi0: bus 3 (PEX2) acpiprt4 at acpi0: bus -1 (BR1A) acpiprt5 at acpi0: bus 4 (PEX3) acpiprt6 at acpi0: bus -1 (PEX4) acpicpu0 at acpi0: C2(350@41 mwait.3@0x51), C1(1000@1 mwait.1), PSS acpicpu1 at acpi0: C2(350@41 mwait.3@0x51), C1(1000@1 mwait.1), PSS acpicpu2 at acpi0: C2(350@41 mwait.3@0x51), C1(1000@1 mwait.1), PSS acpicpu3 at acpi0: C2(350@41 mwait.3@0x51), C1(1000@1 mwait.1), PSS acpicpu4 at acpi0: C2(350@41 mwait.3@0x51), C1(1000@1 mwait.1), PSS acpicpu5 at acpi0: C2(350@41 mwait.3@0x51), C1(1000@1 mwait.1), PSS acpicpu6 at acpi0: C2(350@41 mwait.3@0x51), C1(1000@1 mwait.1), PSS acpicpu7 at acpi0: C2(350@41 mwait.3@0x51), C1(1000@1 mwait.1), PSS "PNP0003" at acpi0 not configured acpicmos0 at acpi0 "PNP0C33" at acpi0 not configured ipmi at mainbus0 not configured cpu0: Enhanced SpeedStep 2400 MHz: speeds: 2401, 2400, 2300, 2200, 2100, 2000, 1900, 1800, 1700, 1600, 1500, 1400, 1300, 1200 MHz pci0 at mainbus0 bus 0 pchb0 at pci0 dev 0 function 0 vendor "Intel", unknown product 0x1f01 rev 0x02 ppb0 at pci0 dev 1 function 0 "Intel Atom C2000 PCIE" rev 0x02: msi pci1 at ppb0 bus 1 ppb1 at pci1 dev 0 function 0 "ASPEED Technology AST1150 PCI" rev 0x03 pci2 at ppb1 bus 2 vga1 at pci2 dev 0 function 0 "ASPEED Technology AST2000" rev 0x30 wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation) wsdisplay0: screen 1-5 added (80x25, vt100 emulation) ppb2 at pci0 dev 2 function 0 "Intel Atom C2000 PCIE" rev 0x02: msi pci3 at ppb2 bus 3 ppb3 at pci0 dev 3 function 0 "Intel Atom C2000 PCIE" rev 0x02: msi pci4 at ppb3 bus 4 pchb1 at pci0 dev 14 function 0 "Intel Atom C2000 RAS" rev 0x02 "Intel Atom C2000 RCEC" rev 0x02 at pci0 dev 15 function 0 not configured "Intel Atom C2000 SMBus" rev 0x02 at pci0 dev 19 function 0 not configured em0 at pci0 dev 20 function 0 "Intel I354 SGMII" rev 0x03: msi, address 0c:c4:7a:08:3a:e8 em1 at pci0 dev 20 function 1 "Intel I354 SGMII" rev 0x03: msi, address 0c:c4:7a:08:3a:e9 ehci0 at pci0 dev 22 function 0 "Intel Atom C2000 USB" rev 0x02: apic 2 int 23 usb0 at ehci0: USB revision 2.0 uhub0 at usb0 configuration 1 interface 0 "Intel EHCI root hub" rev 2.00/1.00 addr 1 ahci0 at pci0 dev 24 function 0 "Intel Atom C2000 AHCI" rev 0x02: msi, AHCI 1.3 ahci0: port 0: 6.0Gb/s scsibus1 at ahci0: 32 targets sd0 at scsibus1 targ 0 lun 0: <ATA, HGST HTS721010A9, JB0O> SCSI3 0/direct fixed naa.5000cca6acd058a8 sd0: 953869MB, 512 bytes/sector, 1953525168 sectors pcib0 at pci0 dev 31 function 0 "Intel Atom C2000 PCU" rev 0x02 ichiic0 at pci0 dev 31 function 3 "Intel Atom C2000 PCU SMBus" rev 0x02: apic 2 int 18 iic0 at ichiic0 sdtemp0 at iic0 addr 0x18: stts2002 sdtemp1 at iic0 addr 0x1a: stts2002 iic0: addr 0x2e 00=3f words 00=3f3f 01=0000 02=0000 03=0000 04=0000 05=0000 06=0000 07=0000 spdmem0 at iic0 addr 0x50: 4GB DDR3 SDRAM ECC PC3-12800 with thermal sensor spdmem1 at iic0 addr 0x52: 4GB DDR3 SDRAM ECC PC3-12800 with thermal sensor isa0 at pcib0 isadma0 at isa0 pckbc0 at isa0 port 0x60/5 irq 1 irq 12 pckbd0 at pckbc0 (kbd slot) wskbd0 at pckbd0: console keyboard, using wsdisplay0 pms0 at pckbc0 (aux slot) wsmouse0 at pms0 mux 0 pcppi0 at isa0 port 0x61 spkr0 at pcppi0 vmm0 at mainbus0: VMX/EPT (using slow L1TF mitigation) uhub1 at uhub0 port 1 configuration 1 interface 0 "Intel product 0x07db" rev 2.00/0.02 addr 2 uhub2 at uhub1 port 3 configuration 1 interface 0 "ATEN International product 0x7000" rev 2.00/0.00 addr 3 uhidev0 at uhub2 port 1 configuration 1 interface 0 "ATEN International product 0x2419" rev 1.10/1.00 addr 4 uhidev0: iclass 3/1 ukbd0 at uhidev0: 8 variable keys, 6 key codes wskbd1 at ukbd0 mux 1 wskbd1: connecting to wsdisplay0 uhidev1 at uhub2 port 1 configuration 1 interface 1 "ATEN International product 0x2419" rev 1.10/1.00 addr 4 uhidev1: iclass 3/1 ums0 at uhidev1: 3 buttons, Z dir wsmouse1 at ums0 mux 0 vscsi0 at root scsibus2 at vscsi0: 256 targets softraid0 at root scsibus3 at softraid0: 256 targets root on sd0a (7d349f3a98fddd8e.a) swap on sd0b dump on sd0b usbdevs: Controller /dev/usb0: addr 01: 8086:0000 Intel, EHCI root hub high speed, self powered, config 1, rev 1.00 driver: uhub0 addr 02: 8087:07db Intel, product 0x07db high speed, self powered, config 1, rev 0.02 driver: uhub1 addr 03: 0557:7000 ATEN International, product 0x7000 high speed, self powered, config 1, rev 0.00 driver: uhub2 addr 04: 0557:2419 ATEN International, product 0x2419 low speed, power 160 mA, config 1, rev 1.00 driver: uhidev0 driver: uhidev1