2

我是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)然后我 cd 到示例目录。我收到以下错误。我试图调查,但找不到解决方法。您的帮助将不胜感激。

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
4

1 回答 1

6

我能够在运行 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

祝你好运

于 2012-04-19T12:07:26.397 回答