C++ Builder XE3 – Declaration terminated incorrectly System.ZLib.hpp

Using Fast-Reports Enterprise edition, just dropping an frxReportServer component on a blank form and compiling, the XE3 compiler chokes with the following:

Error System.ZLib.hpp E2040 Declaration terminated incorrectly – on a line that says extern DELPHI_PACKAGE char *ZLIB_VERSION;

The include file train goes:

frxServer.hpp => frxServerSessionManager.hpp => frxServerReports.hpp => frxExportODF.hpp => frxZip.hpp => System.ZLib.hpp

The solution is simply to include the System.ZLib.hpp BEFORE the frxServer.hpp .  Since the latter is added to the .h file automatically, just put:

#include “System.Zlib.hpp”

first, and the program complies, links, and runs.

Gnostice eDocEngine does not work with C++ Builder XE3

Update, February 25, 2014:  I just tested again, using a fresh install of RAD Studio XE5 Update 2, into which no other components had been installed.  I downloaded the trial version of eDocEngine from http://www.gnostice.com/downloads.asp today, and ran the install into RAD Studio XE5.  I did not run any of the interface installers.  I then created a C++ Builder VCL project with one form, and dropped a TgtPDFEngine component on the form.  I then dropped a TButton, and in the click handler, I added

gtPDFEngine1->BeginDoc();

The program compiles, links, and runs, but when the button is clicked, I get a PDF Setup dialog.  When I click OK without making any changes in the dialog, I get an error:  “Project Project1.exe raised exception class $C0000008E with message ‘floating point divide by zero at 0x006d5a5a’.”.  Thus, as of this point, eDocEngine remains unusable in C++ Builder XE5 Update 2.  Gnostice support says they have a workaround, but it requires turning off Runtime Packages, which, with my application, prevents it from running.

 

I have been using Gnostice’s pdf generation products for a while now, using C++ Builder XE.  Recently, I wanted to move to the current version of C++ Builder, version XE3.  I installed a new version of Windows 7 under Parallels on my Mac, and installed RAD Studio XE3, and the various packages I use, keeping snapshots along the way.  Ultimately, I built my application, and with a few manageable changes, it compiled and ran.  However, when I created the form that contained the PDF Engine component from eDocEngine and built the project, the resulting program crashes with a “floating point divide by zero” error when the form is created.

That was using eDocEngine 3, the most current version available when I was migrating, in January 2013.  I submitted a support request to Gnostice on Jan 18, 2013, about multiple install problems (see below), and a separate support request on Jan 22, 2013 with the show-stopper “floating point divide by zero” error, and although they have sent a few confirmations, and stated that they can reproduce the problem, they have not found a solution, and eDocEngine 3 still does not work with C++ Builder XE3.

