Lazarus

Programming => General => Topic started by: StraightFree on December 13, 2019, 02:34:07 pm

Title: ORM in Lazarus and FPC
Post by: StraightFree on December 13, 2019, 02:34:07 pm
Hello people,

I started using FPC and Lazarus recently.
In delphi I use rtti, custom attributes and class to create and maintain the database. But I realized that lazarus is not supported that way.
I found on the internet the project MORMOT. However, I could not use it.
Does anyone know a similar tool for lazarus running on linux?

Any help will be welcome.

Thank you!
Title: Re: ORM in Lazarus and FPC
Post by: mr-highball on December 13, 2019, 02:54:52 pm
FPC does support custom attributes -
https://wiki.lazarus.freepascal.org/Custom_Attributes

As far as an ORM goes mormot is probably you're best bet (I haven't used it myself). If you were to post "why" you couldn't use it, perhaps someone on the forum could guide you in the right direction.
Title: Re: ORM in Lazarus and FPC
Post by: StraightFree on December 13, 2019, 03:34:48 pm
Thanks for the quick response.

Actually, I tried to use mORMOT, but it gave unit typinfo.pp missing error.

Would you know how to resolve this dependency?
Title: Re: ORM in Lazarus and FPC
Post by: mr-highball on December 13, 2019, 03:53:00 pm
I would first recommend to use fpcupdeluxe to

this will ensure you have the latest versions and will correctly install packages, update paths etc...
I've attached a screenshot showing mormot and the way to install.

here's the program, just download for whatever your platform is:
https://github.com/LongDirtyAnimAlf/fpcupdeluxe
Title: Re: ORM in Lazarus and FPC
Post by: BSaidus on December 13, 2019, 04:23:32 pm
I would first recommend to use fpcupdeluxe to
  • install latest trunk lazarus / fpc
  • install mormot through the module list

this will ensure you have the latest versions and will correctly install packages, update paths etc...
I've attached a screenshot showing mormot and the way to install.

here's the program, just download for whatever your platform is:
https://github.com/LongDirtyAnimAlf/fpcupdeluxe

I Would recommande revisions
Code: Pascal  [Select][+][-]
  1. - FPC trunk SVN 40491
  2. - Lazarus trunk SVN 59757
  3.  
recommandation from AB
see : https://synopse.info/forum/viewtopic.php?id=4895 (https://synopse.info/forum/viewtopic.php?id=4895)

Title: Re: ORM in Lazarus and FPC
Post by: mr-highball on December 13, 2019, 04:34:44 pm
I would first recommend to use fpcupdeluxe to
  • install latest trunk lazarus / fpc
  • install mormot through the module list

this will ensure you have the latest versions and will correctly install packages, update paths etc...
I've attached a screenshot showing mormot and the way to install.

here's the program, just download for whatever your platform is:
https://github.com/LongDirtyAnimAlf/fpcupdeluxe

I Would recommande revisions
Code: Pascal  [Select][+][-]
  1. - FPC trunk SVN 40491
  2. - Lazarus trunk SVN 59757
  3.  
recommandation from AB
see : https://synopse.info/forum/viewtopic.php?id=4895 (https://synopse.info/forum/viewtopic.php?id=4895)

Nice catch, good to know!
Title: Re: ORM in Lazarus and FPC
Post by: StraightFree on December 13, 2019, 07:12:57 pm
mr-highball,

Thank you for your feedback.

I downloaded and compiled fpcupdeluxe on lazarus.
When I ran lazarus / fpc installation from fpcupdeluxe it gave the following error:

