繁体   English   中英

CppUTest示例构建失败

[英]CppUTest examples build fails

我是Mac新手! 我下载了xcode4.2并尝试构建CppUTest-v3

1)当我做的时候,我有以下日志

compiling AllTests.cpp
compiling AllocationInCppFile.cpp
compiling CheatSheetTest.cpp
compiling CommandLineArgumentsTest.cpp
compiling CommandLineTestRunnerTest.cpp
compiling JUnitOutputTest.cpp
compiling MemoryLeakDetectorTest.cpp
compiling MemoryLeakOperatorOverloadsTest.cpp
compiling MemoryLeakWarningTest.cpp
compiling NullTestTest.cpp
compiling PluginTest.cpp
compiling PreprocessorTest.cpp
compiling SetPluginTest.cpp
compiling SimpleStringTest.cpp
compiling TestFailureTest.cpp
compiling TestFilterTest.cpp
compiling TestHarness_cTest.cpp
compiling TestInstallerTest.cpp
compiling TestMemoryAllocatorTest.cpp
compiling TestOutputTest.cpp
compiling TestRegistryTest.cpp
compiling TestResultTest.cpp
compiling UtestTest.cpp
compiling AllocationInCFile.c
compiling TestHarness_cTestCFile.c
compiling CommandLineArguments.cpp
compiling CommandLineTestRunner.cpp
compiling JUnitTestOutput.cpp
compiling MemoryLeakDetector.cpp
compiling MemoryLeakWarningPlugin.cpp
compiling SimpleString.cpp
compiling TestFailure.cpp
compiling TestFilter.cpp
compiling TestHarness_c.cpp
compiling TestMemoryAllocator.cpp
compiling TestOutput.cpp
compiling TestPlugin.cpp
compiling TestRegistry.cpp
compiling TestResult.cpp
compiling Utest.cpp
compiling UtestPlatform.cpp
Building archive lib/libCppUTest.a
ar: creating archive lib/libCppUTest.a
a - objs/src/CppUTest/CommandLineArguments.o
a - objs/src/CppUTest/CommandLineTestRunner.o
a - objs/src/CppUTest/JUnitTestOutput.o
a - objs/src/CppUTest/MemoryLeakDetector.o
a - objs/src/CppUTest/MemoryLeakWarningPlugin.o
a - objs/src/CppUTest/SimpleString.o
a - objs/src/CppUTest/TestFailure.o
a - objs/src/CppUTest/TestFilter.o
a - objs/src/CppUTest/TestHarness_c.o
a - objs/src/CppUTest/TestMemoryAllocator.o
a - objs/src/CppUTest/TestOutput.o
a - objs/src/CppUTest/TestPlugin.o
a - objs/src/CppUTest/TestRegistry.o
a - objs/src/CppUTest/TestResult.o
a - objs/src/CppUTest/Utest.o
a - objs/src/Platforms/Gcc/UtestPlatform.o
Linking CppUTest_tests

ld: library not found for -lgcov
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [CppUTest_tests] Error 1

我发现可以使用llvm make命令进行构建

CC=/Applications/Xcode.app/Contents/Developer/usr/bin/llvm-gcc-4.2 make
Linking CppUTest_tests
Running CppUTest_tests
..................................................
..................................................
..................................................
..................................................
..................................................
...........................................
OK (293 tests, 293 ran, 791 checks, 0 ignored, 0 filtered out, 7 ms)

2)然后我进入示例目录。 我收到以下错误。 我试图进行调查,但找不到解决方法。 您的帮助将不胜感激。

