Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3598222
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:12:55+00:00 2026-05-18T20:12:55+00:00

I have a command-line application written in C++ and built with gcc/make that runs

  • 0

I have a command-line application written in C++ and built with gcc/make that runs on MacOS. This application does not have its own GUI and it not supposed to have any root windows — it’s a console app meant to be controlled by another application.

However, there is a need to show a file selection dialog at one point, which makes this a bit of a hybrid.

I’ve used wxWidgets to create the dialog, but it fails to get input. I’ve seen in the various FAQs and user groups that a bundle is probably required. When I tried to create a bundle it didn’t solve the problem.

Here’s how wxWidgets is initialized:

#ifdef __WXMAC__
    if (!wxEntryStart(argc, argv))
    {
        cout << "Failed to initialize wxWidgets." << endl;
        return 0;  
    }
#endif
    clientApp = new MainClass();
    clientApp->Run(argc, argv);
#ifdef __WXMAC__   
    wxEntryCleanup();
#endif

When I try to show a browse file dialog, using this code, it shows the file chooser but does not respond, acting like it has no message pump:

#ifdef __WXMAC__
    wxFileDialog* dlg = new wxFileDialog( NULL, _("Upload File"), _(""), _(""),
        _("All Files (*.*)|*.*"), wxFD_OPEN|wxFD_FILE_MUST_EXIST );
    if (dlg->ShowModal() == wxID_CANCEL )
    {
        INFOLOG("File upload dialog has been cancelled." << endl )
        return false;
    }
#endif

Since the FAQs say that creating a bundle is a way to automagically create a message pump and make a GUI responsive. I tried creating a bundle:

myapp.app
–> Contents
–> MacOS
–> myapp (executable file)
–> cert.crt (ssl certificate used by app)
–> Resources
–> myapp.icns
–> Info.plist (points ot myapp as executable and uses myapp.icns as icon)

The application controlling this is not one I have control over and has to run it in exactly this way:

myapp

The controlling app needs to read the console output of this app and that is primarily why this has been a console-only app.

Since the executable is a few directories deeper, I tried creating a shell script in the root directory above the bundle to run the application and calling it myapp. Myapp just runs myapp.app/Contents/MacOS/myapp, forwarding the commandline parameters.

This didn’t work. The browse file window is created and just sits there, giving me the rainbow spinwheel every time I mouse over it.

What can I do to get a message pump going? Is there a call I can add to the wxWidgets code or do I need to do something differnently with the bundle? Does having the shell script launch the app that is inside the bundle completely defeat the “message pump magic” that the bundle is supposed to give, and if so, is there a sensible workaround? Do I just need to create some sort of pseudo-parent for the wxFileDialog?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:12:56+00:00Added an answer on May 18, 2026 at 8:12 pm

    I’ve heard reports that an alternative to creating an application bundle is to use the following code (which I never recommend to anyone over a bundle, but it sounds like your situation is a good reason to use it):

    #include <ApplicationServices/ApplicationServices.h>
    
    ProcessSerialNumber PSN;
    GetCurrentProcess(&PSN);
    TransformProcessType(&PSN,kProcessTransformToForegroundApplication);
    

    This is of course platform specific, so wrap it accordingly.

    Do you have a derived wxApp, and wxApp::OnInit()? These are likely still required to initialize the event loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an application that installs SQL Server Express from the command line and
I have a command line executable that alters some bits in a file that
I have a command-line utility that gets quite a bit of downloads from my
I have a small command line program that uses the Team System API. When
I have a small command line utility project that I'm using Maven to manage.
Specifically I have a PHP command-line script that at a certain point requires input
I have a command line program, which outputs logging to the screen. I want
I have a command line Ruby app I'm developing and I want to allow
I have a command-line process I would like to automate and capture in C#.
I have a command line app the continuously outputs YAML data in the form:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.