Code: Pascal  [Select][+][-]
  1. Executing: bunzip2 -d -f -q /tmp/FPCUPTMP00002.zip (working dir: )
  2. fpcupdeluxe: ERROR: FPCNativeInstaller (GetFile): Received non-zero exit code extracting bootstrap compiler. This will abort further processing.
  3. fpcupdeluxe: ERROR: FPCNativeInstaller (GetFile): Getting/extracting bootstrap compiler failed. Archive: /tmp/FPCUPTMP00002.zip
  4. fpcupdeluxe: info: FPCNativeInstaller (DownloadBinUtils): Found GNU make binary here: make.
  5. fpcupdeluxe: ERROR: FPCNativeInstaller (BuildModuleCustom: FPC): FPC bootstrap version error: 0.0.0 ! Should never happen: expect many errors !!
  6. fpcupdeluxe: info: FPCNativeInstaller (BuildModuleCustom: FPC): Running CleanModule once more before building FPC from sources, due to previous CleanModule failure.
  7. fpcupdeluxe: info: FPCNativeInstaller (CleanModule: FPC): Running  distclean failed: could not find cleanup compiler. Will try again later
  8. fpcupdeluxe: info: FPCNativeInstaller (CleanModule: FPC): Running make all install for FPC
  9. Executing: make --jobs=2 PP=/home/administrador/Documentos/dev/fpcupdeluxe-1.6.6a/deluxebin/trunk/fpcbootstrap/ppcx64 FPCMAKE=/home/administrador/Documentos/dev/fpcupdeluxe-1.6.6a/deluxebin/trunk/fpc/bin/x86_64-linux/fpcmake PPUMOVE=/home/administrador/Documentos/dev/fpcupdeluxe-1.6.6a/deluxebin/trunk/fpc/bin/x86_64-linux/ppumove FPCDIR=/home/administrador/Documentos/dev/fpcupdeluxe-1.6.6a/deluxebin/trunk/fpcsrc PREFIX=/home/administrador/Documentos/dev/fpcupdeluxe-1.6.6a/deluxebin/trunk/fpc INSTALL_PREFIX=/home/administrador/Documentos/dev/fpcupdeluxe-1.6.6a/deluxebin/trunk/fpc INSTALL_BINDIR=/home/administrador/Documentos/dev/fpcupdeluxe-1.6.6a/deluxebin/trunk/fpc/bin/x86_64-linux OS_SOURCE=linux CPU_SOURCE=x86_64 OS_TARGET=linux CPU_TARGET=x86_64 'OPT=-Sg -vw-n-h-l-d-u-t-p-c-' --directory=/home/administrador/Documentos/dev/fpcupdeluxe-1.6.6a/deluxebin/trunk/fpcsrc all install (working dir: /home/administrador/Documentos/dev/fpcupdeluxe-1.6.6a/deluxebin/trunk/fpcsrc)
  10. Makefile:135: *** Compiler /home/administrador/Documentos/dev/fpcupdeluxe-1.6.6a/deluxebin/trunk/fpcbootstrap/ppcx64 not found.  Pare.
  11.  
  12. fpcupdeluxe: ERROR: FPCNativeInstaller (CleanModule: FPC): Error running make for FPC failed with exit code 512
  13. . Details:
  14.  
  15.  
  16. ERROR: Fpcupdeluxe fatal error !
Can you tell how to solve?

Thank you!
Title: Re: ORM in Lazarus and FPC
Post by: mr-highball on December 13, 2019, 07:54:17 pm
You said you downloaded and compiled? On the "releases" page there are pre-compiled binaries for all supported platforms. Why don't you try one of these from the latest release and see if you get the same issues,
https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/tag/1.6.6a
Title: Re: ORM in Lazarus and FPC
Post by: PascalDragon on December 14, 2019, 10:47:28 am
FPC does support custom attributes -
https://wiki.lazarus.freepascal.org/Custom_Attributes
Please note that this requires the trunk version of FPC. Neither 3.0.4 nor the upcoming 3.2.0 are supporting Custom Attributes. Also they are currently only supported for types and published properties of classes due to the Extended RTTI still missing.
Title: Re: ORM in Lazarus and FPC
Post by: StraightFree on December 15, 2019, 01:28:03 pm
mr-highball,

Yes. I compiled and executed. I followed your suggestion and managed to install FPC and Lazarus from fpcupdeluxe, including the correct version as enhanced by PascalDragon.

But when compiling some examples of mORMOT, is giving error.

Delete everything and I will try to install again to see if the error persists.

