1

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.

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++: error: libgtest.a: No such file or directory

4
  • you need to change your makefile, AFAIK it can't be done using Linker property tab.
    – vasek
    Aug 22, 2017 at 11:16
  • It seems that I have not direct acces to makefile. Makefile generated internally in VS.
    – LNK
    Aug 22, 2017 at 11:38
  • See answer in stackoverflow.com/questions/45570103/g-cant-link-curl-lib-files/… . Note that VCLinux uses MSBuild by default, so no makefile is involved.
    – stanthomas
    Aug 23, 2017 at 10:25
  • 1
    Alternatively, if you prefer Linker->Input->Additional Dependencies to Linker->Input->Library Dependencies, you must specify the full path, i.e. the line will read /usr/lib/libgtest.a
    – stanthomas
    Aug 23, 2017 at 23:44

2 Answers 2

0

Try omit "lib" and ".a" from the file name as these portions of the filename seem to be added by the linker itself. In your case you would reference "gtest".

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.