2012-11-22 73 views
0

我想用GTEST但執行告訴我g ++的標準lib路徑。而如何增加新的

./netTest: error while loading shared libraries: libgtest.so.0: 
    cannot open shared object file: No such file or directory 
  1. 什麼是標準路徑在GCC鏈接查找庫
  2. 什麼是存儲庫
  3. 的Debian的標準路徑
  4. 如何添加libpaths到g ++(-L標誌是否正確?)

注2:我問,因爲GTEST的庫都在/usr/local/libs/但有剛PYT hon和gtest。所有其他庫位於/usr/lib/。因此,我猜測gtest安裝程序出錯了。

回答

1

PS。也許你可以安裝Debian libgtest-dev包(如果有的話)。

  1. 什麼是標準路徑在GCC鏈接查找庫

您可以gcc -v -x c /dev/null -o /dev/null 2>&1 | grep LIBRARY_PATH

  1. 看到什麼是存儲庫的Debian的標準路徑

也許你的意思是動態加載器在哪裏尋找共享庫。 檢查/etc/ld.so.conf和/或/etc/ld.so.conf.d/中的文件。

  1. 如何添加libpaths到g ++(-L標誌是否正確?)

可以使用--rpath選項ld。但是,我建議只在開發過程中使用它,而不是在部署過程中使用它。

您還可以將LD_LIBRARY_PATH設置爲您的libgtest.so.0的位置。

+0

libgtest-dev只是v1.5的頭文件。 debian wheezy上沒有libgtest0這個共享庫。 ls.so.conf內容:'include /etc/ld.so.conf.d/ *。conf'。 /etc/ld.so.conf.d/libc.conf內容:'/ usr/local/lib'。這正是libgtest.so.0所在的地方。爲什麼我會提到這個錯誤? – ManuelSchneid3r

+0

也許緩存沒有更新。以root身份運行'ldconfig -v'。 – chill

1

上述問題的答案。 gTest不再使用預編譯的庫。

Use of precompiled libgtest Not Recommended 
    ------------------------------------------- 

The Google C++ Testing Framework uses conditional compilation for some 
things. Because of the C++ "One Definition Rule", gtest must be 
compiled with exactly the same flags as your C++ code under test. 
Because this is hard to manage, upstream no longer recommends using 
precompiled libraries [1]. 

- 史蒂夫M.羅賓斯,星期六,2012年4月21日17時00分56秒-0500

好犯規驚喜我了,爲什麼我沒有喘息找到庫:)