2011-09-17 52 views
4

我讀this後約去,並試圖編譯源代碼發現here如何在編譯時在路徑中包含庫?

我下載的源代碼,編譯的第一個文件與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 

回答

3

好吧,我發現了它,並沒有那麼難。

6克標誌:-I DIR搜索包在DIR

我必須指定-I選項是這樣的:

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

紙條給我自己,鏈接它,我需要' -L'選項,如:'6l -L ../graph/ -o maze _go_.6' – OscarRyz

+0

不要忘記接受你的答案,因爲我今天剛剛有同樣的問題...... – Nate

相關問題