Linker errors on "make test" on Fuerte [closed]

asked 2012-08-20 04:46:54 -0500

mkopack gravatar image

updated 2012-08-20 06:33:41 -0500

Lorenz gravatar image

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...

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by mkopack
close date 2012-08-21 04:01:26

Comments

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.

mkopack gravatar image mkopack  ( 2012-08-20 08:49:37 -0500 )edit