Iconv-go compilation issues during the upgrade process

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

For work item reasons, the Golang needs to be upgraded. After the upgrade the old Iconv-go run with problems. Because the new Golang runs more rigorously, the iconv-go needs to be upgraded.

Pull down code from djimenez/iconv-go to compile the discovery "some interfaces of the Iconv library cannot be found", the visual is the library does not chain in. The error message is as follows:

GoInstall./... # github.com/djimenez/iconv-Go/tmp/go-build579267556/github.com/djimenez/iconv-go/_obj/converter.cgo2.o:infunction' _cgo_5f3e10abf205_cfunc_iconv_open':Src/github.com/djimenez/iconv-go/converter.go:142: Undefined reference to ' Libiconv_open'/tmp/go-build579267556/github.com/djimenez/iconv-go/_obj/converter.cgo2.o:infunction' _cgo_5f3e10abf205_cfunc_iconv_close':Src/github.com/djimenez/iconv-go/converter.go: -: Undefined reference to ' Libiconv_close'/tmp/go-build579267556/github.com/djimenez/iconv-go/_obj/converter.cgo2.o:infunction' _cgo_5f3e10abf205_c2func_iconv_open':Src/github.com/djimenez/iconv-go/converter.go: the: Undefined reference to ' Libiconv_open'/tmp/go-build579267556/github.com/djimenez/iconv-go/_obj/converter.cgo2.o:infunction' _cgo_5f3e10abf205_c2func_iconv_close':Src/github.com/djimenez/iconv-go/converter.go: in: Undefined reference to ' Libiconv_close'/tmp/go-build579267556/github.com/djimenez/iconv-go/_obj/converter.cgo2.o:infunction' Call_iconv':Src/github.com/djimenez/iconv-go/converter.go: -: Undefined reference to ' Libiconv'Collect2:LDReturned1Exit status

Very strange, local obviously have installed Iconv, how can not find Iconv library?

Iconv-1.14-free  software Foundation, Inc.license GPLv3  3 or later //gnu.org/licenses/gpl.html> Free To change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Bruno Haible.

Converter.go found in Iconv-go.

Package Iconv /* #cgo Darwin ldflags:-liconv#cgo FreeBSD ldflags:-liconv#cgo Windows ldflags:-liconv#include <stdlib.h>#  Include <iconv.h>//as of Go 1.6 passing a pointer to go pointer, would leads to panic//Therofore we use this wrapper function, to avoid passing **char directly from gosize_t call_iconv (iconv_t ctx, Char *in, size_t *size_in, char *out, si ze_t *size_out) {        return iconv (CTX, &in, size_in, &out, size_out);} */

I got a go, Darwin,freebsd,windows. But I used it under CentOS. Is this the reason why the Iconv library is not chained in? So I tried to make a change.

Package Iconv /* #cgo Darwin ldflags:-liconv#cgo FreeBSD ldflags:-liconv#cgo Windows ldflags:-liconv#cgo ldflags:-liconv#include &l T;stdlib.h> #include <iconv.h>//As of Go 1.6 passing a pointer to go pointer, 'll leads to panic//therofore we u Se This wrapper function, to avoid passing **char directly from gosize_t call_iconv (iconv_t ctx, Char *in, size_t *size_in , Char *out, size_t *size_out) {        return iconv (CTX, &in, size_in, &out, size_out);} */

To compile again. Miraculously passed, passed, passed ...

Well, at present it's just such a wretched solution. This writing does not know whether the cross-platform impact. Let's do it first. Record it.

If any of my colleagues see this article, feel that this is not the solution, please advise.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.