IDE : Code::Blocks
tool chain : TDM-GCC-32 5.1.0
wxWidgets : 3.0.2 (SHARED=0 UNICODE=1 CXXFLAGS+="-std=gnu++11" for both release and debug), built with above tool chain
I have a minimal (according to Code::Blocks project wizard) frame based wxWidgets project. I am trying to follow some of the basic stuff outlined here for using wxStyledTextCtrl. When I build in release, it crashes upon running, but when I build in debug, it runs fine (or it seems to). I commented out everything relating to the wxStyledTextCtrl stuff except for the constructor, but it still crashes. Since it builds without error (and the only warnings are 177 wx deprecation warnings), it's not obvious to me what the error could be.
Release:
Code: Select all
-------------- Clean: Release in LogSearch (compiler: GNU GCC Compiler)---------------
Cleaned "LogSearch - Release"
-------------- Build: Release in LogSearch (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -Wall -std=c++11 -pipe -mthreads -Wno-deprecated-declarations -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -O2 -Wno-unused-local-typedefs -IC:\wxWidgets-3.0.2\include -IC:\wxWidgets-3.0.2\lib\gcc_lib\mswu -c C:\Users\me\Documents\Projects\LogSearch\LogSearchApp.cpp -o obj\Release\LogSearchApp.o
mingw32-g++.exe -Wall -std=c++11 -pipe -mthreads -Wno-deprecated-declarations -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -O2 -Wno-unused-local-typedefs -IC:\wxWidgets-3.0.2\include -IC:\wxWidgets-3.0.2\lib\gcc_lib\mswu -c C:\Users\me\Documents\Projects\LogSearch\LogSearchMain.cpp -o obj\Release\LogSearchMain.o
windres.exe -IC:\wxWidgets-3.0.2\include -IC:\wxWidgets-3.0.2\lib\gcc_lib\mswu -J rc -O coff -i C:\Users\me\DOCUME~1\Projects\LOGSEA~1\resource.rc -o obj\Release\resource.res
mingw32-g++.exe -LC:\wxWidgets-3.0.2\lib\gcc_lib -LC:\wxWidgets-3.0.2\lib\gcc_lib -o bin\Release\LogSearch.exe obj\Release\LogSearchApp.o obj\Release\LogSearchMain.o obj\Release\resource.res -s -mthreads -lwxmsw30u_stc -lwxscintilla -lwxmsw30u_aui -lwxmsw30u_core -lwxbase30u -lwxpng -lwxzlib -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -mwindows
Output file is bin\Release\LogSearch.exe with size 8.66 MB
Process terminated with status 0 (0 minute(s), 3 second(s))
0 error(s), 0 warning(s) (0 minute(s), 3 second(s))
Code: Select all
-------------- Clean: Debug in LogSearch (compiler: GNU GCC Compiler)---------------
Cleaned "LogSearch - Debug"
-------------- Build: Debug in LogSearch (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -Wall -std=c++11 -pipe -mthreads -Wno-deprecated-declarations -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -g -Wno-unused-local-typedefs -IC:\wxWidgets-3.0.2\include -IC:\wxWidgets-3.0.2\lib\gcc_lib\mswu -c C:\Users\me\Documents\Projects\LogSearch\LogSearchApp.cpp -o obj\Debug\LogSearchApp.o
mingw32-g++.exe -Wall -std=c++11 -pipe -mthreads -Wno-deprecated-declarations -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -g -Wno-unused-local-typedefs -IC:\wxWidgets-3.0.2\include -IC:\wxWidgets-3.0.2\lib\gcc_lib\mswu -c C:\Users\me\Documents\Projects\LogSearch\LogSearchMain.cpp -o obj\Debug\LogSearchMain.o
windres.exe -IC:\wxWidgets-3.0.2\include -IC:\wxWidgets-3.0.2\lib\gcc_lib\mswu -J rc -O coff -i C:\Users\me\DOCUME~1\Projects\LOGSEA~1\resource.rc -o obj\Debug\resource.res
mingw32-g++.exe -LC:\wxWidgets-3.0.2\lib\gcc_lib -LC:\wxWidgets-3.0.2\lib\gcc_lib -o bin\Debug\LogSearch.exe obj\Debug\LogSearchApp.o obj\Debug\LogSearchMain.o obj\Debug\resource.res -mthreads -lwxmsw30ud_stc -lwxscintillad -lwxmsw30ud_aui -lwxmsw30ud_core -lwxbase30ud -lwxpngd -lwxzlibd -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -mwindows
Output file is bin\Debug\LogSearch.exe with size 82.40 MB
Process terminated with status 0 (0 minute(s), 8 second(s))
0 error(s), 0 warning(s) (0 minute(s), 8 second(s))
For reference, here is the source file; I have added very little to the stuff auto-generated by Code::Blocks.
Code: Select all
#ifdef WX_PRECOMP
#include "wx_pch.h"
#endif
#ifdef __BORLANDC__
#pragma hdrstop
#endif //__BORLANDC__
#include "LogSearchMain.h"
//helper functions
enum wxbuildinfoformat {
short_f, long_f };
wxString wxbuildinfo(wxbuildinfoformat format)
{
wxString wxbuild(wxVERSION_STRING);
if (format == long_f )
{
#if defined(__WXMSW__)
wxbuild << _T("-Windows");
#elif defined(__WXMAC__)
wxbuild << _T("-Mac");
#elif defined(__UNIX__)
wxbuild << _T("-Linux");
#endif
#if wxUSE_UNICODE
wxbuild << _T("-Unicode build");
#else
wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
}
return wxbuild;
}
BEGIN_EVENT_TABLE(LogSearchFrame, wxFrame)
EVT_MENU(idMenuOpen, LogSearchFrame::OnOpen)
EVT_CLOSE(LogSearchFrame::OnClose)
EVT_MENU(idMenuQuit, LogSearchFrame::OnQuit)
EVT_MENU(idMenuAbout, LogSearchFrame::OnAbout)
END_EVENT_TABLE()
LogSearchFrame::LogSearchFrame(wxFrame *frame, const wxString& title)
: wxFrame(frame, -1, title)
{
#if wxUSE_MENUS
// create a menu bar
wxMenuBar* mbar = new wxMenuBar();
wxMenu* fileMenu = new wxMenu(_T(""));
fileMenu->Append(idMenuOpen, _("&Open\tCtrl-O"), _("Open"));
fileMenu->Append(idMenuQuit, _("&Quit\tAlt-F4"), _("Quit"));
mbar->Append(fileMenu, _("&File"));
wxMenu* helpMenu = new wxMenu(_T(""));
helpMenu->Append(idMenuAbout, _("&About\tF1"), _("Show info about this application"));
mbar->Append(helpMenu, _("&Help"));
SetMenuBar(mbar);
#endif // wxUSE_MENUS
#if wxUSE_STATUSBAR
// create a status bar with some information about the used wxWidgets version
CreateStatusBar(2);
SetStatusText(_("Hello!"),0);
SetStatusText(_("Powered by ") + wxbuildinfo(short_f), 1);
#endif // wxUSE_STATUSBAR
textarea = new wxStyledTextCtrl(this, idTextArea);
//textarea->SetMarginWidth(0, 25);
//textarea->SetMarginType(0, wxSTC_MARGIN_NUMBER);
//textarea->StyleSetForeground(wxSTC_STYLE_LINENUMBER, wxColor(0, 0, 0));
//textarea->StyleSetBackground(wxSTC_STYLE_LINENUMBER, wxColor(235, 235, 235));
//textarea->SetWrapMode(wxSTC_WRAP_WORD);
//textarea->SetText(_("Initial text here"));
//wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
//sizer->Add(textarea, 1, wxEXPAND);
//SetSizer(sizer);
}
LogSearchFrame::~LogSearchFrame()
{
}
void LogSearchFrame::OnOpen(wxCommandEvent &event)
{
}
void LogSearchFrame::OnClose(wxCloseEvent &event)
{
Destroy();
}
void LogSearchFrame::OnQuit(wxCommandEvent &event)
{
Destroy();
}
void LogSearchFrame::OnAbout(wxCommandEvent &event)
{
wxString msg = wxbuildinfo(long_f);
wxMessageBox(msg, _("Welcome to..."));
}
Code: Select all
#ifndef LOGSEARCHMAIN_H
#define LOGSEARCHMAIN_H
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include "LogSearchApp.h"
#include <wx/stc/stc.h>
class LogSearchFrame: public wxFrame
{
public:
LogSearchFrame(wxFrame *frame, const wxString& title);
~LogSearchFrame();
private:
enum
{
idMenuOpen = 1000,
idMenuQuit,
idMenuAbout,
idTextArea
};
wxStyledTextCtrl* textarea;
void OnOpen(wxCommandEvent& event);
void OnClose(wxCloseEvent& event);
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
#endif // LOGSEARCHMAIN_H
Code: Select all
textarea = new wxStyledTextCtrl(this, idTextArea);