Getting started on Linux

637 views
Skip to first unread message

in...@sinelabore.com

unread,
Mar 2, 2015, 4:12:48 PM3/2/15
to cppu...@googlegroups.com
Hello,

I used CppUTest on Mac before without problem.

But now I wanted to switch to Ubuntu and get the following error message for a minimal example:

test.cpp:7: undefined reference to `CommandLineTestRunner::RunAllTests(int, char**)'
test.o: In function `TEST_FirstTestGroup_FirstTest_Test::testBody()':
/home/pmueller/develop/minimal_runtime/tests/test.cpp:25: undefined reference to `UtestShell::getCurrent()'
/home/pmueller/develop/minimal_runtime/tests/test.cpp:25: undefined reference to `NormalTestTerminator::~NormalTestTerminator()'
/home/pmueller/develop/minimal_runtime/tests/test.cpp:25: undefined reference to `NormalTestTerminator::~NormalTestTerminator()'
test.o: In function `__static_initialization_and_destruction_0':
/home/pmueller/develop/minimal_runtime/tests/test.cpp:23: undefined reference to `TestInstaller::TestInstaller(UtestShell&, char const*, char const*, char const*, int)'
/home/pmueller/develop/minimal_runtime/tests/test.cpp:23: undefined reference to `TestInstaller::~TestInstaller()'
test.o: In function `TestTerminator::TestTerminator()':


And this goes on ...

My main looks like:

#include <CppUTest/CommandLineTestRunner.h>
#include <stdint.h>


int main(int ac, char** av){

   int result = CommandLineTestRunner::RunAllTests(ac, av);
   return result;
}

TEST_GROUP(FirstTestGroup)
{
   void setup()
   {
   }

   void teardown()
   {
      // Uninit stuff
   }
};

TEST(FirstTestGroup, FirstTest)
{
  CHECK_TRUE(1); //  true because the buffer is empty
}




And Make looks like this:


all: test
export CPPUTEST_HOME=/usr/local
CPPFLAGS += -I$(CPPUTEST_HOME)/include
LD_LIBRARIES = -L$(CPPUTEST_HOME)/lib -lCppUTest -lCppUTestExt

test: test.o
         g++ -g $(LD_LIBRARIES) -o test test.o

test.o: test.cpp
         g++ -g $(CPPFLAGS) -c test.cpp
        
        
clean:
         rm -f *.o test




I could built CppUTest without problems. And I checked that the lib and include path is correct.

Any idea?

Thanks,
Peter

A. Robert S.

unread,
Mar 18, 2015, 10:49:12 AM3/18/15
to cppu...@googlegroups.com
Did you do a "make install" when you built cpputest? It does seem to find the include files, though...
 
This can also happen when the library was compiled on a different system (e.g. Mac) or with a very different compiler.

Wing Lin

unread,
Mar 21, 2015, 5:46:43 PM3/21/15
to cppu...@googlegroups.com
The link command in your makefile is incorrect; the library should come after the test.o object file due to the file dependency.

News from www.sinelabore.com

unread,
Mar 22, 2015, 5:13:35 AM3/22/15
to cppu...@googlegroups.com
Helle,

that was the trick. But it worked on OS X ...

Thanks!

Best regards,
Peter


--
You received this message because you are subscribed to a topic in the Google Groups "cpputest" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cpputest/GnlxTVf8i8w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cpputest+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

A. Robert S.

unread,
Mar 23, 2015, 4:14:11 AM3/23/15
to cppu...@googlegroups.com
Actually the same thing happened to me the other day when I was playing with a new makefile. You are right, it does work on OS X. So I thought my CppUTest installation under Cygwin was broken.... but it wasn't.... then I realized my Makefile was the problem... really silly :-(.
Reply all
Reply to author
Forward
0 new messages