Project, Compiler Options, Execute After lazarus / 11-Options ---------------------------------------------------------------------- wmike · 2009-01-11 04:40 Is there a way I can call a bat file to run strip.exe and upx.exe in this section? I can't seem to find the app variable so I can pass it to the bat file. Thanks, Mike Wheaton ---------------------------------------------------------------------- Leledumbo · 2009-01-12 05:13 if you have (in .bat file): Code: [Select]strip -s %1 upx --best --lzma %1then you can use (in execute after): Code: [Select]batfile.bat $TargetFile()In case I was wrong, try looking the suitable macro here. ---------------------------------------------------------------------- Nicola Gorlandi · 2009-04-21 09:14 This is my solution for Windows SO... In Compiler Options, Execute after I inserted this Strip_Exe.bat  $Path($CompPath()) $TargetCPU() $TargetFile() and in the project path I've inserted the file Strip_Exe.Bat Code: [Select]rem Batch per "strippare" il file rem riceve come parametri: rem 1 - il percorso in cui si trovano i file binari di FPC (es. rem 2 - il processore utilizzato (per ora Arm o x86) rem 3 - il file eseguibile da strippare... echo percorso %1 echo Processore %2 echo file %3 rem Nessun check di validità dei parametri... IF %2%==arm goto l_ARM IF %2%==i386 goto l_I386 goto fine :l_ARM Rem Strip per processore Arm echo Processore %2% %1arm-wince-strip --strip-all %3 goto fine :l_I386 Rem Strip per processore i386 echo Processore %2% %1strip --strip-all %3 :fine rem chiudo il bat... Missing the Upx only.... Bye ---------------------------------------------------------------------- Paul Ishenin · 2009-04-21 13:49 Checking -Xs in the compiler options is not enough? ---------------------------------------------------------------------- Nicola Gorlandi · 2009-04-28 09:31 yes... ---------------------------------------------------------------------- jmLandsvik · 2011-04-06 09:38 This problem persists? I've put in this under Project/options/Compiler/options/compilation command: D:\lazarus\fpc\2.4.3\bin\i386-win32\strip.exe --strip-all $(TargetFile) and get this message D:\lazarus\fpc\2.4.3\bin\i386-win32\strip.exe: Documents\PROSJEKT\lazarus\AttriButeNumbering\Attributes.exe: No such file or directory looking at the error, it's even missing a part, as my path is: "D:\users\myDir\My Documents\PROSJEKT\lazarus\AttriButeNumbering" Reading the "manual",under "Paths & Parts" says this: TargetFile - the output file of the current project (e.g. the executable or the library) So, where did I go wrong? Quote from: Paul Ishenin on April 21, 2009, 03:49:38 pmChecking -Xs in the compiler options is not enough? Nope, not on my puter it is... regards... //JM ---------------------------------------------------------------------- jmLandsvik · 2011-04-06 10:09 I don't belive this.... After looking at the error and seeing that it is missing the "first part" of my path, I did a little experimenting, and when I got to this: D:\lazarus\fpc\2.4.3\bin\i386-win32\strip.exe --strip-all "$(TargetFile)" (Note the double qoutes) it actually worked... Great, but, really, this can't be intentioanlly? or can it ? //Jan Magne ---------------------------------------------------------------------- Leledumbo · 2011-04-06 18:35 Quotelooking at the error, it's even missing a part, as my path is: "D:\users\myDir\My Documents\PROSJEKT\lazarus\AttriButeNumbering" (Note the double qoutes) it actually worked... Great, but, really, this can't be intentioanlly? or can it ?You have spaces in the project path, surely without quotes it would be regarded as two arguments for strip. ---------------------------------------------------------------------- jmLandsvik · 2011-04-08 13:30 Quote from: Leledumbo on April 06, 2011, 08:35:41 pmQuotelooking at the error, it's even missing a part, as my path is: "D:\users\myDir\My Documents\PROSJEKT\lazarus\AttriButeNumbering" (Note the double qoutes) it actually worked... Great, but, really, this can't be intentioanlly? or can it ?You have spaces in the project path, surely without quotes it would be regarded as two arguments for strip. Hi, Well, first I would think that when using $(TargeFile) I would get the "FileName", and not "Drive:\Path\FileName" Second, when putting in av "$(variable)" like that, it would be handled properly, ie. either double qoutes be insertet automatiacally, or when needed. Or is it normal, that ONE systemvariable will be treated different depending on what's inside? *cofused* tnx., and regards Jan Magne ---------------------------------------------------------------------- Leledumbo · 2011-04-09 03:46 QuoteWell, first I would think that when using $(TargeFile) I would get the "FileName", and not "Drive:\Path\FileName"Hmm... agreed. The macro name is a little misleading, but it's already there for a long time. And it's easy to get just the filename: $NameOnly($TargetFile()) QuoteSecond, when putting in av "$(variable)" like that, it would be handled properly, ie. either double qoutes be insertet automatiacally, or when needed.AFAIK the macro expander only expands to the contents, no more no less. Everything outside the $() construct isn't part of the macro and is totally your freedom. QuoteOr is it normal, that ONE systemvariable will be treated different depending on what's inside? *cofused*AFAIK no. ---------------------------------------------------------------------- ArtLogi · 2016-01-19 15:59 I have also a problem with this strip.exe tool under Lazarus. I'm using FPC v2.6.4 and Laz v1.2.6 under w7. Trying to get that 15Mb a bit smaller, since tbh, for tool that counts 1+1 it is a bit much. So debugging data have to go. I did follow these instructions: http://lazplanet.blogspot.fi/2013/03/how-to-reduce-exe-file-size-of- your.html I assume I would also go through just project settings, but since there is now rather simplistic problem in hand (hope so) I would like to know the solution, I have stried some alteration of the "working directory path" as follows: "$ProjPath()" --strip-all "$TargetFile()" etc. , but obviously ending even more obscure result of wrong path. The fields are like: C:\FPC\2.6.4\bin\i386-win32\strip.exe --strip-all "$TargetFile()" The wrong path error is then: Unable to run the tool "Strip current EXE": Working directory C:\lazarus\--strip-all "C:\users\Me\Desktop\MyProject\Verkko.exe"\ not found. The C:\Lazarus\ is the folder as set in the "IDE options" How I can get rid of that? So the tool can work no matter the project folder.. Thank you. ---------------------------------------------------------------------- balazsszekely · 2016-01-19 16:10 1. Go to: Lazarus Menu-->Project-->Project Options-->Compiler Option-->Build Modes-->Create Debug and Release modes-->Select release 2. Build your application again. Form 15M you're down to 1.5 M(empty application). You can further shrink the size with upx, but please note some AV's may detect your exe as false positive. ---------------------------------------------------------------------- ArtLogi · 2016-01-19 16:38 Quote from: GetMem on January 19, 2016, 05:10:23 pm1. Go to: Lazarus Menu-->Project-->Project Options-->Compiler Option-->Build Modes-->Create Debug and Release modes-->Select release 2. Build your application again. Form 15M you're down to 1.5 M(empty application). You can further shrink the size with upx, but please note some AV's may detect your exe as false positive. OK, that way it works as should without any problems in my case 15Mb to 1.8Mb (without UPX).. Although the route for the right option you propose is not most clear one, since the Build Modes seems to be behind that tickbox at up middle. (For future readers) Picture: http://i.imgur.com/yHtbFSj.png Does anyone have idea how the strip.exe can be properly linked, so it does search from the true project path and not from the path entered in IDE settings (my case C:\Lazarus\). For my part this is now solved. Edit. Two unworking variation to call strip.exe http://i.imgur.com/qyJL9bT.png http://i.imgur.com/SrFxHCB.png OK, the last (and the most obvious thing I didn't try is place the parameters to parameters field.  Strip.exe also works now... http://i.imgur.com/IWb25S5.png That tutorial on that blog seems to be out dated. ?? No.. I have somesort of dyslexia going on right here atm. it seems. From blog: QuoteParameters: --strip-all "$TargetFile()"