Program exe release not working Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
RigelBlack
In need of some credit
In need of some credit
Posts: 5
Joined: Sat Oct 13, 2018 11:42 am

Program exe release not working

Post by RigelBlack » Sat Oct 13, 2018 12:48 pm

Hi guys, I have a question on you. I wrote a little program to help me with some editing of a long txt file. I wrote it in Code:Blocks 13.12 using WxWidgets. Here is my code:

Code: Select all

/***************************************************************
 * Name:      WxWMain.cpp
 * Purpose:   Code for Application Frame
 * Author:     ()
 * Created:   2016-01-15
 * Copyright:  ()
 * License:
 **************************************************************/

#include "wx_pch.h"
#include "WxWMain.h"
#include <wx/msgdlg.h>
#include <wx/textfile.h>

//(*InternalHeaders(WxWFrame)
#include <wx/intl.h>
#include <wx/string.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(__UNIX__)
        wxbuild << _T("-Linux");
#endif

#if wxUSE_UNICODE
        wxbuild << _T("-Unicode build");
#else
        wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
    }

    return wxbuild;
}

//(*IdInit(WxWFrame)
const long WxWFrame::ID_STATICTEXT1 = wxNewId();
const long WxWFrame::ID_TEXTCTRL1 = wxNewId();
const long WxWFrame::ID_TOGGLEBUTTON1 = wxNewId();
const long WxWFrame::ID_PANEL1 = wxNewId();
const long WxWFrame::idMenuQuit = wxNewId();
const long WxWFrame::idMenuAbout = wxNewId();
//*)

BEGIN_EVENT_TABLE(WxWFrame,wxFrame)
    //(*EventTable(WxWFrame)
    //*)
END_EVENT_TABLE()

WxWFrame::WxWFrame(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(WxWFrame)
    wxMenuItem* MenuItem2;
    wxMenuItem* MenuItem1;
    wxMenu* Menu1;
    wxMenuBar* MenuBar1;
    wxMenu* Menu2;

    Create(parent, wxID_ANY, _("Konverter"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("wxID_ANY"));
    SetClientSize(wxSize(1000,680));
    Panel1 = new wxPanel(this, ID_PANEL1, wxPoint(320,336), wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
    StaticText1 = new wxStaticText(Panel1, ID_STATICTEXT1, _("Vyber soubor urceny k prepisu do matice"), wxPoint(376,16), wxDefaultSize, 0, _T("ID_STATICTEXT1"));
    TextCtrl1 = new wxTextCtrl(Panel1, ID_TEXTCTRL1, wxEmptyString, wxPoint(16,80), wxSize(968,560), wxTE_MULTILINE|wxTE_READONLY|wxVSCROLL|wxHSCROLL|wxALWAYS_SHOW_SB, wxDefaultValidator, _T("ID_TEXTCTRL1"));
    ToggleButton1 = new wxToggleButton(Panel1, ID_TOGGLEBUTTON1, _("Nacist soubor"), wxPoint(448,40), wxDefaultSize, 0, wxDefaultValidator, _T("ID_TOGGLEBUTTON1"));
    MenuBar1 = new wxMenuBar();
    Menu1 = new wxMenu();
    MenuItem1 = new wxMenuItem(Menu1, idMenuQuit, _("Quit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
    Menu1->Append(MenuItem1);
    MenuBar1->Append(Menu1, _("&File"));
    Menu2 = new wxMenu();
    MenuItem2 = new wxMenuItem(Menu2, idMenuAbout, _("About\tF1"), _("Show info about this application"), wxITEM_NORMAL);
    Menu2->Append(MenuItem2);
    MenuBar1->Append(Menu2, _("Help"));
    SetMenuBar(MenuBar1);

    Connect(ID_TOGGLEBUTTON1,wxEVT_COMMAND_TOGGLEBUTTON_CLICKED,(wxObjectEventFunction)&WxWFrame::OnToggleButton1Toggle);
    Connect(idMenuQuit,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&WxWFrame::OnQuit);
    Connect(idMenuAbout,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&WxWFrame::OnAbout);
    //*)
}

WxWFrame::~WxWFrame()
{
    //(*Destroy(WxWFrame)
    //*)
}
void WxWFrame::OnQuit(wxCommandEvent& event)
{
    Close();
}

void WxWFrame::OnAbout(wxCommandEvent& event)
{
    wxString msg = wxbuildinfo(long_f);
    wxMessageBox(msg, _("Welcome to..."));
}

void WxWFrame::OnToggleButton1Toggle(wxCommandEvent& event)
{
    TextCtrl1->SetValue("");
    wxString        file;
    wxFileDialog    fdlog(this, _("Otevrit TXT soubor"), "", "",
                       "koncovka TXT (*.txt)|*.txt", wxFD_OPEN|wxFD_FILE_MUST_EXIST);

    if(fdlog.ShowModal() != wxID_OK) return;
    file.Clear();
    file = fdlog.GetPath();

    wxString str;

    wxTextFile tfile;
    tfile.Open(file);
    size_t num = tfile.GetLineCount();
    size_t cnt = 0;

    str = tfile.GetFirstLine();

    while(!tfile.Eof())
    {
        cnt++;
        str = tfile.GetNextLine();
        if (cnt == num-1) str = "\""+str+"\"";
        else str = "\""+str+"\",";
        str.Replace(wxT("\t"),wxT(""));
        TextCtrl1->WriteText("\r\n");
        if (str != "\"\",") TextCtrl1->WriteText(str);
    }
}
When I click Build and Run, everything works fine. But when I go to the Debug or Release folder, where the .exe is located, and start to run it from there, I get an error, which says, that the code cannot be run, because wxbase30u_gcc471TDM.dll and wxmsw30u_core_gcc471TDM.dll was not found. So if I want to run that program, I have to open Code:blocks every time and hit Build and Run, which is pretty annoying.

So my question is - how can I add necessary dlls to the final release in order to function without Code:blocks installed? Or is there any other way around this?

I would be thankful for any help :)

catalin
Moderator
Moderator
Posts: 1497
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: Program exe release not working

Post by catalin » Sat Oct 13, 2018 1:10 pm

Copy the required dll-s next to your exe.

RigelBlack
In need of some credit
In need of some credit
Posts: 5
Joined: Sat Oct 13, 2018 11:42 am

Re: Program exe release not working

Post by RigelBlack » Sat Oct 13, 2018 1:31 pm

Thank you :) Solved.

Post Reply