Have any of you faced a similar problem?

Thank you for your help
Title: Re: ORM in Lazarus and FPC
Post by: StraightFree on December 17, 2019, 04:40:08 pm
Folks,

By uninstalling and installing again, I was able to make some of the examples work.

I have a problem now declaring custom attributes (TCustomAtributte), lazarus returns the following error:

uCustomAttributeTypeFields.pas (12,27) Error: Identifier not found "TCustomAttribute".

I try to compile the exemple in this link:
https://wiki.freepascal.org/Custom_Attributes

But, the same error occurs.

Has anyone ever experienced this?
Have any suggestions on how to solve?

Any help will be most welcome.

Thank you!
Title: Re: ORM in Lazarus and FPC
Post by: mr-highball on December 17, 2019, 04:49:45 pm
FPC does support custom attributes -
https://wiki.lazarus.freepascal.org/Custom_Attributes
Please note that this requires the trunk version of FPC. Neither 3.0.4 nor the upcoming 3.2.0 are supporting Custom Attributes. Also they are currently only supported for types and published properties of classes due to the Extended RTTI still missing.

when compiling fpc/lazarus did you make sure you selected trunk? as @PascalDragon pointed out above, these are a new feature and are only supported with the latest build (see selection in attached image)
Title: Re: ORM in Lazarus and FPC
Post by: StraightFree on December 17, 2019, 07:01:27 pm
mr-highball,

Thanks for the reply.

Actually had done the installation of trunk version.

I deleted everything and tried to install the trunkgit version.
The installation of fpc happens without any error, but the installation of lazarus gives the following error:

"/home/administrator/Documents/dev/fpcupdeluxe/trunkgit/lazarus/components/codetools/definetemplates.pas(323,25) Fatal: (2003) Syntax error,") "expected but", "found
Fatal: (1018) Compilation aborted
Error: / home / admin / Documents / dev / fpcupdeluxe / trunkgit / fpc / bin / x86_64-linux / ppcx64 returned an error exitcode
make: *** [Makefile: 3257: codetools] Error 2
fpcupdeluxe: ERROR: LazarusNativeInstaller (BuildModuleCustom: Lazbuild): make returned error code # 512


ERROR: Fpcupdeluxe fatal error! "

Can you tell the cause or have any suggestions for a solution?
Title: Re: ORM in Lazarus and FPC
Post by: mr-highball on December 17, 2019, 07:05:18 pm
Hmm, I'm not sure about why you're having that. Unfortunately I don't have a linux machine in front of me to test with (I use windows primarily). Perhaps someone else has seen the issue?
Also, you could look/post an issue on the maintainers github,
https://github.com/LongDirtyAnimAlf/fpcupdeluxe/issues
Title: Re: ORM in Lazarus and FPC
Post by: PascalDragon on December 18, 2019, 09:43:50 am
I have a problem now declaring custom attributes (TCustomAtributte), lazarus returns the following error:

uCustomAttributeTypeFields.pas (12,27) Error: Identifier not found "TCustomAttribute".

I try to compile the exemple in this link:
https://wiki.freepascal.org/Custom_Attributes

