为什么我会收到“ld: in libUnitTest++.a,存档没有目录”?构建 UnitTest 时++在 Mac OS X 上?
下载 UnitTest++ 版本 1.4 后(来自 http://sourceforge.net/projects/unittest-cpp/) 并执行 make,我得到:
$ make
src/AssertException.cpp
src/Test.cpp
src/Checks.cpp
src/TestRunner.cpp
src/TestResults.cpp
src/TestReporter.cpp
src/TestReporterStdout.cpp
src/ReportAssert.cpp
src/TestList.cpp
src/TimeConstraint.cpp
src/TestDetails.cpp
src/MemoryOutStream.cpp
src/DeferredTestReporter.cpp
src/DeferredTestResult.cpp
src/XmlTestReporter.cpp
src/CurrentTest.cpp
src/Posix/SignalTranslator.cpp
src/Posix/TimeHelpers.cpp
Creating libUnitTest++.a library...
src/tests/Main.cpp
src/tests/TestAssertHandler.cpp
src/tests/TestChecks.cpp
src/tests/TestUnitTest++.cpp
src/tests/TestTest.cpp
src/tests/TestTestResults.cpp
src/tests/TestTestRunner.cpp
src/tests/TestCheckMacros.cpp
src/tests/TestTestList.cpp
src/tests/TestTestMacros.cpp
src/tests/TestTimeConstraint.cpp
src/tests/TestTimeConstraintMacro.cpp
src/tests/TestMemoryOutStream.cpp
src/tests/TestDeferredTestReporter.cpp
src/tests/TestXmlTestReporter.cpp
src/tests/TestCurrentTest.cpp
Linking TestUnitTest++...
ld: in libUnitTest++.a, archive has no table of contents
collect2: ld returned 1 exit status
make: *** [TestUnitTest++] Error 1
一位同事在使用相同版本的 gcc (4.2.1) 的 Mac 上没有出现此错误。 (注意:我可以使用我的同事构建的 libUnitTest++.a,所以我没有被阻止,但我仍然想解决这个问题。)
我做了一个 Google 搜索,听起来 ranlib
已经解决了其他人的类似问题,但是 libUnitTest++.a 没有创建,所以我无法运行ranlib
就可以了。
After I download UnitTest++ version 1.4 (from http://sourceforge.net/projects/unittest-cpp/) and do a make, I get:
$ make
src/AssertException.cpp
src/Test.cpp
src/Checks.cpp
src/TestRunner.cpp
src/TestResults.cpp
src/TestReporter.cpp
src/TestReporterStdout.cpp
src/ReportAssert.cpp
src/TestList.cpp
src/TimeConstraint.cpp
src/TestDetails.cpp
src/MemoryOutStream.cpp
src/DeferredTestReporter.cpp
src/DeferredTestResult.cpp
src/XmlTestReporter.cpp
src/CurrentTest.cpp
src/Posix/SignalTranslator.cpp
src/Posix/TimeHelpers.cpp
Creating libUnitTest++.a library...
src/tests/Main.cpp
src/tests/TestAssertHandler.cpp
src/tests/TestChecks.cpp
src/tests/TestUnitTest++.cpp
src/tests/TestTest.cpp
src/tests/TestTestResults.cpp
src/tests/TestTestRunner.cpp
src/tests/TestCheckMacros.cpp
src/tests/TestTestList.cpp
src/tests/TestTestMacros.cpp
src/tests/TestTimeConstraint.cpp
src/tests/TestTimeConstraintMacro.cpp
src/tests/TestMemoryOutStream.cpp
src/tests/TestDeferredTestReporter.cpp
src/tests/TestXmlTestReporter.cpp
src/tests/TestCurrentTest.cpp
Linking TestUnitTest++...
ld: in libUnitTest++.a, archive has no table of contents
collect2: ld returned 1 exit status
make: *** [TestUnitTest++] Error 1
A co-worker doesn't get this error on his Mac, with the same version of gcc (4.2.1). (Note: I can use the libUnitTest++.a built by my co-worker, so I'm not blocked, but I would like to troubleshoot this problem nonetheless.)
I did a Google search, and it sounds like ranlib
has solved others' similar problems, but libUnitTest++.a isn't getting created so I can't run ranlib
on it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己也遇到过这个问题,您需要在 .a 文件上运行 ranlib,然后再将其传递给 g++。我已经在自制程序配方中对此进行了修补,请享受:
https ://github.com/pdex/homebrew/blob/master/Library/Formula/unittest-cpp.rb
I've run into this problem myself, you need to run ranlib on the .a file before passing it along to g++. I've patched this in a homebrew recipe, enjoy:
https://github.com/pdex/homebrew/blob/master/Library/Formula/unittest-cpp.rb