Carbon question

Discussion in 'Mac Programming' started by pinsrw, Aug 15, 2010.

  1. pinsrw macrumors regular

    Joined:
    May 30, 2010
    #1
    Hi all,

    I need to do some old fashioned C-based Carbon coding, and I'm having a little problem. My program is coded I think normally, and when I put the executable into myapp.app/Content/MacOS, and invoke it by double-clicking on myapp.app, everything works fine... The app window comes up and my graphics is displayed.

    However when I try running my executable from the command-line, the window comes up blank and is behind other windows. Can anyone here with Carbon knowledge hazard a guess as to why this might be and how to fix it?

    Thanks.
     
  2. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #2
    You need to use the 'open' command at the terminal to launch application bundles.

    open -a TextEdit

    Will launch the TextEdit application. No need to provide the .app extention.

    Unless the application is in your path try using:

    open -a path/to/your/appbundle
     
  3. pinsrw thread starter macrumors regular

    Joined:
    May 30, 2010
    #3
    Now I'm getting stranger results than before. When I do this:

    Code:
    $ open my.app/Contents/MacOS/my 
    It produces the same blank window in the background but it also products a Terminal with some minor shell errors printed.

    When I do this I get an error and no application window appears:

    Code:
    $ open -a my.app/Contents/MacOS/my 
    Unable to find application named 'my.app/Contents/MacOS/my'
     
  4. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #4
    Point to the bundle with open, not the executable in the bundle.

    -Lee
     
  5. pinsrw thread starter macrumors regular

    Joined:
    May 30, 2010
    #6
    Well yes, doing "open ./my.app" works fine.

    But I want to run the executable like so
    Code:
    $ cd my.app/Contents/MacOS ; ./my
    ... ignoring the bundle.

    I know that this is possible, because some GUI-based executables do run OK from the command-line. For instance, I can already do this with another application that I wrote, but it's one where the GUI subsystem is a library that I borrowed (kind of like wxwidgets), thus I didn't write its GUI initialization. I'm left wondering how they coded it such that one can run the executable from the command line.
     
  6. Big Dave macrumors 6502

    Joined:
    Nov 27, 2007
    Location:
    Crestview, Fl
    #7
     
  7. pinsrw thread starter macrumors regular

    Joined:
    May 30, 2010
    #8
    It comes up behind the Terminal window, but its contents are filled in.
    Also the application list (command-Tab) does not show it.
    Any ideas?
    Thanks.
     

Share This Page