1

I was trying to install a neural networks toolbox called CarlSim using visual studio 2012, in which they use gtest in their code. I try to install gtest by downloading it online and build using gtest.sln file. It gives me two warnings. I guess these two warnings are the reason for this error. But I don't know how to solve this. The gtest seems only can build gtestd.lib. Below is the error during install of the neural network toolbox

Error   2   error LNK1104: cannot open file 'gtest.lib' C:\Users\Dukerama\Desktop\CarlSim\carlsim\test\LINK carlsim_tests

Below are the warnings of the gest.

    1>------ Rebuild All started: Project: gtest, Configuration: Debug Win32 ------
1>  gtest-all.cc
1>C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppBuild.targets(1299,5):      warning MSB8012: TargetPath(C:\Users\Dukerama\Desktop\gtest\gtest-  1.6.0\msvc\gtest/Debug\gtest.lib) does not match the Library's OutputFile property value (C:\Users\Dukerama\Desktop\gtest\gtest-1.6.0\msvc\gtest\Debug\gtestd.lib). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppBuild.targets(1301,5): warning MSB8012: TargetName(gtest) does not match the Library's OutputFile property value (gtestd). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).
1>  gtest.vcxproj -> C:\Users\Dukerama\Desktop\gtest\gtest-1.6.0\msvc\gtest/Debug\gtest.lib
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
user5473110
  • 125
  • 1
  • 9

2 Answers2

0

Output from build command in VS you have posted suggests that there are inconsistencies between certain values in VS project properties for gtest (located in 'Configuration Properties -> General' and in 'Configuration Properties -> Librarian -> General'). However, output also suggests that the gtest library is built at location:

C:\Users\Dukerama\Desktop\gtest\gtest-1.6.0\msvc\gtest/Debug\gtest.lib

You should take this file and place it in directory where CarlSim toolbox expects to find the gtest library. You can find this out in the VS project properties for CarlSim ('Configuration Properties -> Linker -> General -> AdditionalLibraryDirectories').

P.S. Make sure that both gtest and CarlSim link to the same runtime library, or you'll get more linker errors. You can inspect the runtime library in their VS project properties at 'Configuration Properties -> C/C++ -> Code Generation -> Runtime Library'.

Marko Popovic
  • 3,999
  • 3
  • 22
  • 37
  • Thank you for your answer. But I went to that directory and didn't find gtest.lib. There is only a gtestd.lib not gtest.lib. – user5473110 Nov 16 '15 at 14:38
  • Finally, I figured out why. I tried to use right click solution property to set the configure mode to release. It didn't work. If I change it in the panel, it works. I will now deal with the warnings using what you said. – user5473110 Nov 16 '15 at 15:29
  • I now can generate gtest.lib. But when I compile Carlsim. It still gives me an "can't not open file gtest.lib" error. I've already include the folder which has gtest.lib file in the library. I don't know why. – user5473110 Nov 16 '15 at 15:35
  • I now have a new error saying "error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'" – user5473110 Nov 16 '15 at 17:15
  • @user5473110 Sorry if my answer did not help you much, it was all I could do with information you've given. As for your last error, one project is configured to target x64 architecture, while the other is configured for x86. This can be changed by opening project properties and clicking 'Configuration Manager' button, and then modifying 'Platform' for a selected build configuration. Hope this helps! – Marko Popovic Nov 16 '15 at 19:27
0

I had the same problem. Unfortunately, the proposed solution didn't help me. In my case, the build worked properly on my PC, but it gave the error on a collegue's PC. We solved it moving the project in a new location with a shorter path.

Rudy Barbieri
  • 389
  • 1
  • 4
  • 16