How do I set up gtest in Windows Netbeans?
I've looked at the Netbeans forums, gtest wiki & around here & I can't seem to find a way to get gtest working right in Netbeans (6.9.1, Windows 7x64). There's no problem with my #include of gtest.h or with the unittest file itself - ASSERT_LE is recognized etc. I'm using cygwin & the results are the same with gtest at c:\gtest-1.5.0 or cygwin/usr/local/gtest-1.5.0. I think it might be matter of getting a different makefile for the tests to use & based off the gtest included makefile, but that hasn't worked for me (maybe I'm doing it wrong). This is what I get when I hit ALT-F6 (Test Project):
g++.exe -o build/Debug/Cygwin-Windows/tests/TestFiles/f1 build/Debug/Cygwin-Windows/tests/tests/Armor_unittest.o build/Debug/Cygwin-Windows/tests/tests/newsimpletest.o build/Debug/Cygwin-Windows/main_nomain.o build/Debug/Cygwin-Windows/Character_nomain.o build/Debug/Cygwin-Windows/Map_nomain.o build/Debug/Cygwin-Windows/Armor_nomain.o build/Debug/Cygwin-Windows/Weapon_nomain.o build/Debug/Cygwin-Windows/Shop_nomain.o build/Debug/Cygwin-Windows/Enemy_nomain.o
build/Debug/Cygwin-Windows/tests/tests/Armor_unittest.o: In function `_ZN31ArmorTest_SetupAndGetWorks_Test8TestBodyEv':
/cygdrive/c/Users/.../winPro2Game/tests/Armor_unittest.cpp:9: undefined reference to `testing::internal::AssertHelper::A开发者_如何学JAVAssertHelper(testing::TestPartResult::Type, char const*, int, char const*)'
/cygdrive/c/Users/.../winPro2Game/tests/Armor_unittest.cpp:9: undefined reference to `testing::internal::AssertHelper::operator=(testing::Message const&) const'
/cygdrive/c/Users/.../winPro2Game/tests/Armor_unittest.cpp:9: undefined reference to `testing::internal::AssertHelper::~AssertHelper()'
/cygdrive/c/Users/.../winPro2Game/tests/Armor_unittest.cpp:9: undefined reference to `testing::internal::AssertHelper::~AssertHelper()'
etc...
If I put a custom built makefile that is almost identical to the one included with gtest into the test folder & right click on it & Make I get:
Makefile:21: target `gtest-all.o' doesn't match the target pattern
Makefile:25: target `gtest_main.o' doesn't match the target pattern
Makefile:39: *** multiple target patterns. Stop.
If I do Test Project again I get:
rm -f build/Debug/Cygwin-Windows/tests/tests/Makefile.o.d
g++.exe -c -g -I../../../../../../../gtest-1.5.0/include -MMD -MP -MF build/Debug/Cygwin-Windows/tests/tests/Makefile.o.d -o build/Debug/Cygwin-Windows/tests/tests/Makefile.o tests/Makefile
g++: tests/Makefile: linker input file unused because linking not done
gcc.exe build/Debug/Cygwin-Windows/tests/tests/Makefile.o -o build/Debug/Cygwin-Windows/tests/tests/Makefile
gcc: build/Debug/Cygwin-Windows/tests/tests/Makefile.o: No such file or directory
gcc: no input files
make[1]: *** [build/Debug/Cygwin-Windows/tests/tests/Makefile] Error 1
make[1]: Leaving directory `/cygdrive/c/Users/.../winPro2Game'
make: *** [.build-tests-impl] Error 2
Thanks!
you were close in the first place - from the first snippet of "undefined reference", it's a linker configuration issue - you don't have gtest library added. as far as i remember, gtest doesn't ship binaries, so you'll have to compile library yourself (gtest.lib), then add that somewhere in linker properties as additional library - not a netbeans user myself, can't tell exactly where.
精彩评论