Delphi compile error F2048 Bad unit format - delphi

I ran into an obscure error and am posting the solution here in the hope that it will help someone else having the same problem.
I am writing a Continuous Integration (CI) program using Delphi XE4 to ensure that a set of pascal source files will compile under older versions of Delphi. This CI program runs a series of batch files each running the command line compiler of an older Delphi version. The batch file running the XE compiler produced the following error:
F2048 Bad unit format: 'c:\program files (x86)\embarcadero\rad studio\11.0\lib\Win32\release\System.dcu' - Expected version: 22.0 ... Found version: 25.0
Note that the expected and found versions are different (in this case XE and XE4). Several people have reported similar errors where the expected and found versions were the same - this is usually a mixup between 32 and 64 bit DCUs, but that wasn't the problem here.
This problem only occurs when the CI program is run from within the Delphi XE4 IDE. If the CI program is run outside of the IDE it works fine.

The XE4 IDE adds several environment variables that are inherited by the program being debugged (in this case CI) that are in turn inherited by the batch files. One of these extra environment variables confuses the XE compiler when run in the batch file. The culprit is the added BDSLIB environment variable that points to the XE4 lib directory.
The solution was to simply add
set BDSLIB=
to the beginning of each of batch files. Once this change was made the CI program runs successfully both inside and outside the IDE.

Related

dxgettext and Windows 10

