我正在尝试为使用 CMake 的 C++11 库编译测试。我在 Ubuntu 上使用 UnitTest++ 和 C++11 取得了成功,但是 Mac OS X 给了我链接器错误。
在 CMake 中,我的 APPLE 链接器标志和库如下所示:
SET(CMAKE_CXX_FLAGS "--stdlib=libc++ --std=c++11")
TARGET_LINK_LIBRARIES(mytest unittest++)
用这个编译会给我链接器错误,例如:
Undefined symbols for architecture x86_64:
"std::string::c_str() const", referenced from:
UnitTest::MemoryOutStream::GetText() const in libunittest++.a(MemoryOutStream.o)
"std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::str() const", referenced from:
UnitTest::MemoryOutStream::GetText() const in libunittest++.a(MemoryOutStream.o)
"std::ostream::~std::ostream()", referenced from:
construction vtable for std::ostream-in-UnitTest::MemoryOutStream in libunittest++.a(TestRunner.o)
construction vtable for std::ostream-in-UnitTest::MemoryOutStream in libunittest++.a(Test.o)
....
这是完整的粘贴。