2011-12-14 55 views
1

我目前正在開發一個項目,我試圖實現協議緩衝區作爲序列化格式在本地計算機上存儲數據,然後稍後再回讀。協議緩衝區的一些功能對於這個項目來說似乎很完美,所以我急於測試它,但是我遇到了一些問題。構建和使用Google協議緩衝區

到目前爲止,我還沒有足夠的時間來測試協議緩衝區。我將最新的zip文件(版本2.4.1)下載到我的Windows機器上。我閱讀了位於文件夾根目錄下的install.txt文件,但它是基於Unix的系統。然後我看到它帶有一個vsprojects文件夾,並閱讀其中列出的說明。基本上,我被告知要做的是打開一個解決方案,然後在Debug或Release中構建整個解決方案。我立即收到一些關於「config.h」未找到的錯誤。

我再次檢查了Unix的說明和步驟之一是...

  1. cd' to the directory containing the package's source code and type './configure' to configure the package for your system. If you're using CSH「在舊版本的System V的,你可能需要輸入 sh ./configure' instead to prevent CSH」從試圖執行 `configure'本身。

運行`configure'需要一段時間。在運行時,它會打印一些 消息,告訴它正在檢查哪些功能。

因此,我啓動到我很少使用的Ubuntu,並嘗試按照這些說明。上面列出的步驟去罰款,我甚至能夠獲得下一步和「做」的項目,但是當時間到了使用「make install」命令,我收到以下錯誤:

[email protected]:~/Desktop/protobuf-2.4.1$ make install 
Making install in . 
make[1]: Entering directory `/home/ross/Desktop/protobuf-2.4.1' 
make[2]: Entering directory `/home/ross/Desktop/protobuf-2.4.1' 
make[2]: Nothing to be done for `install-exec-am'. 
test -z "/usr/local/lib/pkgconfig" || /bin/mkdir -p "/usr/local/lib/pkgconfig" 
/bin/mkdir: cannot create directory `/usr/local/lib/pkgconfig': Permission denied 
make[2]: *** [install-pkgconfigDATA] Error 1 
make[2]: Leaving directory `/home/ross/Desktop/protobuf-2.4.1' 
make[1]: *** [install-am] Error 2 
make[1]: Leaving directory `/home/ross/Desktop/protobuf-2.4.1' 

化妝:* [安裝遞歸]錯誤1

我主要使用Windows進行開發,我正在使用的整個項目現在正在Windows中進行,所以我有點擔心。有沒有人有幸在Windows或Linux中建立協議緩衝區?

謝謝

回答

3

你不能這樣做make install爲自己的用戶,當你試圖安裝系統範圍。 如果您擁有sudo權限,則可以使用sudo make install,或者以任何其他可能的方式成爲root,然後運行它。

如果您沒有管理員權限,可以運行./configure --prefix=$HOME/protobuffers,編譯並再次運行make install,它會在你的家目錄的子目錄安裝它們稱爲protobuffers。請注意,您可能想要在配置文件中調整您的LD_LIBRARY_PATH,以便能夠找到庫。如果你只需要protoc,那應該可以做到。

---編輯---

說到這,protoc也可用於Windows,你可以在那裏使用它們。 您可以下載here

+0

好吧,那爲linux的一方工作。不要以爲你有任何有用的Windows建議?我檢查了運行configure的第一步沒有生成一個config.h,因爲我希望... – 2011-12-14 20:08:25