Page 1 of 1

OS X main app window not showing

Posted: Sun Feb 18, 2007 11:41 pm
by paul-m
I'm on a MacBook Pro Core Duo running system 10.4.8, wxMac version 2.6.3 and using gcc i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5250).

I have a very complex, wx-based program that runs just fine on Win XP and Fedora Core 5 (using wx for windows and wxGTK, respectively). I'm trying to get it running natively on OS X - not through X11.

The problem on the mac is that my main app window never appears. I've read this forum, I've googled, etc. I've made it past the Rez and bundle making steps, so it's not just a focus issue, though the menus don't appear in the menu bar either.

One of the things the app does on startup is throw up a wxMessageBox (telling the user to locate a config file) and then it throws up a wxFileDialog so the user can do just that. These dialogs come up just fine (and I can interact with them just fine) but the main App window and menus never appear.

Any suggestions? Is this a deeper rez issue than just the standard `wx-config --rezflags` [myapp], or something else I've completely missed?

Thanks
- Paul

Posted: Mon Feb 19, 2007 12:35 am
by Auria
Actually, rezflags is deprecated. Unless you want backward compatibility with macs more than 6 years old, you will want to ditch that and build mac OS X app bundles.

Is anything printed on the console?

If you passs your app through a debugger, where does it go while nothing happens?

Do the wxWidget samples run fine?

Have you tried building a small sample and compilling it yourself? You probably can't show us your big project but if you can reproduce it in a small project, you could either a) solve your issue by experimentating in a flexible project or b) show it to us.

Posted: Mon Feb 19, 2007 6:15 am
by paul-m
Thanks for responding!

1) So I make a bundle without doing the Rez step?

I was doing
/Developer/Tools/Rez -d __DARWIN__ -t APPL Carbon.r -o [myapp]

and some variants of that. Are you saying that's unnecessary?

2) Normally, under FC 5 and WinXP there are a couple of lines of initialization checks that are printed to the console (yes, we run a 2nd, console (dos) window in Windows along with the main app window). If I take my freshly linked app and ./myapp& it from the build dir, I get those initialization lines just fine, though the app doesn't at all appear in the dock or its name just to the right of the apple menu. (But it shows up in 'top')

3) I'll have a debug build by tomorrow. I was overly optimistic and started with a release build :-)

4) The samples run fine. I've combed their Makefiles and watched the output when I 'make' them and tried to distill down what's going on. This is probably where I'm going wrong. If I just do this

mkdir -p myapp.app/Contents/MacOS
mv myapp myapp.app/Contents/MacOS

and then double click the myapp.app from the finder, I get a dock icon, the myapp menu next to the apple menu, and I can do Help->About through the menus and it works, but nothing in the console and no main app window or other menus. I tried doing the whole shebang from

/Developer/Tools/Rez -d __DARWIN__ -t APPL Carbon.r -o myapp
/Developer/Tools/SetFile -a C myapp
mkdir -p myapp.app/Contents/MacOS
mv myapp myapp.app/Contents/MacOS
sed etc etc

like the samples do, and got nothing different than the shortcut way described above.

How much of that is absolutely necessary (do in need the Info.plist etc or it just won't work) to make a working bundle?
Are the samples doing the Rez and SetFile commands just to be backwards compatible?
What about the other *.r files in that Rez command, like sample.r?

I did a small sample back in the 10.1 days on an iBook. I'll dig that out and see how it behaves on this new system. I recall only simple compile/link with the appropriate wx-config inputs and the Rez command and it worked fine. The fact that the samples are working tells my I'm doing something wrong and my system is fine. If you have any ideas, let me know - I'll go the debugger route and get back to you.

Thanks
- Paul

Posted: Tue Feb 20, 2007 12:17 am
by paul-m
Ok, I think I've figured this out. I dropped the rez steps and read up a little on apple's site about bundles. Then it dawned on me that the app's main frame uses wxMDI* classes which I recalled are a windows paradigm. Sure enough, the main app window which shows (but is mostly blank) under Windows and FC 5 won't show under OS X until a data file is loaded, then it comes up nicely, along with the menus. Still a few missing little details, but I think this resolves this issue.

- Paul

Posted: Tue Feb 20, 2007 12:22 am
by Auria
paul-m wrote:Thanks for responding!

1) So I make a bundle without doing the Rez step?

I was doing
/Developer/Tools/Rez -d __DARWIN__ -t APPL Carbon.r -o [myapp]

and some variants of that. Are you saying that's unnecessary?
If you target OS X, it's not.

g++ myfile.cpp -o MyApp `wx-config --cppflags --libs`

something like this should be enough. Since Mac OS X is Unix, i find i can very often work the same way i would in Linux.

Note that a program built like that will run, though it will not receive any events unless it is placed in a bundle.
2) Normally, under FC 5 and WinXP there are a couple of lines of initialization checks that are printed to the console (yes, we run a 2nd, console (dos) window in Windows along with the main app window). If I take my freshly linked app and ./myapp& it from the build dir, I get those initialization lines just fine, though the app doesn't at all appear in the dock or its name just to the right of the apple menu. (But it shows up in 'top')
Maybe try putting more prints, to know whether the code that displays the window is called, whether the constructor of the window is displayed, etc.
4) The samples run fine. I've combed their Makefiles and watched the output when I 'make' them and tried to distill down what's going on. This is probably where I'm going wrong.
Don't watch the sample makefiles too much - they are overly complicated for starting. Especially, the mac makefiles build two versions of each sample. One for backward compatibility, one for OS X. If you look at them be careful not to look at the backward compatibility part (unless you need it of course) As i already said, using g++ with wx-config should about just do it.
/Developer/Tools/Rez -d __DARWIN__ -t APPL Carbon.r -o myapp
/Developer/Tools/SetFile -a C myapp
sed etc etc
I am not 100% sure what these do, but i never used them so i can confirm they are not necessary to get a working OS X app.
How much of that is absolutely necessary (do in need the Info.plist etc or it just won't work) to make a working bundle?
To make bundles, you WILL need a correct info.plist file. Fortunately, it's a very easy to understand XML file. My suggestion is to duplicate an existing simple app and replace its executable by your own. Then, edit the info.plist file to adapt executable name, app name, app version, icon, supported file types, documents your app produce, etc. For a minimal app you won't need a lot of stuff.

And also, before doing your big app, i would recommend trying a little sample of your own :D

Good luck ;)

EDIT: I just saw you're on an Intel mac. Definitelty drop the backward compatibility, Classic and Intel just aren,t compatible :P