编译时如何在路径中包含库?

发布于 2024-12-05 06:42:52 字数 1424 浏览 2 评论 0原文

我正在阅读这篇关于 Go 的帖子,并正在尝试编译源码发现这里

我下载了源代码,用 编译了第一个文件make ,我可以看到生成了对象:

$pwd
/Users/oscarryz/code/go/rsc/rosetta/graph

$ls -ltR
total 136
-rw-r--r--  1 oscarryz  staff  61295 Sep 17 16:20 _go_.6
drwxr-xr-x  3 oscarryz  staff    102 Sep 17 16:20 _obj
-rw-r--r--  1 oscarryz  staff    126 Sep 17 16:17 Makefile
-rw-r--r--  1 oscarryz  staff   2791 Sep 17 16:17 graph.go

./_obj:
total 0
drwxr-xr-x  3 oscarryz  staff  102 Sep 17 16:20 rsc.googlecode.com

./_obj/rsc.googlecode.com:
total 0
drwxr-xr-x  3 oscarryz  staff  102 Sep 17 16:20 hg

./_obj/rsc.googlecode.com/hg:
total 0
drwxr-xr-x  3 oscarryz  staff  102 Sep 17 16:20 rosetta

./_obj/rsc.googlecode.com/hg/rosetta:
total 136
-rw-r--r--  1 oscarryz  staff  68486 Sep 17 16:20 graph.a

不,我的问题是,如何引用迷宫目录中的已编译代码:

/Users/oscarryz/code/go/rsc/rosetta/maze/maze.go

其导入声明是:

import (
    "bytes"
    "fmt"
    "rand"
    "time"

    "rsc.googlecode.com/hg/rosetta/graph"
)

现在无法编译并显示错误消息:

6g  -o _go_.6 maze.go 
maze.go:20: can't find import: rsc.googlecode.com/hg/rosetta/graph
make: *** [_go_.6] Error 1

I'm reading this post about go and was trying to compile the source code found here

I downloaded the source code, compiled the first file with make and I can see the object is generated:

$pwd
/Users/oscarryz/code/go/rsc/rosetta/graph

$ls -ltR
total 136
-rw-r--r--  1 oscarryz  staff  61295 Sep 17 16:20 _go_.6
drwxr-xr-x  3 oscarryz  staff    102 Sep 17 16:20 _obj
-rw-r--r--  1 oscarryz  staff    126 Sep 17 16:17 Makefile
-rw-r--r--  1 oscarryz  staff   2791 Sep 17 16:17 graph.go

./_obj:
total 0
drwxr-xr-x  3 oscarryz  staff  102 Sep 17 16:20 rsc.googlecode.com

./_obj/rsc.googlecode.com:
total 0
drwxr-xr-x  3 oscarryz  staff  102 Sep 17 16:20 hg

./_obj/rsc.googlecode.com/hg:
total 0
drwxr-xr-x  3 oscarryz  staff  102 Sep 17 16:20 rosetta

./_obj/rsc.googlecode.com/hg/rosetta:
total 136
-rw-r--r--  1 oscarryz  staff  68486 Sep 17 16:20 graph.a

No my question is, how do I refer to that compiled code from the maze directory:

/Users/oscarryz/code/go/rsc/rosetta/maze/maze.go

Whose import declarations are:

import (
    "bytes"
    "fmt"
    "rand"
    "time"

    "rsc.googlecode.com/hg/rosetta/graph"
)

And right now is failing to compile with the error message:

6g  -o _go_.6 maze.go 
maze.go:20: can't find import: rsc.googlecode.com/hg/rosetta/graph
make: *** [_go_.6] Error 1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山川志 2024-12-12 06:42:52

好吧,我找到了,没那么难。

6g 标志:-I DIR 搜索 DIR 中的包

我必须指定 -I 选项,如下所示:

6g -I ../graph/_obj/ -o _go_.6 maze.go 

Ok, I found it, wasn't that hard.

6g flags: -I DIR search for packages in DIR

I have to specify the -I option like this:

6g -I ../graph/_obj/ -o _go_.6 maze.go 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文