Recent

Author Topic: Project inspector - OS specific packages  (Read 984 times)

TheLastCayen

  • Jr. Member
  • **
  • Posts: 81
Project inspector - OS specific packages
« on: November 08, 2019, 11:41:51 pm »
Hi

I am using:
 - Lazarus 2.0.6 64bit
 - FPC  3.0.4

I wonder if there is a way to set a package to only be Required under Linux. I mean, in the code, I can use something like {$IFDEF UNIX} {$ENDIF}. I wonder if there is an option to do it with my required package?

Let say I need to load package_hello_world under linux. Instead, in windows, I am using user32.dll ...  package_hellow_world is not compatible windows... Do I have to remove/add the dependency every time I change OS or can I do something to make it automatic?


Soner

  • Sr. Member
  • ****
  • Posts: 305
Re: Project inspector - OS specific packages
« Reply #1 on: November 09, 2019, 01:19:14 am »
Once I needed that too, but I did not find any solution for this, so I made work around for this.
Modify your package installation unit like this:
Code: Pascal  [Select][+][-]
  1. unit your_lib;
  2. // put the code below in your unit after reserverd word unit....;
  3.  {$IfNDef UNIX}
  4.  interface
  5.  implementation
  6.  end.
  7. // if your os is not  unix all code after "end." will ignored from compiler.
  8.  {$IfEnd}
  9.  
  10.  
  11. // .. here is the normal code from your lib.
  12.  
  13.  

TheLastCayen

  • Jr. Member
  • **
  • Posts: 81
Re: Project inspector - OS specific packages
« Reply #2 on: November 09, 2019, 04:40:47 am »
Thank you Soner. If there is no other option I will check for that one. Kind of not a fan since I will have to modify the package every time it's upgrade.Can also become a problem if I open the source of my app:(

 

TinyPortal © 2005-2018