LyX fails to build on macos (Mojave, CMake, XCode) with the latest commit (01ee3bf1f5) with message:

Undefined symbols for architecture x86_64:
"boost::assertion_failed_msg(char const*, char const*, char const*, char const*, long)", referenced from: boost::array<unsigned int, 256ul>::operator[](unsigned long) in ConverterCache.o boost::array<unsigned int, 256ul>::operator[](unsigned long) in libfrontend_qt.a(GuiApplication.o) boost::array<unsigned int, 256ul>::operator[](unsigned long) in libsupport.a(FileName.o) boost::array<unsigned int, 256ul>::operator[](unsigned long) in libfrontend_qt.a(GuiClipboard.o)

From the boost docs (https://www.boost.org/doc/libs/1_68_0/libs/assert/doc/html/assert.html) it's clear that boost::assertion_failed_msg() must be defined, ...

If the macro BOOST_ENABLE_ASSERT_HANDLER is defined when <boost/assert.hpp> is included, BOOST_ASSERT_MSG(expr,msg) expands to

(BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed_msg(#expr,
    msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
This is true regardless of whether NDEBUG is defined.

boost::assertion_failed_msg is declared in <boost/assert.hpp> as

namespace boost
{
    void assertion_failed_msg(char const * expr, char const * msg,
        char const * function, char const * file, long line);
}
but it is never defined. The user is expected to supply an appropriate definition.

... which is not the case now, and BOOST_ASSERT_MSG is defined in boost::array.hpp.

I've defined the additional function assertion_failed_msg()in boost.cpp (patch attached) and this resolves the problem.

Two more remarks:

1) I don't understand why this problem surfaces now and not earlier;

2) There are additional definitions of assertion_failed() in client/boost.cpp and in tex2lyx/boost.cpp;

Patrick
diff --git a/src/boost.cpp b/src/boost.cpp
index 7ae7433a1b..fd24ef5832 100644
--- a/src/boost.cpp
+++ b/src/boost.cpp
@@ -46,5 +46,19 @@ void assertion_failed(char const * expr, char const * 
function,
        // FIXME: do we have a list of exit codes defined somewhere?
        lyx::lyx_exit(1);
 }
+       
+void assertion_failed_msg(char const * expr, char const * msg, char const * 
function,
+                                         char const * file, long line)
+{
+       lyxerr << "Assertion triggered in " << function
+       << " by failing check \"" << expr << "\""
+       << " in file " << file
+       << " with error message \"" << msg << "\":" << line << endl;
+       
+       // FIXME: by default we exit here but we could also inform the user
+       // about the assertion and do the emergency cleanup without exiting.
+       // FIXME: do we have a list of exit codes defined somewhere?
+       lyx::lyx_exit(1);
+}
 
 } // namespace boost

Reply via email to