In early February 2013, Gnostice released eDocEngine version 4, and so I tried installing that.  The main installation program worked (although the importers still fail).  Unfortunately, a C++ Builder XE3 project onto which a TgtPDFEngine component is dropped will not compile (the first error is an #include of “NtDef.h”, which does not exist in my system – it appears to be included by a JEDI file).  I managed to get a test program to compile by removing that #include, and substituting fragments of NtDef.h and other files for the missing include file, and ultimately got my simple test program (a TgtPDFEngine component on an empty form, with no code whatsoever) to compile, build, and start, but the same “floating point divide by zero” error occurs on startup.  Thus the same problem appears to occur with eDocEngine 4.  I submitted a support request regarding that on Feb 9, 2013.

I did some additional testing on eDocEngine 3 under XE3, which I reported here: https://forums.embarcadero.com/message.jspa?messageID=527312 .  It appears that the problem is that, in XE3, the components are not being correctly initialized when linked for C++, although they are for Delphi.  One of the variables that should be initialized, thus, is not, and is still zero.  When it is used, the divide by zero error occurs.

My environment for testing is a brand new version of Windows 7, with a brand new installed and registered RAD Studio XE3.  Because I am using a virtual machine (Parallels on a Mac), I can use snapshots to make sure that there is no other software or component installed, so I know that the problem is with eDocEngine.  All that is required to produce the problem is dropping a TgtPDFEngine component on the form of a C++ project.  No code or other components are required.  If a TgtPDFEngine component is dropped on the form of a Delphi XE3 project, the program compiles and runs.  I thought I might try controlling the TgtPDFEngine component through a Delphi form, but no luck: if you create a C++ project, and then add a Delphi form and drop the TgtPDFEngine component on the Delphi form, the same divide by zero error occurs on program startup.

At this point, it has been well over a month since I brought this to Gnostice’s attention, with no resolution or indication that they have any clue as to how to fix it.  I cannot do any development with my new XE3 environment until they do, or alternatively I find another PDF library to use instead.  The other, non-PDF components do not seem to have this problem.  If you have any suggestions, please make a comment below.

Here is the text of my original support request, noting multiple problems with the eDocEngine installation routines under C++ Builder XE3 — I sent this request to them on Jan 18, with no substantive response as of yet (Feb 28, 2013)

 

I just installed the newest version of the three VCL products, and had some difficulties accessing them using C++

The eDocEngine VCL installation completed without issue until I came to the exporters.  I wanted to use the FastReports, DevExpress, HTMLViewer, and TRichView / ScaleRichView exporters.  All four that can be installed using your exporter generator failed immediately, and the error log that the generator said would be created was not created (and no file with that filename was created anywhere within my system)

So, THE FIRST PROBLEM is that the exporter generator fails completely, and THE SECOND PROBLEM is that the exporter generator does not create any log file.

I do have all five underlying components installed into my RAD Studio XE3 through Delphi, but with C++ files created, so that I can use them in C++ as well — I initially did that for Gnostice, since Gnostice could not use the components when installed directly into C++ (see my blog post for details: http://www.nachbar.name/2011/10/14/installing-gnostice-edocengine-in-c-builder-with-trichview/ ).  The exception is DevExpress, which just has a single installation program that installs the components into both personalities, without any options in the current version, so I have DevExpress installed using their installation program.  I am using the most current version of DevExpress, v2012 vol 2.2 .

I manually generated all five exporters per your instructions, modifying the project files to generate all C++ Files, including package libs (as I have for all of the components I have discussed, so I can use them in C++ — see http://www.nachbar.name/2011/07/16/compiling-thtmlviewer-to-use-in-c-builder-xe/ for more details on how I had generated HTMLViewer.)  Of note, your installation packages do not have an XE3 version for the HTMLViewer exporter, so I used a modified version of your XE2 version of the exporter project, so THE THIRD PROBLEM is that you do not include a project file for the HTMLViewer exporter under XE3.

All five of the exporters installed, and all but the DevExpress one can be dropped on a C++ application and the application will compile and run.  All five can be dropped in a Delphi application and the application will compile and run.

So, THE FOURTH PROBLEM is that the DevExpress exporter component causes a compile error when merely dropped on an empty form by itself.  The exact error is “Declaration terminated incorrectly”, encountered when parsing gtXPressPrntIntf.hpp after having parsed vcl.h, System.Classes.hpp, Vcl.Controls.hpp, Vcl.StdCtrls.hpp, Vcl.Forms.hpp, gtClasses3.hpp, and gtXportIntf.hpp .  The error occurs on line 282 of System.ZLib.hpp, while reading the extern DELPHI_PACKAGE char *ZLIB_VERSION; line

Other problems encountered in the exporter generator process: THE FIFTH PROBLEM is that many of the exporters have the old names for the units in the .pas files, including FastReport, which uses Graphics (which has been renamed to Vcl.Graphics), Controls, StdCtrls, and Dialogs .  By renaming those, I was able to get that exporter to compile.  The other exporters had similar problems, and required the source .pas files to be changed to get them to compile in XE3.

Then, I installed PDFToolkit VCL.  The installation went without problem, and I can drop the TgtPDFViewer on a C++ form and get the application to compile and run.  Same for TgtPDFDocument, and TgtPDFPrinter.  However, if I drop a TgtOutlineViewer on the form I get a link error: Unable to open file GTPDFOUTLINEVIEWER.OBJ .  If I drop a TgtPDFSearchPanel, I get the link error Unable to open file ‘GTPDFSEARCHPANEL.OBJ’ .

So, THE SIXTH PROBLEM is that I cannot use either of those two components in a C++ project without generating a link error.  Often, that error will occur if the .lib file containing those units is not Added to the project.  I can certainly do that manually, if you tell me which .lib library file contains those units.  Note that all five components can be added to a Delphi project without difficulty.

Finally, I installed the XtremePDFConverter.  Again, the installation went without incident.  However, when I drop a TgtPDFConverter component on a C++ form and try to build, I get a “Find Static Library” dialog, “Unable to find static library gtRTFBaseD17.lib”  .  That .lib file does not exist on my system, although gtRTFBaseD17.bpl, .dcp, .dpk, .dproj, .rc, and .res do.

So, THE SEVENTH PROBLEM is that I cannot use the XtremePDFConverter in a C++ project.  It works in a Delphi project.

Please advise how I can address these problems, specifically where I can get the missing .lib files for PDFToolkit and XtremePDFConverter (I could probably recompile the packages to create them myself, if that is your recommendation), and how I can get the DevExpress Print Exporter to work (I don’t have a clue where to start with that one).

Note that I have my system in a virtual machine, so I can easily switch between system snapshots if there are installations you would like me to test.

Thanks!