英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论