compiling AllTests.cpp
compiling CircularBuffer.cpp
compiling CircularBufferTest.cpp
compiling EventDispatcher.cpp
compiling EventDispatcherTest.cpp
compiling HelloTest.cpp
compiling MockDocumentationTest.cpp
ApplicationLib/MockDocumentationTest.cpp:193:85: warning: expression result unused [-Wunused-value]
        mock_c()->actualCall("foo")->withIntParameters("integer", 10)->returnValue().value.doubleValue;
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~
1 warning generated.
compiling Printer.cpp
compiling PrinterTest.cpp
compiling hello.c
Building archive lib/libCppUTestExamples.a
ar: creating archive lib/libCppUTestExamples.a
a - objs/ApplicationLib/CircularBuffer.o
a - objs/ApplicationLib/CircularBufferTest.o
a - objs/ApplicationLib/EventDispatcher.o
a - objs/ApplicationLib/EventDispatcherTest.o
a - objs/ApplicationLib/HelloTest.o
a - objs/ApplicationLib/MockDocumentationTest.o
a - objs/ApplicationLib/Printer.o
a - objs/ApplicationLib/PrinterTest.o
a - objs/ApplicationLib/hello.o
Linking CppUTestExamples_tests
Undefined symbols for architecture x86_64:
  "_main", referenced from:
      start in crt1.10.6.o
  "mock(SimpleString const&)", referenced from:
      TEST_EventDispatcher_EventWithRegistrationForEventResultsIntoCallback_Test::testBody()      in libCppUTestExamples.a(EventDispatcherTest.o)
      TEST_EventDispatcher_RegisterTwoObserversResultIntoTwoCallsAndARegistrationNotification_Test::testBody()      in libCppUTestExamples.a(EventDispatcherTest.o)
      TEST_GROUP_CppUTestGroupEventDispatcher::setup()      in libCppUTestExamples.a(EventDispatcherTest.o)
      TEST_GROUP_CppUTestGroupEventDispatcher::teardown()      in libCppUTestExamples.a(EventDispatcherTest.o)
      ObserverMock::notify(Event const&, int)in libCppUTestExamples.a(EventDispatcherTest.o)
      ObserverMock::notifyRegistration(EventObserver*)        in libCppUTestExamples.a(EventDispatcherTest.o)
      productionCode()     in libCppUTestExamples.a(MockDocumentationTest.o)
      ...
  "MockNamedValue::getIntValue() const", referenced from:
      TEST_MockDocumentation_returnValue_Test::testBody()      in libCppUTestExamples.a(MockDocumentationTest.o)
      TEST_MockDocumentation_setData_Test::testBody()      in libCppUTestExamples.a(MockDocumentationTest.o)
  "MockNamedValue::~MockNamedValue()", referenced from:
      TEST_MockDocumentation_returnValue_Test::testBody()      in libCppUTestExamples.a(MockDocumentationTest.o)
      TEST_MockDocumentation_setData_Test::testBody()      in libCppUTestExamples.a(MockDocumentationTest.o)
  "MockSupport::setData(SimpleString const&, int)", referenced from:
      TEST_MockDocumentation_setData_Test::testBody()      in libCppUTestExamples.a(MockDocumentationTest.o)
  "MockSupport::setDataObject(SimpleString const&, SimpleString const&, void*)", referenced from:
      TEST_MockDocumentation_setData_Test::testBody()      in libCppUTestExamples.a(MockDocumentationTest.o)
  "MockSupport::getData(SimpleString const&)", referenced from:
      TEST_MockDocumentation_setData_Test::testBody()      in libCppUTestExamples.a(MockDocumentationTest.o)
  "MockNamedValue::getObjectPointer() const", referenced from:
      TEST_MockDocumentation_setData_Test::testBody()      in libCppUTestExamples.a(MockDocumentationTest.o)
  "_mock_c", referenced from:
      TEST_MockDocumentation_CInterface_Test::testBody()      in libCppUTestExamples.a(MockDocumentationTest.o)
  "_mock_scope_c", referenced from:
      TEST_MockDocumentation_CInterface_Test::testBody()      in libCppUTestExamples.a(MockDocumentationTest.o)
ld: symbol(s) not found for architecture x86_64

collect2: ld returned 1 exit status
make: *** [CppUTestExamples_tests] Error 1

我可以在运行Lion的Mac上找到CppUTest缺少的libgcov.a的位置。

/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/libgcov.a
/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/x86_64/libgcov.a

显然,这些位置不在加载程序的默认搜索路径中,因此将64位变体链接到/ usr / local / lib后,我可以轻松地制作CppUTest。

sudo ln -s /usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/x86_64/libgcov.a /usr/local/lib/libgcov.a

祝你好运

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM