Search code examples
c++macoswxwidgets

wxWidgets 3.1.0 and Mac OS X El Capitan (10.11)


Are there any known issues using wxWidgets 3.1.0 on Mac OS X El Capitan (10.11)? I was able to compile it without issues and my imports are resolving (no build errors) for my sample application, but upon launching I get an instant segmentation fault. I'm trying to run the minimal sample provided in the documentation. It builds without any errors but when ran, it immediately crashes.

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000001

The error shown by the system for thread 0:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libstdc++.6.dylib               0x00007fff932ee71a std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::assign(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&) + 26
1   libwx_osx_cocoau_core-3.1.dylib 0x0000000109eee003 wxNonOwnedWindow::Create(wxWindow*, int, wxPoint const&, wxSize const&, long, wxString const&) + 67
2   libwx_osx_cocoau_core-3.1.dylib 0x0000000109ef2321 wxTopLevelWindowMac::Create(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxString const&) + 49
3   WxTestApp                       0x0000000109eb7aec wxFrame::wxFrame(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxString const&) + 140 (frame.h:35)
4   WxTestApp                       0x0000000109eb7501 MyFrame::MyFrame(wxString const&) + 129 (main.cpp:145)
5   WxTestApp                       0x0000000109eb744d MyFrame::MyFrame(wxString const&) + 29 (main.cpp:180)
6   WxTestApp                       0x0000000109eb7366 MyApp::OnInit() + 102 (main.cpp:127)
7   libwx_osx_cocoau_core-3.1.dylib 0x0000000109ee962e wxApp::CallOnInit() + 158
8   libwx_baseu-3.1.dylib           0x000000010a5d1bf9 wxEntry(int&, wchar_t**) + 121
9   WxTestApp                       0x0000000109eb7216 main + 38 (main.cpp:108)
10  libdyld.dylib                   0x00007fff998c25ad start + 1

Line 108 of main.cpp is:

wxIMPLEMENT_APP(MyApp);

Is this a known issue or is there something that needs to be tweaked from the minimal sample provided in the documentation? I'm wondering if it might have to do with the System Integrity Protection security feature.


Solution

  • wxWidgets 3.1.0 definitely does work on macOS 10.11, this looks like a build problem because there is just no reason whatsoever for the code to crash in std::string::assign().

    You mention that you built the minimal sample using CMake. I don't know how exactly did you do it, as we don't provide CMakefiles for the samples (yet, anyhow), but building it using simple make -C samples/minimal in the build directory should definitely work.

    BTW, it looks like you built directly in the source directory. This should still work but it's easy to make a mistake (and not easy to find it) if you do it like this, so I strongly recommend to build in a separate build directory, e.g. mkdir -p ~/build/wx-3.1.0 && cd $_ && ~/src/wx/3.1.0/configure && make (assuming you have your sources in this directory, of course).