It took some time, but I think I have found a solution; description below:
Some important dots:
- I was able to use the library with C ++ Builder 11, not with version 10.4.2;
- The library installation program does not generate the .hpp files necessary for use with C ++ Builder (-JL option for the Delphi compiler);
- I had to have the .hpp files generated and also modified to allow the library to work with C ++ Builder 11
To generate the .hpp files I created a C ++ Builder project and added all the .pas files composing!
the various libraries:
Then in the C ++ project I set the generation of all files for C ++ Builder:
Of course, the other paths can also be set, according to your needs (I didn't do it).
I set the compilation order (right click on the project name in the project manager, then select “Build Order” on the context menu) according to the dependencies reported in the documentation pdfs; so first DRTE, then Mathematics, Analytics, etc.
I compiled the project before inserting any other code with the C ++ language. At this point I got the .hpp files in the same folders as the .pas, plus dcu and .obj files in the win32 (or win64) project’s folder. No errors obtained so far.
I then added a button to the project, and the code to create the TTranslator object in the Click event; next, I’ve added the related include <Analytix.Utilities.hpp> header in unit1.cpp.
Next, I compiled, but I’ve got many errors like those I’ve already reported in the first post ('Types' is not a class, namespace, or enumeration). To solve these problems (I wouldn't call them errors) I made the following substitutions in the .hpp files (I recommend keeping copies of the original files):
- “Base::Types::TFloat” replaced with “TSystemFloat”
- “Base::Types::TCharSet” replaced with “TCharSet”
- “Base::Types::TClassArray” replaced with “TClassArray”
- “Base::Types::TStringArray” replaced with “TStringArray”
- “Base::Types::TObjectArray” replaced with “TObjectArray”
Finally I commented the “using namespace” clauses in the Base.Assemblies.hpp, Base.Utilities.hpp and Base.Symbols.hpp files.
Once this was done, I compiled again and I had no more errors; Success!
below is the source of a minimal test project (unit1.cpp), with logic extracted from the demo analytics VCL in pascal:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include <Analytix.Translator.hpp>
#include <Analytix.Utilities.hpp>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TValue v;
UnicodeString vName = "b";
TFloat vValue = 2.0;
UnicodeString f = "sin(b)^2+cos(b)^2";
UnicodeString s = "";
TTranslator *FTranslator = new TTranslator();
TUtilities *Util = new TUtilities();
if (FTranslator->CheckSyntax(f)) {
FTranslator->Add(vName, vValue);
v = FTranslator->Calculate(f);
s = Util->SafeToString(v);
RichEditEvaluateResult->Text = f + " = " + s;
}
delete FTranslator;
delete Util;
}
//---------------------------------------------------------------------------
The execution:
Of course, the modifications of the .hpp files are not the best solution, nor do they guarantee good working for all functions of the library; but my experience shows that the TMS Analytics & Physics library can work with C ++ Builder.
In my modest opinion, the problem derives from the choice of the names of the DRTE library files and from the way in which the delphi compiler (dcc32.exe and dcc64.exe) generates the namespaces in the .hpp files: for the Delphi code everything is OK; on the other side, the namespaces generated in the .hpp files are not "harmonized" to work simultaneously with each other and this confuses the C ++ Builder compiler.
TMS Analytics & Phusics Pack is advertised and sold as a product for Delphi. Hope this post helps extend it to the C ++ Builder as well.