error when starting application on mac lazarus / 13-General ---------------------------------------------------------------------- Blue1987 · 2011-02-11 16:09 I am writing an application, and have already compiled for windows... then I asked a friend of mine to lend me his mac... I installed everything and then compiled the application... yet when the application starts, the debugger shows an error, but does not say which error... is there someone who can try to compile it on mac? it's open-source distributed and you can get the code at http://www.calcio4ever.it/pagina_04_03.htm ---------------------------------------------------------------------- Blaazen · 2011-02-11 17:14 I tried your application and my feeling is that it is somewhat strange  . Probably it should auto-maximize which does not work. There are no title and title (sytem) buttons to do maximalize/minimalize manually. Images cannot be loaded on Unix-like platform because of path: Code: [Select]sfondo0.picture.LoadFromFile('immagini\sfondi\sfondo3.jpg'); Code: [Select]sfondo0.picture.LoadFromFile('immagini/sfondi/sfondo3.jpg'); (backslash is Windows only, we use slash) so it can be simply solved. Because there are so many places with backslash I was not able test it properly - program raises exeption. Edit: I forgot tell you I am on Linux+Qt ---------------------------------------------------------------------- User137 · 2011-02-11 17:23 Using this myself: Code: [Select]const       {$IFDEF Windows}       PathChar = '\';       {$ELSE}       PathChar = '/';       {$ENDIF} procedure FixPath(var path: string); var i: integer; c: char; begin   for i:=1 to length(path) do begin     c:=path[i];     if ((c='\') or (c='/')) and (c<>PathChar) then path[i]:=PathChar;   end; end; // ... or function version possibly this way function getFixPath(const path: string): string; begin   result:=path; FixPath(result); end; ---------------------------------------------------------------------- Blue1987 · 2011-02-12 02:32 thank you both! as you suggested, I corrected the code using / and \ depending on the OS.. using first Code: [Select]const       {$IFDEF Windows}       PChar = '\';       {$ELSE}       PChar = '/';       {$ENDIF}     and then i.e. Code: [Select]sfondo0.picture.LoadFromFile('immagini' + pchar + 'sfondi' + pchar + 'sfondo3.jpg'); I substituted the file linked in page " http://www.calcio4ever.it/pagina_04_03.htm " (so that you can check)... anyway, it seem to still keep on not working. what else could it be? ---------------------------------------------------------------------- Phil · 2011-02-12 02:52 Looks like you're using a relative path to sfondo3.jpg at startup. But relative to what? If from your executable, remember that it's at project1.app/Contents/MacOS/project1. Normally on Mac you would place any resources (immagini, database) that the app requires to run in project1.app/Contents/Resources. Then reference it relative to the executable with ../Resources/immagini/sfondi/sfondo3.jpg. Thanks. -Phil ---------------------------------------------------------------------- Blue1987 · 2011-02-12 03:02 Quote from: Phil on February 12, 2011, 03:52:12 amLooks like you're using a relative path to sfondo3.jpg at startup. But relative to what? If from your executable, remember that it's at project1.app/Contents/MacOS/project1. Normally on Mac you would place any resources (immagini, database) that the app requires to run in project1.app/Contents/Resources. Then reference it relative to the executable with ../Resources/immagini/sfondi/sfondo3.jpg. Thanks. -Phil ok, I must admit I do not know anything about mac-os, since I always used windows... hence I understand I can just make some trials to understand how it works on a different os! I simply hoped it was easier to "write once" so that I can "compile anywhere" ;- ) anyway, thank you... I'll try to understand your suggestion... ---------------------------------------------------------------------- Phil · 2011-02-12 03:14 Quote from: Blue1987 on February 12, 2011, 04:02:04 amok, I must admit I do not know anything about mac-os, since I always used windows... hence I understand I can just make some trials to understand how it works on a different os! I simply hoped it was easier to "write once" so that I can "compile anywhere" ;- ) Well, it compiled fine, it just didn't run. When the image file could not be found, I got a message box with Cancel to quit, OK to ignore. I clicked OK and did see the main form, which actually looked quite nice. But when I clicked the top button on the form, I got another error about a file not found, so probably similar issue there. I didn't see any main menu. Is it just button operated? Some ideas here about some of the differences between Mac and the rest of the world: http://web.me.com/macpgmr/ObjP/MacXPlatform_Part8.html There's also quite a bit of information in the Lazarus wiki, although watch out for things that are now out of date or a bit jumbled: http://wiki.lazarus.freepascal.org/OS_X_Programming_Tips The ultimate reference of course is Apple's on-line docs, which are very extensive. Here's also a very brief overview of the app bundle concept: http://en.wikipedia.org/wiki/Application_bundle Thanks. -Phil ---------------------------------------------------------------------- Blue1987 · 2011-02-12 11:37 Quote from: Phil on February 12, 2011, 04:14:07 amQuote from: Blue1987 on February 12, 2011, 04:02:04 amok, I must admit I do not know anything about mac-os, since I always used windows... hence I understand I can just make some trials to understand how it works on a different os! I simply hoped it was easier to "write once" so that I can "compile anywhere" ;- ) Well, it compiled fine, it just didn't run. When the image file could not be found, I got a message box with Cancel to quit, OK to ignore. I clicked OK and did see the main form, which actually looked quite nice. But when I clicked the top button on the form, I got another error about a file not found, so probably similar issue there. I didn't see any main menu. Is it just button operated? Some ideas here about some of the differences between Mac and the rest of the world: http://web.me.com/macpgmr/ObjP/MacXPlatform_Part8.html There's also quite a bit of information in the Lazarus wiki, although watch out for things that are now out of date or a bit jumbled: http://wiki.lazarus.freepascal.org/OS_X_Programming_Tips The ultimate reference of course is Apple's on-line docs, which are very extensive. Here's also a very brief overview of the app bundle concept: http://en.wikipedia.org/wiki/Application_bundle Thanks. -Phil it cannot go on since it tries to load the database when you click the button.... (try the win version from http://www.calcio4ever.it/pagina_04_01.htm ... they told me that it works quite well using Wine) well... I'll try to understand the basics and then I'll tell you ;-) thank you so much, Paolo ---------------------------------------------------------------------- Blue1987 · 2011-02-21 00:56 p.s. I need one more thing! what is the equivalent of the character #13#10 (for windows) in the different operative systems? thank you! ---------------------------------------------------------------------- Blaazen · 2011-02-21 01:10 Linux & Unix systems use only LineFeed (#10). Here (http://lazarus- ccr.sourceforge.net/docs/rtl/system/settextlineending.html) is some useful function.