dongxieyi9115 2011-09-17 21:30
浏览 88
已采纳

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

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
  • 写回答

1条回答 默认 最新

  • dongtun1209 2011-09-17 22:09
    关注

    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 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?