Forum > Other OS

Relative path to .app package contents in OSX

(1/1)

Uto:
Hi,

I have a project that was running in Windows and Linux so far, and now I'm trying to port it to OSX as well. The project is an IDE for a compiler of mine, which is a C application.

On other OSs, the IDE executable is in the same folder where compiler is, so the IDE default path to compiler is just the compiler file name.

In OSX, Lazarus creates (cause I asked for it) a .app package, where as you know, the actual executable is at Contents/MacOS folder.

I would want to include the compiler and some required libraries in the package, so I can share just the app file, cause it is more close to OSX standards, so I've tried to add the compiler to the Contents/MacOS folder, but it seems the execution folder is the path were the .app "file" is, so the result is "compiler not found" when trying to compile.

I have also tried to set default path to myapp.app/Contents/MacOS/compiler (where "compiler" is the name of the compiler executable file) and to ./myapp.app/Contents/MacOS/compiler, but I had no success.

Probably I'm not doing it the right way, is there something I'm missing? Maybe a better organized way of building the package?

balazsszekely:

--- Quote ---In OSX, Lazarus creates (cause I asked for it) a .app package, where as you know, the actual executable is at Contents/MacOS folder.
--- End quote ---
The actual executable is inside your project folder. The alias inside Contents/MacOS  is just a "link". After the development is done, you should replace it with the executable from your project dir. Anyway ParamStr(0) should always indicate ../Contents/MacOS/

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---CompilerPath := ParamStr(0) + 'CompilarName';

Uto:
Thank you for your reply.

I hadn't noticed the "executable" within the package was just a symbolic link. Also, using ParamStr(0) seems to be the perfect way to set all required files locations relatively to that path.

Now I just wonder if is there any way to make the Lazarus compiler put the real exe file inside the package, together with the localization folder (my IDE is multilanguage). Otherwise as you say I have to move the exe file to the inner folder, and the language files too, and I'm worried cause I may well forget it.

Also, I've noticed when I put the executable zip file inside the package,  Lazarus cannot create symbolic link anymore cause a file with same name already exists, what is very inconvenient. Is there any walkaround for this issue?

balazsszekely:

--- Quote ---@Uto
Now I just wonder if is there any way to make the Lazarus compiler put the real exe file inside the package, together with the localization folder (my IDE is multilanguage). Otherwise as you say I have to move the exe file to the inner folder, and the language files too, and I'm worried cause I may well forget it.
--- End quote ---
I. Create a bash script with all the command you need:
    1. copy executable under "Contents/MacOS"
    2. copy compiler under "Contents/MacOS/Compiler"
    3. etc...
II. Lazarus Menu-->Project-->Project Options-->Compiler Commands-->Execute After. Type the exact path of your bash script. After every Compile or/and Build or/and Run the script is executed. First you need to make the script executable with chmod.

Uto:

--- Quote from: GetMem on December 08, 2015, 09:03:11 pm ---
--- Quote ---@Uto
Now I just wonder if is there any way to make the Lazarus compiler put the real exe file inside the package, together with the localization folder (my IDE is multilanguage). Otherwise as you say I have to move the exe file to the inner folder, and the language files too, and I'm worried cause I may well forget it.
--- End quote ---
I. Create a bash script with all the command you need:
    1. copy executable under "Contents/MacOS"
    2. copy compiler under "Contents/MacOS/Compiler"
    3. etc...
II. Lazarus Menu-->Project-->Project Options-->Compiler Commands-->Execute After. Type the exact path of your bash script. After every Compile or/and Build or/and Run the script is executed. First you need to make the script executable with chmod.

--- End quote ---

That will do it, I had the script already built (apart of the compiler it needs some libraries) but I didn't know about the "execute after" option, many thanks!

Navigation

[0] Message Index

Go to full version