Migrating to Linux (Mint)

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
Ksawery
Experienced Solver
Experienced Solver
Posts: 83
Joined: Thu Jul 25, 2019 12:31 pm

Migrating to Linux (Mint)

Post by Ksawery »

Hello,

I have successfully built and debugged my wxWidgets GUI under Windows 10, Visual Studio 2019. I'm now attempting to migrate my project to Linux Mint. Unfortunately I'm seeing complication errors. Here are the steps that I have taken so far:
  • Tested the installation using the samples provided.
  • Installed Code::Blocks along with the wxSmith plugin.
  • Created a new wxWidgets project (3.0.x was the latest version avialable in the options) and imported my project files.
  • Added the `wx-config --cxxflags` and `wx-config --libs` compiler flags to the Project Build Options.
  • Checked that the IDE does indeed see the wxWidgets header files (and other dependencies in my project).
Initially I was getting compilation errors relating to the BOOL variable being declared. I think that this #define exists only in the Windows version of wxWidgets? Anyhow, I replaced all instances of BOOL with bool. Now I'm seeing several compilation errors relating to wxWidgets macros. I'm posting the list of errors below:

Code: Select all

||=== Build: Debug in PomiarWiazki_wxWidgets_Linux (compiler: GNU GCC Compiler) ===|
/home/ksawery/repos/PomiarWiazki_wxWidgets_Linux/PomiarWiazki_wxWidgets_Linux/cApp.h|2|warning: ignoring #pragma warning  [-Wunknown-pragmas]|
/home/ksawery/repos/PomiarWiazki_wxWidgets_Linux/PomiarWiazki_wxWidgets_Linux/cMain.h|2|warning: ignoring #pragma warning  [-Wunknown-pragmas]|
/home/ksawery/repos/PomiarWiazki_wxWidgets_Linux/PomiarWiazki_wxWidgets_Linux/cDiagnostics.h|2|warning: ignoring #pragma warning  [-Wunknown-pragmas]|
/home/ksawery/repos/PomiarWiazki_wxWidgets_Linux/PomiarWiazki_wxWidgets_Linux/cInformation.h|2|warning: ignoring #pragma warning  [-Wunknown-pragmas]|
/home/ksawery/repos/PomiarWiazki_wxWidgets_Linux/PomiarWiazki_wxWidgets_Linux/cDiagnostics.h|2|warning: ignoring #pragma warning  [-Wunknown-pragmas]|
/home/ksawery/repos/PomiarWiazki_wxWidgets_Linux/PomiarWiazki_wxWidgets_Linux/cDiagnostics.cpp|4|error: ISO C++ forbids taking the address of a bound member function to form a pointer to member function.  Say ‘&cDiagnostics::OnButtonClickedReset’ [-fpermissive]|
/usr/local/include/wx-3.1/wx/event.h|91|note: in definition of macro ‘wxDECLARE_EVENT_TABLE_ENTRY’|
/usr/local/include/wx-3.1/wx/event.h|4381|note: in expansion of macro ‘wx__DECLARE_EVT2’|
/usr/local/include/wx-3.1/wx/event.h|4577|note: in expansion of macro ‘wx__DECLARE_EVT1’|
/usr/local/include/wx-3.1/wx/event.h|4144|note: in expansion of macro ‘wxEVENT_HANDLER_CAST’|
/usr/local/include/wx-3.1/wx/event.h|4577|note: in expansion of macro ‘wxCommandEventHandler’|
/home/ksawery/repos/PomiarWiazki_wxWidgets_Linux/PomiarWiazki_wxWidgets_Linux/cDiagnostics.cpp|4|note: in expansion of macro ‘EVT_BUTTON’|
/home/ksawery/repos/PomiarWiazki_wxWidgets_Linux/PomiarWiazki_wxWidgets_Linux/cDiagnostics.cpp|5|error: ISO C++ forbids taking the address of a bound member function to form a pointer to member function.  Say ‘&cDiagnostics::OnDiagnosticsResetTimer’ [-fpermissive]|
/usr/local/include/wx-3.1/wx/event.h|91|note: in definition of macro ‘wxDECLARE_EVENT_TABLE_ENTRY’|
/usr/local/include/wx-3.1/wx/event.h|4381|note: in expansion of macro ‘wx__DECLARE_EVT2’|
/usr/local/include/wx-3.1/wx/timer.h|192|note: in expansion of macro ‘wx__DECLARE_EVT1’|
/usr/local/include/wx-3.1/wx/timer.h|189|note: in expansion of macro ‘wxEVENT_HANDLER_CAST’|
/usr/local/include/wx-3.1/wx/timer.h|192|note: in expansion of macro ‘wxTimerEventHandler’|
/home/ksawery/repos/PomiarWiazki_wxWidgets_Linux/PomiarWiazki_wxWidgets_Linux/cDiagnostics.cpp|5|note: in expansion of macro ‘EVT_TIMER’|
/home/ksawery/repos/PomiarWiazki_wxWidgets_Linux/PomiarWiazki_wxWidgets_Linux/cDiagnostics.cpp|6|error: ISO C++ forbids taking the address of a bound member function to form a pointer to member function.  Say ‘&cDiagnostics::OnClose’ [-fpermissive]|
/usr/local/include/wx-3.1/wx/event.h|91|note: in definition of macro ‘wxDECLARE_EVENT_TABLE_ENTRY’|
/usr/local/include/wx-3.1/wx/event.h|4381|note: in expansion of macro ‘wx__DECLARE_EVT2’|
/usr/local/include/wx-3.1/wx/event.h|4383|note: in expansion of macro ‘wx__DECLARE_EVT1’|
/usr/local/include/wx-3.1/wx/event.h|4412|note: in expansion of macro ‘wx__DECLARE_EVT0’|
/usr/local/include/wx-3.1/wx/event.h|4185|note: in expansion of macro ‘wxEVENT_HANDLER_CAST’|
/usr/local/include/wx-3.1/wx/event.h|4412|note: in expansion of macro ‘wxCloseEventHandler’|
/home/ksawery/repos/PomiarWiazki_wxWidgets_Linux/PomiarWiazki_wxWidgets_Linux/cDiagnostics.cpp|6|note: in expansion of macro ‘EVT_CLOSE’|
/home/ksawery/repos/PomiarWiazki_wxWidgets_Linux/PomiarWiazki_wxWidgets_Linux/cDiagnostics.cpp||In constructor ‘cDiagnostics::cDiagnostics(const uint8_t*, const char*, int, bool*, bool*, bool*, bool*, bool*, int32_t*, int32_t*, uint16_t*, uint16_t*, wxMenu*)’:|
/usr/local/include/wx-3.1/wx/chartype.h|225|error: converting to execution character set: Invalid or incomplete multibyte or wide character|
/usr/local/include/wx-3.1/wx/cpp.h|18|note: in definition of macro ‘wxCONCAT_HELPER’|
/home/ksawery/repos/PomiarWiazki_wxWidgets_Linux/PomiarWiazki_wxWidgets_Linux/cDiagnostics.cpp|97|note: in expansion of macro ‘wxT’|
||=== Build failed: 4 error(s), 5 warning(s) (0 minute(s), 4 second(s)) ===|
Any help would be greatly appreciated.

