无法在 Eclipse 中编译 googletest
unable to compile googletest in eclipse
我正在尝试编译 googletest (git clone https://github.com/google/googletest.git -b release-1.11.0) 但不断出现 1000 多个链接器错误。
我是运行windows10、eclipseCDT(最新)、mingw(最新)gcc。我创建了一个 eclipse c++ 项目(可执行的空项目)。
添加包含路径到:
- 谷歌测试
- googletest/includes
- googlemock
- googlemock/includes
将源位置添加到:
- googletest/src
- googlemock/src
所有编译都没有问题,但链接失败并出现 1000 多个错误。例如
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
googletest\gtest.o: in function `testing::IsNotSubstring(char const*, char const*, wchar_t const*, wchar_t const*)':
C:\dev\unode\eclipse\unit_tests\Debug/../../googletest/googletest/src/gtest.cc:1821: multiple definition of `testing::IsNotSubstring(char const*, char const*, wchar_t const*, wchar_t const*)';
googletest\gtest-all.o:C:/dev/unode/eclipse/googletest/googletest/src/gtest.cc:1821: first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
googletest\gtest.o: in function `testing::IsSubstring(char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
C:\dev\unode\eclipse\unit_tests\Debug/../../googletest/googletest/src/gtest.cc:1827: multiple definition of `testing::IsSubstring(char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)';
googletest\gtest-all.o:C:/dev/unode/eclipse/googletest/googletest/src/gtest.cc:1827: first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
googletest\gtest.o: in function `testing::IsNotSubstring(char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
我正在阅读 googletests readme.md 以找出我做错了什么但一无所获。一些帮助将不胜感激
啊,有文件
googletest/src/gtest-all.cc
其中包括所有源文件。所以所有源文件都编译了两次,删除这个文件解决了我的问题
我正在尝试编译 googletest (git clone https://github.com/google/googletest.git -b release-1.11.0) 但不断出现 1000 多个链接器错误。
我是运行windows10、eclipseCDT(最新)、mingw(最新)gcc。我创建了一个 eclipse c++ 项目(可执行的空项目)。
添加包含路径到:
- 谷歌测试
- googletest/includes
- googlemock
- googlemock/includes
将源位置添加到:
- googletest/src
- googlemock/src
所有编译都没有问题,但链接失败并出现 1000 多个错误。例如
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
googletest\gtest.o: in function `testing::IsNotSubstring(char const*, char const*, wchar_t const*, wchar_t const*)':
C:\dev\unode\eclipse\unit_tests\Debug/../../googletest/googletest/src/gtest.cc:1821: multiple definition of `testing::IsNotSubstring(char const*, char const*, wchar_t const*, wchar_t const*)';
googletest\gtest-all.o:C:/dev/unode/eclipse/googletest/googletest/src/gtest.cc:1821: first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
googletest\gtest.o: in function `testing::IsSubstring(char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
C:\dev\unode\eclipse\unit_tests\Debug/../../googletest/googletest/src/gtest.cc:1827: multiple definition of `testing::IsSubstring(char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)';
googletest\gtest-all.o:C:/dev/unode/eclipse/googletest/googletest/src/gtest.cc:1827: first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
googletest\gtest.o: in function `testing::IsNotSubstring(char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
我正在阅读 googletests readme.md 以找出我做错了什么但一无所获。一些帮助将不胜感激
啊,有文件 googletest/src/gtest-all.cc
其中包括所有源文件。所以所有源文件都编译了两次,删除这个文件解决了我的问题