Lazarus

Programming => Operating Systems => macOS / Mac OS X => Topic started by: Julius on November 05, 2011, 08:32:31 am

Title: launching OS X application
Post by: Julius on November 05, 2011, 08:32:31 am
Hello,

I've installed lazarus on my intel mac snowleopard. Created a "hello world" application - just a button showing messagebox, nothing special. When I hit run button - it compiles and works ok.

The problem arrises when I try to run the binary file of the newbuilt application. The terminal window appears, I see the application window, but it is inactive for some reason.

I am new to mac os. I've been programming for windows and linux until now...

OS:  SnowLeopard
System version: Mac OS X 10.6.8
Kernel: Darwin 10.8.0
XCode: 3.2.6
FPC: 2.4.2
Lazarus 0.9.30

Using carbon LCL widget set.
Title: Re: launching OS X application
Post by: felipemdc on November 05, 2011, 08:39:09 am
How are you running the application? From Lazarus?

In any case, go to Project->Project Options

Select "Use Application Bundle"
Click in the button "Create Application Bundle"
and try again running from Lazarus.
Title: Re: launching OS X application
Post by: Julius on November 05, 2011, 08:53:50 am
Quote
How are you running the application? From Lazarus?
From lazarus I'm running it by clicking "Run" buttont (the green triangle). It works Ok.
From Console window I'm running it clicking project1 from the file manager.

Quote
Select "Use Application Bundle"
Click in the button "Create Application Bundle"
and try again running from Lazarus.
Did all that. Still ok when running from Lazarus, problems when from filemanager.

In the terminal window I see "TCarbonButton.SetFocus Error: SetKeyboardFocus failed with result -30585. The message does not appear if i run the project using sudo, but the bahavior remains, so I doubt it is the root of the problem..
Title: Re: launching OS X application
Post by: felipemdc on November 05, 2011, 09:04:17 am
From lazarus I'm running it by clicking "Run" buttont (the green triangle). It works Ok.
From Console window I'm running it clicking project1 from the file manager.

Ok, now I see. There is no problem, this is just how Carbon works. Carbon applications *must be run* from the Bundle.

You cannot run the executable. To run the Bundle open a terminal and type something like this:

cd myproject
open project1.app
Title: Re: launching OS X application
Post by: Julius on November 05, 2011, 09:17:57 am
Oh... didn't know that. Thank you.

If I have used cocoa - would I be able to execute it (not open)?
Title: Re: launching OS X application
Post by: Jonas Maebe on November 05, 2011, 09:55:25 am
If I have used cocoa - would I be able to execute it (not open)?

This has nothing to do with Carbon vs Cocoa. You can change this behaviour by explicitly calling TransformProcessType though: http://developer.apple.com/library/mac/#documentation/Carbon/Reference/Process_Manager/Reference/reference.html#//apple_ref/c/func/TransformProcessType (yes, that call is technically part of "Carbon", but it applies equally to Cocoa applications: http://www.cocoadev.com/index.pl?TransformProcessType -- at the low level, Carbon and Cocoa are completely interdependent and use each other's facilities all the time).
Title: Re: launching OS X application
Post by: Julius on November 05, 2011, 10:40:06 am
Thank you both jmaebe and felipemdc for the help.

Starting something new is usually not an easy task. It's good to have you guys!
TinyPortal © 2005-2018