从Visual Studio 2017指定Linux的外部库 [英] Specify external library for linux from Visual Studio 2017

查看:65
本文介绍了从Visual Studio 2017指定Linux的外部库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Visual Studio 2017开发linux(ubuntu)c ++项目.我想将googletest集成到我的代码中.我已经安装了googletest并根据后续教程运行测试示例.当我使用cmake从bash终端运行该程序时,一切正常.

I'm developing linux(ubuntu) c++ project from Visual Studio 2017. I want to integrate googletest into my code. I have installed googletest and run test example according following tutorial. Everything works fine when I run it from bash terminal using cmake.

现在我需要使用VS运行它.为此,我需要指定VS中/usr/lib/libgtest.a 的路径.我在 Linker-> General-> Additional Library Directories 中添加了/usr/lib ,并在 Linker-> Input中添加了 libgtest.a ->其他依赖项.但是编译器仍然无法链接该库:

Now I need to run it using VS. For that I need to specify path to /usr/lib/libgtest.a from VS. I added /usr/lib into Linker->General->Additional Library Directories and added libgtest.a into Linker->Input->Additional Dependencies. But compiler still cannot link the library:

g ++:错误:libgtest.a:没有这样的文件或目录

g++: error: libgtest.a: No such file or directory

推荐答案

尝试使用"gtest"配置属性->链接器->输入->库依赖项.注意:libgtest.a必须位于标准位置,以便链接程序可以搜索.

Try Configuration Properties -> Linker->Input->Library Dependencies with "gtest". Note: libgtest.a must in standard location so linker can search.

这篇关于从Visual Studio 2017指定Linux的外部库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