Skip to content

Fails to Build: undefined reference to libintl_bind_textdomain_codeset'` #1

@systmkor

Description

@systmkor

Environment

  • Alpine Linux 3.2.0 RC2
  • musl-1.1.8 (libc)
  • gettext-0.19.4 (gnu)
  • go-1.4.2
  • gettext commit 98b7b91

Error

After running make or trying to just run go get github.com/lxc/lxd . The gettext errors are produced as shown below.

go build
# _/home/admin/src/port2port/lxc/gettext
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_bind_textdomain_codeset':
./gettext.go:64: undefined reference to `libintl_bind_textdomain_codeset'
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_bindtextdomain':
./gettext.go:78: undefined reference to `libintl_bindtextdomain'
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_dcgettext':
./gettext.go:94: undefined reference to `libintl_dcgettext'
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_dcngettext':
./gettext.go:112: undefined reference to `libintl_dcngettext'
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_dgettext':
./gettext.go:126: undefined reference to `libintl_dgettext'
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_dngettext':
./gettext.go:142: undefined reference to `libintl_dngettext'
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_gettext':
./gettext.go:164: undefined reference to `libintl_gettext'
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_ngettext':
./gettext.go:179: undefined reference to `libintl_ngettext'
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_textdomain':
./gettext.go:207: undefined reference to `libintl_textdomain'
collect2: error: ld returned 1 exit status

Fix

Tell cgo to link libintl by changing line 26 of gettext.go from /* to

// #cgo LDFLAGS: -lintl

and then insert /* into line 27 of the same file.

Go Test

go build
go test
¡Hola mundo!
Una manzana
3 manzanas
Buenos días
¡Hasta luego!
Hallo, Welt!
Ein Apfel
3 Äpfel
Guten morgen
Aufwiedersehen!
PASS
ok      _/home/admin/src/port2port/lxc/gettext  0.002s

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions