Closed claremacrae closed 4 years ago
This is much less helpful than the old "You have forgotten to configure your main", unfortunately.
The linker output on Mac with clang-9 is:
Undefined symbols for architecture x86_64:
"ApprovalTests::FileApprover::verify(ApprovalTests::ApprovalNamer const&, ApprovalTests::ApprovalWriter const&, ApprovalTests::Reporter const&)", referenced from:
ApprovalTests::TApprovals<ApprovalTests::ToStringCompileTimeOptions<ApprovalTests::StringMaker> >::verify(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, ApprovalTests::Options const&) in HelloApprovalsTests.cpp.o
"ApprovalTests::StringWriter::StringWriter(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
ApprovalTests::TApprovals<ApprovalTests::ToStringCompileTimeOptions<ApprovalTests::StringMaker> >::verify(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, ApprovalTests::Options const&) in HelloApprovalsTests.cpp.o
"ApprovalTests::DefaultNamerFactory::getDefaultNamer()", referenced from:
ApprovalTests::TApprovals<ApprovalTests::ToStringCompileTimeOptions<ApprovalTests::StringMaker> >::getDefaultNamer() in HelloApprovalsTests.cpp.o
"ApprovalTests::Options::defaultReporter()", referenced from:
ApprovalTests::Options::Options() in HelloApprovalsTests.cpp.o
"ApprovalTests::Scrubbers::doNothing(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
ApprovalTests::Options::Options() in HelloApprovalsTests.cpp.o
"ApprovalTests::Options::FileOptions::getFileExtension() const", referenced from:
ApprovalTests::TApprovals<ApprovalTests::ToStringCompileTimeOptions<ApprovalTests::StringMaker> >::verify(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, ApprovalTests::Options const&) in HelloApprovalsTests.cpp.o
"ApprovalTests::Options::fileOptions() const", referenced from:
ApprovalTests::TApprovals<ApprovalTests::ToStringCompileTimeOptions<ApprovalTests::StringMaker> >::verify(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, ApprovalTests::Options const&) in HelloApprovalsTests.cpp.o
"ApprovalTests::Options::getReporter() const", referenced from:
ApprovalTests::TApprovals<ApprovalTests::ToStringCompileTimeOptions<ApprovalTests::StringMaker> >::verify(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, ApprovalTests::Options const&) in HelloApprovalsTests.cpp.o
"ApprovalTests::Options::scrub(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
ApprovalTests::TApprovals<ApprovalTests::ToStringCompileTimeOptions<ApprovalTests::StringMaker> >::verify(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, ApprovalTests::Options const&) in HelloApprovalsTests.cpp.o
"vtable for ApprovalTests::StringWriter", referenced from:
ApprovalTests::StringWriter::~StringWriter() in HelloApprovalsTests.cpp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is fixed by:
(it will be included in the next release)
It turns out that builds that link against the ApprovalTests.cpp source tree - such as via CMake's FetchContent
- still give the help message if main is not configured.
It's only the builds with the single-header that give missing symbol linker-errors instead.
I got this output on Windows in Visual Studio when building against v.10.1.1, and having not updated my main.
This is a change from the old "you have forgotten to set up your main" output...
This is because those functions are now implemented code that is only compiled when the Approved code in main() is activated via the preprocessor...
We just need to update the Troubleshooting doc to describe this.