0

我想使用 gtest 但执行告诉我

./netTest: error while loading shared libraries: libgtest.so.0:
  cannot open shared object file: No such file or directory
  1. gcc 链接器中查找库的标准路径是什么
  2. Debian 存储库的标准路径是什么
  3. 如何将 libpaths 添加到 g++(-L 标志是否正确?)

注意2:我问是因为gtest的库在/usr/local/libs/但里面只有python和gtest。所有其他库都在/usr/lib/. 因此,我猜 gtest 安装程序出错了。

4

2 回答 2

2

PS。也许您可以只安装 Debianlibgtest-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.

于 2012-11-22T10:59:42.233 回答
2

前面问题的答案。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].

-- Steve M. Robbins,2012 年 4 月 21 日,星期六 17:00:56 -0500

好吧,为什么我没有在 Wheezy 中找到图书馆,这让我不再感到惊讶 :)

于 2012-11-22T11:21:28.977 回答