Console is shown at startup Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
Klaus82
Experienced Solver
Experienced Solver
Posts: 52
Joined: Tue Nov 09, 2010 8:58 am

Console is shown at startup

Post by Klaus82 »

I have the problem that the console is always shown on startup before the wxFrame is shown.

When I compile the shipped minimal sample, it does NOT show the console at startup, but when I write an own application (see code below), the console is shown before the wxFrame is visible. It looks like a wxAppConsole which creates a wxFrame.

Do I have to add a define or something else?

CMakeLists.txt

Code: Select all

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.1)

#add required wxWidgets lib
FIND_PACKAGE(wxWidgets COMPONENTS core base REQUIRED)  # it is essential that 'core' is mentioned before 'base'.
INCLUDE(${wxWidgets_USE_FILE})

# build executable 
ADD_EXECUTABLE(Minimal minimal.cpp)

# linked libraries
TARGET_LINK_LIBRARIES(Minimal ${wxWidgets_LIBRARIES} )
minimal.cpp

Code: Select all

#include <wx/wx.h>

class MyApp : public wxApp
{
public:
    virtual bool OnInit();
};

class MyFrame : public wxFrame
{
public:
    MyFrame(const wxString& title);
};

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
   if ( !wxApp::OnInit() )
        return false;
    MyFrame *frame = new MyFrame("Minimal wxWidgets App");
    frame->Show(true);
    return true;
}

MyFrame::MyFrame(const wxString& title)
       : wxFrame(NULL, wxID_ANY, title)
{
    
}
Build:

Code: Select all

cmake -G"MinGW Makefiles"
mingw32-make
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Console is shown at startup

Post by PB »

Have you tried adding -mwindows to the linker flags?
Klaus82
Experienced Solver
Experienced Solver
Posts: 52
Joined: Tue Nov 09, 2010 8:58 am

Re: Console is shown at startup

Post by Klaus82 »

That was the problem. I added the linker flag to my cmake file:

Code: Select all

SET(CMAKE_EXE_LINKER_FLAGS "-mwindows")
Thanks a lot.
Post Reply