2012-04-15 12 views
0

描述如何從我自己的GNU Makefile中將「getoptpp」編譯爲陰影庫並將其靜態鏈接到我的程序?GNU MAKE - 從我自己的Makefile創建getoptpp庫或爲C++建議命令行選項庫

我做什麼:

在我的程序目錄中我未歸檔getoptpp庫同名子目錄。 比增加了新的目標,以我的Makefile:(自述說我使用的共享標誌,使$>讓SHARED = N。)

getoptpp: 
    cd getoptpp; $(MAKE) SHARED=n 

比我加入這個目標我的程序的要求目標的清單:

myprogram: getoptpp 
    g++ **** myprogram 

但在調用make myprogram之後 - 根本沒有創建新的.so。 呼籲 「讓getoptpp」 的時候 - 讓說 '是最新的'

* 新增:.PHONY的建議後有錯誤*

cd getoptpp; make SHARED=n 
"Makefile", line 15: Missing dependency operator 
"Makefile", line 19: Need an operator 
"Makefile", line 24: Need an operator 
"Makefile", line 45: Missing dependency operator 
"Makefile", line 47: Need an operator 
make: fatal errors encountered -- cannot continue 
*** Error code 1 

http://code.google.com/p/getoptpp/

OR

請爲我的C++程序建議非常好的命令行解析庫。我可以簡單地編譯爲鏈接到我的程序的.o對象。沒有提升!

回答

1

該目錄存在,並沒有更新,所以是的,它是最新的。也許你想要declare it as a dependency of .PHONY

+0

謝謝,現在有一個錯誤。黨的生成文件是從框中。 – abrahab 2012-04-15 10:36:20

+1

這是什麼類型的系統?它看起來像你的'make'不是GNU'make';您可能需要調用'gmake',特別是在* BSD主機上。 – geekosaur 2012-04-15 10:40:30

+0

是的,現在我在freebsd。謝謝,但是...如果我在這種lib的這種編譯中使用gmake,我的makefile將不能移植到其他的* unix系統中? :(不適用(( – abrahab 2012-04-15 10:49:31