Linker errors on "make test" on Fuerte [closed]
Hey gang,
I'm trying in vain to get a simple empty unit test set up for my system running on Fuerte + Ubuntu 12.04.
I've created a simple unit test.cpp file based on what found here link text
I've also created a corresponding .launch file, and added the 3 lines to the CMakeLists.txt.
When I initially tried, I was getting a linker error when trying to run "make test": /usr/bin/ld: cannot find -lgtest
I confirmed that libgtest-dev IS installed on the system, but for the life of me I can't find the .a file anywhere in the usual places. I DID find it in a number of the Fuerte stack's /lib directories. I also found the source for it in /usr/src/gtest. I've tried both compiling from source, and also copying the .a's found in the other stacks and putting it into my packages' /lib.
Now when I try to invoke "make test" I get:
/home/mkopack/trooper-svn/trunk/trooper_ocu/lib/libgtest.a(gtest-all.cc.o): In function `testing::internal::ThreadLocal<testing::TestPartResultReporterInterface*>::CreateKey()':
/usr/include/gtest/internal/gtest-port.h:1365: undefined reference to `pthread_key_create'
/home/mkopack/trooper-svn/trunk/trooper_ocu/lib/libgtest.a(gtest-all.cc.o): In function `testing::internal::ThreadLocal<std::vector<testing::internal::TraceInfo, std::allocator<testing::internal::TraceInfo> > >::CreateKey()':
/usr/include/gtest/internal/gtest-port.h:1365: undefined reference to `pthread_key_create'
/home/mkopack/trooper-svn/trunk/trooper_ocu/lib/libgtest.a(gtest-all.cc.o): In function `~ThreadLocal':
/usr/include/gtest/internal/gtest-port.h:1336: undefined reference to `pthread_getspecific'
/usr/include/gtest/internal/gtest-port.h:1340: undefined reference to `pthread_key_delete'
/usr/include/gtest/internal/gtest-port.h:1336: undefined reference to `pthread_getspecific'
/usr/include/gtest/internal/gtest-port.h:1340: undefined reference to `pthread_key_delete'
I'm rather stumped at this point. What am I missing? I can't believe it's this hard just to get unit test capability stood up given that most of the stacks seem to use it...
Ok, turns out I needed to put in the following line into my CMakeLists.txt:
target_link_libraries(ocutest gtest)
(where ocutest is the name of my test executeable...)
That seems to have fixed it and now I can run my tests.