Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/158.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在Windows Netbeans中设置gtest?_C++_Netbeans_Googletest - Fatal编程技术网

C++ 如何在Windows Netbeans中设置gtest?

C++ 如何在Windows Netbeans中设置gtest?,c++,netbeans,googletest,C++,Netbeans,Googletest,我已经查看了Netbeans论坛、GTESTwiki和周围的内容&我似乎找不到让gtest在Netbeans(6.9.1,Windows7x64)中正常工作的方法。我的#include of gtest.h或unittest文件本身没有问题-ASSERT#LE被识别等。我使用的是cygwin&结果与c:\gtest-1.5.0或cygwin/usr/local/gtest-1.5.0上的gtest相同。我认为这可能是为了测试使用不同的makefile的问题&基于gtest包含的makefile,

我已经查看了Netbeans论坛、GTESTwiki和周围的内容&我似乎找不到让gtest在Netbeans(6.9.1,Windows7x64)中正常工作的方法。我的#include of gtest.h或unittest文件本身没有问题-ASSERT#LE被识别等。我使用的是cygwin&结果与c:\gtest-1.5.0或cygwin/usr/local/gtest-1.5.0上的gtest相同。我认为这可能是为了测试使用不同的makefile的问题&基于gtest包含的makefile,但这对我不起作用(也许我做错了)。这是我点击ALT-F6(测试项目)时得到的结果:

等等

如果我将一个与gtest中包含的文件几乎相同的定制makefile放入test文件夹,右键单击它,并使我获得:

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.
如果我再次测试项目,我会得到:


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

谢谢

从“undefined reference”的第一个片段开始,这是一个链接器配置问题,您没有添加gtest库。据我所知,gtest不提供二进制文件,因此您必须自己编译库(gtest.lib),然后将其添加到链接器属性中的某个位置,作为附加库—我自己不是netbeans用户,无法准确说出具体位置。

从“undefined reference”的第一个片段开始,您一开始就很接近了,这是一个链接器配置问题-您没有添加gtest库。据我记忆所及,gtest不提供二进制文件,所以您必须自己编译库(gtest.lib),然后将其作为附加库添加到链接器属性中的某个位置—不是netbeans用户本人,无法确切地说出位置


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