Has anyone got dxgettext running under Windows 10?
I installed dxgettext from the offical homepage under Windows 10, which worked fine.
But whenever I try to run some of the installed tools (e.g. msgfmt.exe), they don't really run, but call themselves again, generating thousands of processes and making the system crawl.
This is what happens:
I call msgfmt --help
the executable msgfmt hangs, blocking the command window
in the TaskManager I see houndreds of msgfmt.exe processes popping up
I think, I have to replace the gettext tools of the dxgettext package with some newer version but before trying to figure it out I first wanted to ask if someone else experienced similar problems and found a working solution.
My questions:
Has anyone got the tools coming with dxgettext running under Windows 10?
What steps have been necessary to get it to run?
I resolved the problem in the following way:
I downloaded https://github.com/mlocati/gettext-iconv-windows/releases/download/v0.19.8.1-v1.14/gettext0.19.8.1-iconv1.14-static-32.zip from https://mlocati.github.io/articles/gettext-iconv-windows.html
I replaced the following files from the installation directory of dxgettext with files from the zip archive:
msgattrib.exe
msgcat.exe
msgcmp.exe
msgcomm.exe
msgconv.exe
msgen.exe
msgexec.exe
msgfilter.exe
msgfmt.exe
msggrep.exe
msginit.exe
msgmerge.exe
msgunfmt.exe
msguniq.exe
xgettext.exe
Result:
Dxgettext and the tools, I use, seem to work fine. I found no problems with my workflow so far, with one exception:
If I use assemble to embed mo-files into an exe compiled with JvGnugettext.pas, I get the following error:
Pach code “6637DB2E-62E1-4A60-AC19-C23867046A89” was not found in .exe file. Are you sure the .exe file has been compiled with the correct libraries?
This may not be related to the original problem. However, it is resolved by replacing the original assemble.exe with the version from https://sourceforge.net/p/dzlib/code/HEAD/tree/buildtools/trunk/ (see answer by #dummzeuch).
The installer on the official home page is pretty old. Last time I looked it contained several outdated dlls and executables from the original gnugettext project that did not work correctly under recent Windows versions. You could take those from my buildtools repository on OSDN. These work for me. No guarantee that they work for you though.
https://osdn.net/projects/dzlib-tools/scm/svn/tree/head/buildtools/trunk/
I've been having these issues too with dxgettext 1.22, in Windows 10 1607. I changed some DLLs at first but kept having the bash.exe looping and hogging my PC to death.
So what I did was basically install latest Cygwin 32bit and replaced the appropiate DLLs. I kept the ones for gettext. Instructions:
Download and fresh install dxgettext-1.2.2.exe from http://dxgettext.po.dk/download as admin. Restart.
Download Cygwin 32bit from https://cygwin.com/install.html in a different folder from dxgettext (I took the default, c:\cygwin)
Run setup-x86.exe and select "Base" Package (Install). Next, Select Required packages just in case.
Move the following files from dxgettext folder to a backup folder (we'll use some DLL later):
cyg*.dll
bash.exe
Copy from c:\cygwin to the dxgettext folder the following files:
bash.exe (set to run as admin)
cygwin1.dll
cygiconv-2.dll
cygintl-8.dll
cygreadline7.dll
cyggcc_s-1.dll
cygncursesw-10.dll
Recover the file(s) below from the backup folder (See #4) and copy to the dxgettext folder.
cyggettextsrc-0-14-1.dll
cyggettextlib-0-14-1.dll
cygintl-3.dll
Running like this, you might get error 740 (requires elevation). So: Set ggmerge.exe,ggfmt.exe to run as admin
** EDIT** Found online this very interesting link, from a programmer who offers a free backup written in Delphi. The good thing is he adapted the dxgettext tools to run in Windows 10. This helped me a lot.
http://personal-backup.rathlev-home.de/translate.html

How get Netbeans 7.2 to use 32 Bit JVM

So I am using Netbeans to develop a Jenkins Groovy Post Build Script.
Jenkins runs in 32 bit mode (Production cannot touch), Netbeans wants to run in 64 bit mode.
I can get EITHER environment to work, the problem is that I need to keep switching my PATH variable so the right version of a DLL is on the path, but switch is time consuming and annoying.
I am trying to figure out how to get Netbeans to either run in 32 bit mode or to change the PATH variable in Netbeans to use the 64 Bit DLL (something Visual Studio supports).
So far, nothing I've done has convinced Netbeans to use 32 mode and I see no way to change the path for the Netbeans IDE.
Suggestions?
So I never did get -D to work properly. The values provided there just didn't seem to be reflected in the environment like I would have thought.
My eventual solution was to create a small *.BAT file that doctors the PATH before starting Netbeans. I would LOVE for someone to offer a better solution.
SET PATH=%PATH:enu\auth\x86=enu\auth\x64%
cd /d "C:\Program Files\NetBeans 7.2"
start "NetBeans with PATH Override" "C:\Program Files\NetBeans 7.2\bin\netbeans64.exe" --console suppress

i got trouble running exe file on runtime package delphi xe2

I tried to make the program Delphi XE2 with dynamic runtime package.
when I compile it no problem, but when on the run with F9 program just compiled and created exe file but it did not run.
what is wrong with my configuration?
configuration that I use
Link with runtime package set True
-- value from all configuration 32 bit windows platform set True
runtime package inherited set True
NB "When Link with runtime package" set to false, it can run normally.
The behaviour you describe is what happens when the .bpl files cannot be found. if you run the .exe outside the IDE you will get an error message to that effect. For some reason that error message does not show when running from within the IDE. Note that it's not enough even to use the Run Without Debugging option. You have to start the executable outside the IDE, for example by double clicking on the .exe file in an explorer window.
Probably the most effective way to debug this to work out which dependencies are failing is with Dependency Walker. Load up your executable and debug its startup from the Profile menu.
Solve the problem by making sure that the .bpl files can be found. Make sure they are on the DLL search path. The best way to do that is to place them alongside the .exe file.

How to do a command line build using Delphi 7?

I am trying to build a delphi project from the command line compiler
Example: C:\dcc32 -B C:\BD\Delphi7\work\MyProject.dpr
Aside from the the standard evironment pathing:
$(DELPHI)\Bin;
$(DELPHI)\Lib;
$(DELPHI)\Imports;
$(DELPHI)\Projects\Bpl;
$(DELPHI)\Rave5\Lib;
there is nearly 50 other paths to other libraries, components, etc...
How do i package this all up and point to these to use in the commanline parameters to make my build?
When i run the example above
C:\dcc32 -B C:\BD\Delphi7\work\MyProject.dpr
i get a FATAL: File not found : 'file name here'
thanks
Under Delphi 7 you need to edit you dcc32.cfg file (in you Delphi bin folder). You need to copy the library path from the IDE and put in the dcc32.cfg file. You have to add it 4 times for the different command line parameters, eg:
-u=path
-i=path
-r=path
-o=path
There are 4, I believe. I haven't done this in a few years so I hope that the info is correct. Certainly, the command line compiler does not use the same place to store the paths as the IDE does.
I don't think dcc32.exe is stored under C:\, if it is you're installation of Delphi is really out of order, or you have moved only the dcc32.exe file.
It's advised to use the dcc32.exe from the directory where the Delphi install has stored it. The Delphi directory depends strongly on the Delphi version, but for Delphi versions op to 7, this looked something like this:
C:\Program Files\Borland\Delphi7\bin\dcc32.exe
For later versions of Delphi, this should be changed to:
"C:\Program Files (x86)\Embarcadero\RAD Studio\8.0\bin\DCC32.exe" -h

Delphi 2009 command line compiler using dcc32.cfg?

In Delphi 2009, how can I build a project using command line. I tried using the command line compiler and supplying -a -u -i -r in dcc32.cfg file. But compiler is not recognizing the paths and throwing the error required package xyzPack is not found.
-aWinTypes=Windows;WinProcs=Windows;DbiProcs=BDE;DbiTypes=BDE;DbiErrs=BDE
-u"C:\MyProj\Output\DCP"
-i"C:\MyProj\Output\DCP"
-r"C:\MyProj\Output\DCP"
and on command line i execute the command :
dcc32 "C:\MyProj\MyProject.dpr" -B -E"c:\MyProj\Output\EXE"
What am I doing wrong here?
Thanks & Regards,
Pavan.
Instead of invoking the compiler directly, consider using MSBuild on your .dproj, since that's what the IDE uses. Delphi MSBuild Build Configurations From Command Line might help you with that.
From the related answer (as shown below) ie:
Compiling with Delphi 2009 from a command line under Windows Vista 64-bit
I notice that you should be able to build a single package from the command line this way. I have used batch files (buildall.cmd) to launch dcc32, and have not yet used msbuild.
I have ultimately found both approaches frustrating, and have instead decided to opt for building a little GUI shell (a lite version of Final Builder, if you like) that basically works as a semi-graphical semi-command-line way of automating my builds and filtering the compiler output to produce results. I would be highly interested in anyone else's experiences with "tinder box" (daily or even continuous build) operations with Delphi.
You may end up where I'm heading... just buy Final Builder. :-)

Resources