Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - gtest linking error: (2 Items)
   
gtest linking error  
Hello,

i have trouble with linking gtest. When i work from command line is works fine(see below working example), but  
when i try do the compile my gtest project with a makefile i get "undefined reference to `testing::internal::EqFailure..
." during linking step.  If i exclude the testcase the linking works fine an i can run the application, but without a 
TEST(...).  I attached the *.cpp and *.h files of may project
I am using QNX Momentics version: 7.1.2 and compiling for v7.0.0 32bit.  

working example: 
qcc -std=gnu++0x -v -o gtests_main gtests_main.cpp gtests_case1.cpp  -lgtest

error example:

make -j all 
qcc -lang-c++ -V5.4.0,gcc_ntox86_gpp -g3 -Wall -Wp,-std=gnu++0x -o lib/gtests_case1.o -c gtests_case1.cpp
qcc -lang-c++ -V5.4.0,gcc_ntox86_gpp -g3 -Wall -Wp,-std=gnu++0x -o lib/gtests_main.o -c gtests_main.cpp
qcc -lang-c++ -V5.4.0,gcc_ntox86_gpp -o px3xtun_gtests -Wl,-lstdc++ ./lib/gtests_case1.o ./lib/gtests_main.o -lgtest
./lib/gtests_case1.o: In function `testing::AssertionResult testing::internal::CmpHelperEQ<double, int>(char const*, 
char const*, double const&, int const&)':
[...]/qnx700/target/qnx7/usr/include/gtest/gtest.h:1460: undefined reference to `testing::internal::EqFailure(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&, bool)'
cc: [...]/qnx700/host/win64/x86_64/usr/bin/i586-pc-nto-qnx7.0.0-ld caught signal 1
make: *** [all] Error 1
makefile:28: recipe for target 'all' failed
"make -j all" terminated with exit code 2. Build might be incomplete.
Attachment: Text gtests_main.cpp 1.45 KB Text gtests_case1.cpp 1,003 bytes Text gtests.h 779 bytes
Re: gtest linking error  
Not sure why you posting on IDE forum, but if I google it it brings this https://stackoverflow.com/questions/24820664/
undefined-reference-to-testinginternaleqfailure-in-gtest

In gist it is a mismatch between header and library - make sure you header is from the same place as library, i.e. part 
of same sdp distribution