Regards,
Ksawery
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Migrating to Linux (Mint)

Post by DavidHart »

Hi,

I've not previously seen that error message from an event table, so it's not a standard Linux issue. (OTOH if you were using Bind() it would be happening because your compiler can't cope with 'cDiagnostics::OnClose' as its second parameter; it wants '&cDiagnostics::OnClose'.)

Can you post the relevant event table(s) and event handler signatures?

Regards,

David
Ksawery
Experienced Solver
Experienced Solver
Posts: 83
Joined: Thu Jul 25, 2019 12:31 pm

Re: Migrating to Linux (Mint)

Post by Ksawery »

Thank you for your reply. Here is the event table:

Code: Select all

wxBEGIN_EVENT_TABLE(cDiagnostics, wxFrame)
	EVT_BUTTON(10003, OnButtonClickedReset)
	EVT_TIMER(10005, OnDiagnosticsResetTimer)
	EVT_CLOSE(OnClose)
wxEND_EVENT_TABLE()
And here are the event handlers:

Code: Select all

void cDiagnostics::OnButtonClickedReset(wxCommandEvent& evt)
{
	if (m_btn_reset->IsEnabled()) m_btn_reset->Disable(); //disable reset button
	*this->mbDiagnosticsResetEnabled = TRUE; //signal Modbus thread to reset counters
	*this->mbDiagnosticsResetting = TRUE; //wait for Modbus thread to indicate reset message has been sent
	mbDiagnosticsResetPressed = TRUE;
}

void cDiagnostics::OnDiagnosticsResetTimer(wxTimerEvent& evt)
{
	m_static_txt_diag_error->Hide();
}

void cDiagnostics::OnClose(wxCloseEvent&)
{
	//Stop timer
	if (mbDiagnosticsResetTimer->IsRunning()) mbDiagnosticsResetTimer->Stop();

	//Delete helper thread
	if (GetThread() && GetThread()->IsRunning()) GetThread()->Delete();

	*this->mbDiagnosticsWindowIsOpen = FALSE; //signal Modbus thread that diagnostics window is no longer open
	*this->mbDiagnosticsEnabled = FALSE; //signal Modbus thread to stop reading diagnostics
	*this->mbDiagnosticsAvailable = FALSE;

	//Re-enable diagnostics menu item
	if (!(m_pToolsMenu->IsEnabled(wxID_VIEW_DETAILS))) m_pToolsMenu->Enable(wxID_VIEW_DETAILS, TRUE);

	Destroy();
}
Regards,
Ksawery
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Migrating to Linux (Mint)

Post by DavidHart »

I was about to say that I couldn't see anything wrong with the code. Fortunately I first googled the error message and found this thread.

Your event table entries should be e.g.
EVT_BUTTON(10003, cDiagnostics::OnButtonClickedReset)

Presumably compilers on the other OSes are less fussy.
Ksawery
Experienced Solver
Experienced Solver
Posts: 83
Joined: Thu Jul 25, 2019 12:31 pm

Re: Migrating to Linux (Mint)

Post by Ksawery »

Thank you for taking the time to look into my problem, that solved that issue! Unfortunately i'm still seeing errors related to the wxT macro:

Code: Select all

||=== Build: Debug in PomiarWiazki_wxWidgets_Linux (compiler: GNU GCC Compiler) ===|
/home/ksawery/repos/PomiarWiazki_wxWidgets_Linux/PomiarWiazki_wxWidgets_Linux/cDiagnostics.cpp||In constructor ‘cDiagnostics::cDiagnostics(const uint8_t*, const char*, int, bool*, bool*, bool*, bool*, bool*, int32_t*, int32_t*, uint16_t*, uint16_t*, wxMenu*)’:|
/usr/local/include/wx-3.1/wx/chartype.h|225|error: converting to execution character set: Invalid or incomplete multibyte or wide character|
/usr/local/include/wx-3.1/wx/cpp.h|18|note: in definition of macro ‘wxCONCAT_HELPER’|
/home/ksawery/repos/PomiarWiazki_wxWidgets_Linux/PomiarWiazki_wxWidgets_Linux/cDiagnostics.cpp|97|note: in expansion of macro ‘wxT’|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
Is the use of wxT incorrect in Linux? I didn't have any issues in Windows.

Regards,
Ksawery
Ksawery
Experienced Solver
Experienced Solver
Posts: 83
Joined: Thu Jul 25, 2019 12:31 pm

Re: Migrating to Linux (Mint)

Post by Ksawery »

I replaced some instances of wxT with _T, and it seems to work ok now. I still have other unexpected bugs in the application, but at least it compiles successfully now.

Many thanks,
Ksawery
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Migrating to Linux (Mint)

Post by DavidHart »

I replaced some instances of wxT with _T, and it seems to work ok now
That's surprising: _T is exactly the same as wxT :? .

After googling the error message, does the string contain a special character?

BTW, if you don't want wx2.8 compatibility you can replace all those wxT("")s with "".
Ksawery
Experienced Solver
Experienced Solver
Posts: 83
Joined: Thu Jul 25, 2019 12:31 pm

Re: Migrating to Linux (Mint)

Post by Ksawery »

It is possible that the string contained a random special character, due to foreign characters being pushed and pulled from GitHub. So that might have been the real issue - which I accidentally fixed by correcting typos.

Thank you for your help.

Ksawery
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7480
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Migrating to Linux (Mint)

Post by ONEEYEMAN »

Hi,
As David pointed out - do not use wxT(). Use "" directly.

Code: Select all

s/wxT("abc")/"abc"
.

Thank you.
Post Reply