[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Mingw-cross-env-list] gcc 4.7.0, -std=c++11 and wxWidgets
From: |
Moritz Bunkus |
Subject: |
[Mingw-cross-env-list] gcc 4.7.0, -std=c++11 and wxWidgets |
Date: |
Sat, 14 Apr 2012 23:25:44 +0200 |
Hey,
I've just spent the past three hours figuring out why my program
suddenly segfaults. It seems that using experimental features is
really just that, experimental. Oh well.
My project requires C++11 support. This has worked just fine so far
with gcc 4.6.x but fails miserably with 4.7.0 and wxWidgets. I've
boilt it down to this small sample program:
-----------------
#undef __STRICT_ANSI__
#include <wx/wx.h>
#include <iostream>
#include <wx/menu.h>
#include <wx/string.h>
#define ID_M_FILE_NEW 12345
int main() {
std::cout << "1\n";
const wxString dummy(L"dummy");
std::cout << "2\n";
wxMenu *file_menu = new wxMenu();
std::cout << "3\n";
file_menu->Append(ID_M_FILE_NEW, dummy);
std::cout << "4\n";
return 0;
}
------------------
Command line used for compilation:
i686-pc-mingw32-g++ -Wall -o test2.exe $(i686-pc-mingw32-wx-config
--cflags) test2.cpp $(i686-pc-mingw32-wx-config --libs | sed -e
's/-mwindows//' -e 's/-Wl,--subsystem,windows//')
Compiled with today's MXE (meaning wxWidgets 2.8.12 and gcc 4.7.0) in
"normal" mode it's just fine and executes just fine. Compiled in C++11
mode (by simply adding "-std=c++11") it crashes between 3 and 4 --
whenever a wxString object is used.
I've found these two fine threads about ABI incompatibility:
http://gcc.gnu.org/ml/gcc/2011-10/msg00113.html (gcc in general) and
https://groups.google.com/group/wx-users/browse_thread/thread/e4cae9eb10615384?pli=1
(wxWidgets in particular). It seems that mixing code compiled without
-std=c++11 and code compiled with it will simply not work anymore.
Unfortunately "not work" neither implies that it doesn't compile or
link -- it does! It simply segfaults or does other fancy stuff. I ( =
configure) cannot even detect whether or not a library has been
compiled with C++11 support.
So what this means to me: I'm screwed and will have to stay with gcc
4.6.x until there's at least an ABI change.
So let's make this relevant to MXE. Can I simply downgrade gcc by
changing the download link (and re-compiling everything afterwards, of
course)? Or was there more involved, e.g. a lot of patches etc?
Kind regards,
mo
- [Mingw-cross-env-list] gcc 4.7.0, -std=c++11 and wxWidgets,
Moritz Bunkus <=