I'm writing a utility program that converts an XML file to a database. I wish to use the wxwidgets wxXML classes and more. The program does not have a GUI, so I created it as a console application. Because it is to be cross-platform, I used wxStandardPaths to generate the full path names. At run-time, I get an error about using wxStandardPaths without initializing wxApp. I tried creating a Frame application and doing everything at the App OnInit() method and not calling frame->Show(), but that got me a more detailed error about needing to initialize the application first. Besides, creating an empty frame that is never shown is ugly design.
How can I create a console application in wxDev-C++ using all the non-visual classes including wxStandardPaths ?
wxStandardPaths and Console Application [SOLVED]
wxStandardPaths and Console Application [SOLVED]
Last edited by Tony0945 on Thu Dec 24, 2015 2:14 am, edited 1 time in total.
Re: wxStandardPaths and Console Application
I know nothing about wxDev-C++ but if nothing else, it should not stand in your way. Check the console sample bundled with wxWidgets to see how to create wxWidgets console application. And if you want a true console application, make sure to create one (with the proper linker subsystem).
I have just tried with the modified console sample and can confirm that wxStandardPaths works in the console application (latest wxWidgets trunk on MSW).
I have just tried with the modified console sample and can confirm that wxStandardPaths works in the console application (latest wxWidgets trunk on MSW).
-
- Earned some good credits
- Posts: 113
- Joined: Sat Sep 24, 2011 9:32 pm
- Location: Poland
Re: wxStandardPaths and Console Application
Perhaps you have used wxStandardPaths as a object directly. This statement I have found in docs:
Regards, Jarek
and some example form stackoverflow.com:Note that you must not create objects of class wxStandardPaths directly, but use the global standard paths object returned by wxStandardPaths::Get()
Code: Select all
bool dialogsApp::OnInit()
{
wxString xpath;
xpath = wxStandardPaths::Get().GetExecutablePath();
Re: wxStandardPaths and Console Application
After a few more hours of googling, I found that the linker message goes away if I include
#include <wx/init.h> and in main() add
However, now when I run, there is no console window and if I run the program by "Start Button->Run->cmd" and navigate to the Output directory and execute the program manually, there is not output and no error messages. Also the program does not pause for keyboard input.
The entire test program is here:
My understanding is that this initialization is called by the wxApp constructor.
I think some library or definitions must be added to the Project options. My question is now, using the wxDev-cpp GUI tool, how can I make the test program work?
#include <wx/init.h> and in main() add
Code: Select all
wxInitializer ini;
The entire test program is here:
Code: Select all
#include <cstdlib>
#include <iostream>
#include <wx/init.h>
using namespace std;
int main(int argc, char *argv[])
{
cout << "Press the enter key to continue ...";
cin.get();
wxInitializer ini;
if (!ini.IsOk())
{
cout <<"didn't work";
}
return EXIT_SUCCESS;
}
I think some library or definitions must be added to the Project options. My question is now, using the wxDev-cpp GUI tool, how can I make the test program work?
Re: wxStandardPaths and Console Application
.Tony0945 wrote:After a few more hours of googling, I found that the linker message goes away ...
No googling was necessary, the answer was supplied right in the first reply in this thread, i.e. check the console sample. And if you don't see the console window at all (even when running your app from the command line), you may want to check if you don't compile it with "-mwindows" flag. If you do, remove the flag or perhaps just adding "-mconsole" may be enough.
I guess virtually no one uses wxDev-C++ in 2015 here on the forums. You are better off asking on their forums.Tony0945 wrote:My question is now, using the wxDev-cpp GUI tool, how can I make the test program work?
Re: wxStandardPaths and Console Application
The -mwindows flag was indeed the problem. Thank you very much.
I suppose it's time to move on to wxSmith
??? This is the wxDev-C++ forum! It's where I've always gone.I guess virtually no one uses wxDev-C++ in 2015 here on the forums. You are better off asking on their forums.
I suppose it's time to move on to wxSmith