Recent

Author Topic: ORM in Lazarus and FPC  (Read 2161 times)

StraightFree

  • New Member
  • *
  • Posts: 22
ORM in Lazarus and FPC
« 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!

mr-highball

  • Full Member
  • ***
  • Posts: 105
Re: ORM in Lazarus and FPC
« Reply #1 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.
-Highball

StraightFree

  • New Member
  • *
  • Posts: 22
Re: ORM in Lazarus and FPC
« Reply #2 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?

mr-highball

  • Full Member
  • ***
  • Posts: 105
Re: ORM in Lazarus and FPC
« Reply #3 on: December 13, 2019, 03:53:00 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
-Highball

BSaidus

  • Sr. Member
  • ****
  • Posts: 314
  • lazarus 1.8.4 Win8.1 / cross FreeBSD
Re: ORM in Lazarus and FPC
« Reply #4 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

lazarus 1.8.4 Win8.1 / cross FreeBSD
dhukmucmur vernadh!

mr-highball

  • Full Member
  • ***
  • Posts: 105
Re: ORM in Lazarus and FPC
« Reply #5 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

Nice catch, good to know!
-Highball

StraightFree

  • New Member
  • *
  • Posts: 22
Re: ORM in Lazarus and FPC
« Reply #6 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!

mr-highball

  • Full Member
  • ***
  • Posts: 105
Re: ORM in Lazarus and FPC
« Reply #7 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
-Highball

PascalDragon

  • Hero Member
  • *****
  • Posts: 905
  • Compiler Developer
Re: ORM in Lazarus and FPC
« Reply #8 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.

StraightFree

  • New Member
  • *
  • Posts: 22
Re: ORM in Lazarus and FPC
« Reply #9 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

StraightFree

  • New Member
  • *
  • Posts: 22
Re: ORM in Lazarus and FPC
« Reply #10 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!
« Last Edit: December 17, 2019, 04:41:46 pm by StraightFree »

mr-highball

  • Full Member
  • ***
  • Posts: 105
Re: ORM in Lazarus and FPC
« Reply #11 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)
-Highball

StraightFree

  • New Member
  • *
  • Posts: 22
Re: ORM in Lazarus and FPC
« Reply #12 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?

mr-highball

  • Full Member
  • ***
  • Posts: 105
Re: ORM in Lazarus and FPC
« Reply #13 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
-Highball

PascalDragon

  • Hero Member
  • *****
  • Posts: 905
  • Compiler Developer
Re: ORM in Lazarus and FPC
« Reply #14 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).