But, the same error occurs.
Do you really use a current trunk of FPC? Do you either use {$mode Delphi} or {$mode ObjFPC} followed by {$modeswitch PrefixedAttributes}? Would you please test the example from the Wiki and compile on a command line using fpc theexample.pp and provide the output here? You can also run fpc -iV to check what version FPC reports (it should be 3.3.1).
Title: Re: ORM in Lazarus and FPC
Post by: Thaddy on December 18, 2019, 10:23:25 am
You can also run fpc -iV to check what version FPC reports (it should be 3.3.1).
Well, you also would need the revision, since trunk is a moving target. All wiki examples compile, but there are already more features in place. As you know... :-X
(That's the reason I always compile my trunk with the revision built-in.)
Title: Re: ORM in Lazarus and FPC
Post by: StraightFree on December 19, 2019, 01:30:51 pm
PascalDragon and Thaddy,

Thanks for your reply.


I am using the below version of FPC and lazarus.

PascalDragon, I am using FPCUPdeluxe to install FPC and Lazarus. The trunk version installs without problems, but there is an error trying to compile the example of this link (https://wiki.freepascal.org/Custom_Attributes#Complete_example (https://wiki.freepascal.org/Custom_Attributes#Complete_example)). The error that returns is as follows:

Code: Pascal  [Select][+][-]
  1. "project1.lpr (19.31) Error: Identifier not found" TCustomAttribute ""

When attempting to install the trunkgit version as directed by mr-highball, the installation is not completed. I posted an issue with the error returned in installing this version at this link:

https://github.com/LongDirtyAnimAlf/fpcupdeluxe/issues/167 (https://github.com/LongDirtyAnimAlf/fpcupdeluxe/issues/167)

Have any of you been able to install by FPCUPDeluxe the latest version of FPC and Lazarus and compile the example with TCustomAttribute?

Thank you so much for your help.
Title: Re: ORM in Lazarus and FPC
Post by: DonAlfredo on December 19, 2019, 01:33:33 pm
Will be solved !

https://forum.lazarus.freepascal.org/index.php/topic,47835.msg343467
Title: Re: ORM in Lazarus and FPC
Post by: StraightFree on December 19, 2019, 01:52:39 pm
DonAlfredo,

Thanks for your reply.

I will follow the other topic.
I hope you correct this issue soon.

Thanks again for the help!
Title: Re: ORM in Lazarus and FPC
Post by: Pascal on December 19, 2019, 01:59:12 pm
Have any of you been able to install by FPCUPDeluxe the latest version of FPC and Lazarus and compile the example with TCustomAttribute?

No problems here with handmade checkout and build of FPC trunk (r43677) and Lazarus trunk (r62379).
Title: Re: ORM in Lazarus and FPC
Post by: StraightFree on December 19, 2019, 02:05:54 pm
Pascal,

So in that case, do you manually download and install without FPCUPDeluxe?
After installing FPC and Lazarus, how do you install MORMOT?

Thanks for the answer.
Title: Re: ORM in Lazarus and FPC
Post by: Pascal on December 19, 2019, 02:08:47 pm
Sorry, i do not use mORMot. My answer just belongs to the quote.
Title: Re: ORM in Lazarus and FPC
Post by: StraightFree on December 19, 2019, 02:13:27 pm
Pascal,

Got it.
I will wait for DonAlfredo's answer in the other topic.

Thanks for tour reply.
Title: Re: ORM in Lazarus and FPC
Post by: DonAlfredo on December 19, 2019, 02:51:12 pm
The documentation of mORMot has some tips !!

https://synopse.info/files/html/Synopse%20mORMot%20Framework%20SAD%201.18.html#TITL_203

In Setup+, you can add revisions for FPC and Lazarus. These will certainly work !
Title: Re: ORM in Lazarus and FPC
Post by: jus on December 19, 2019, 06:53:56 pm
@StraightFree: if you need only a persistence framework to separate the business logic you can also give TIOPF (http://tiopf.sourceforge.net/) a try. It works for Delphi and Lazarus.

There are also youtube videos available:
tiOPF Model GUI Mediator / MVP - Part 1 (https://youtu.be/FBw_3gXxyeI)
tiOPF Model GUI Mediator / MVP - Part 2 (https://youtu.be/cI7XkZ0GR0s)
tiOPF Model GUI Mediator / MVP - Part 3 (https://youtu.be/CdsJ6FHs3vM)

jus
Title: Re: ORM in Lazarus and FPC
Post by: StraightFree on December 20, 2019, 04:40:44 pm
jus,

In fact, I need to use RTTI and custom attributes to do database creation and maintenance.

I found the solution in madref's post in the following topic (https://forum.lazarus.freepascal.org/index.php/topic,47835.0.html (https://forum.lazarus.freepascal.org/index.php/topic,47835.0.html)).

I resolved the issue by installing fpcdeluxe version 1.6.4h.

I'll do some tests to verify its operation.

Thank you all for your help.
TinyPortal © 2005-2018