How to change lib path for "go build"

huangapple go评论85阅读模式
英文:

How to change lib path for "go build"

问题

我正在尝试使用goncurses。在Centos 6上,ncurses库版本较旧(5.7,需要5.9),所以我从源代码构建了ncurses,并将其安装到了/usr/lib、/usr/include等目录下。

我该如何告诉"go get"命令在/lib目录下的系统库之外,使用/usr/lib目录下的库呢?

这是我当前的输出:

$ go get -v code.google.com/p/goncurses
code.google.com/p/goncurses
# code.google.com/p/goncurses
/tmp/go-build076024492/code.google.com/p/goncurses/_obj/goncurses.o: In function `ncurses_is_subwin':
src/code.google.com/p/goncurses/goncurses.c:71: undefined reference to `is_subwin'
/tmp/go-build076024492/code.google.com/p/goncurses/_obj/goncurses.o: In function `ncurses_is_pad':
src/code.google.com/p/goncurses/goncurses.c:63: undefined reference to `is_pad'
collect2: ld returned 1 exit status

我尝试过不同的变体,如LD_LIBRARY_PATH=/usr/lib-ccflags = '-I /usr/lib',但行为没有任何变化。

我知道这是一个简单的问题,但我现在无法找到答案。

英文:

I'm trying to work with goncurses. On Centos 6 the ncurses library is old (5.7, wants 5.9), so I built ncurses from source and installed it into /usr/lib, /usr/include, etc.

How do I tell "go get" to run against the stuff in /usr/lib instead of the system stuff in /lib?

This is my currenty output:

$ go get -v code.google.com/p/goncurses
code.google.com/p/goncurses
# code.google.com/p/goncurses
/tmp/go-build076024492/code.google.com/p/goncurses/_obj/goncurses.o: In function `ncurses_is_subwin':
src/code.google.com/p/goncurses/goncurses.c:71: undefined reference to `is_subwin'
/tmp/go-build076024492/code.google.com/p/goncurses/_obj/goncurses.o: In function `ncurses_is_pad':
src/code.google.com/p/goncurses/goncurses.c:63: undefined reference to `is_pad'
collect2: ld returned 1 exit status

I've tried different variations on LD_LIBRARY_PATH=/usr/lib and -ccflags = '-I /usr/lib' with out any change in behavior.

I know it's a simple question, but my google-fu is failing me right now.

答案1

得分: 2

goncurses包依赖于pkg-config来获取构建所需的正确路径。

如果你能够让pkg-config在你的系统上输出ncurses的正确路径,Go语言将会自动处理后续步骤。另一种选择是分叉goncurses的代码,并编辑源代码中的#cgo指令。

英文:

The goncurses package is relying on pkg-config to get the proper paths for building.

If you can get pkg-config to output the correct paths for ncurses on your system -- go will do the right thing from there. Your other option is of course to fork the goncurses code, and edit the #cgo directives in the source.

huangapple
  • 本文由 发表于 2014年5月27日 08:03:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/23879205.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定