LCL without GTK lazarus / 31-LCL ---------------------------------------------------------------------- aradeonas · 2014-05-19 19:03 Hi I have a simple FreePascal program in RedHat machine,it is ok. but when I add LCL in the project and run it from Terminal it say : Gtk-WARNING **: cannot open display‏ I dont know GTK but I need LCL for my Interfaces and ... . any help? thanks ---------------------------------------------------------------------- cpalx · 2014-05-19 19:08 Where are you executing the program. It looks like you try to use a terminal (TTY) or remote conexion (maybe using putty) ---------------------------------------------------------------------- aradeonas · 2014-05-19 19:10 exactly! I only want to use LCL but i dont know how to do it in RedHat machine. its work in my win and fedora but not RedHat server. ---------------------------------------------------------------------- taazz · 2014-05-19 19:16 what do you mean with "I need lcl for my interfaces"? ---------------------------------------------------------------------- aradeonas · 2014-05-19 19:23 I use my library that it has some classes that they use Interfaces unit. ---------------------------------------------------------------------- taazz · 2014-05-19 19:30 I don not know what or how you use the interfaces.pp file but you can try to compile your application with the no gui widget set instead of gtk and see if that helps at all. ---------------------------------------------------------------------- aradeonas · 2014-05-19 19:44 tnx taazz. i use it like this : Code: [Select]TBaseFile=class(TInterfacedPersistent,IFileInterface) How can i compile with the no gui widget set? i am new in Lazarus and English! ---------------------------------------------------------------------- Dibo · 2014-05-19 20:06 Weird. TInterfacedPersistent is part of FCL, not LCL. Are you sure that you don't have unused units in "uses" clause which could require LCL? Look at warnings while compiling, you should have something like "unused unit XXX". Other thing which you could do is: Remove LCL from project required packages. Maybe you don't need LCL but some sub package which is added with LCL and doesn't use GTK. Try to add FCL and LazUtils package instead of main LCL ---------------------------------------------------------------------- aradeonas · 2014-05-19 20:22 compiler msg : QuoteUinterfaces.pas(8,54) Fatal: Can not find unit Interfaces used by UInterfaces. Check if package LCL is in the dependencies. ?! and when i add LCL,its Compile nicely but run wrongly in RedHat Server and show that error ---------------------------------------------------------------------- Dibo · 2014-05-19 20:39 UInterfaces is your unit right? Seems that you have "interfaces" unit added in "uses" clause, why? What I see "interfaces" unit is not what you think. This is unit for graphical user interface, not free pascal interface, that is why GTK, Qt and Windows widgetsets are added as dependencies. Can you remove this unit from uses clause and try to compile? ---------------------------------------------------------------------- Dibo · 2014-05-19 20:43 To clarify, you are writting console app, not GUI right? ---------------------------------------------------------------------- aradeonas · 2014-05-19 20:50 Yes. and thank you very much. its compile but in the end of compiling  show this error : QuoteConsoleTest.lpr(84,1) Error: Undefined symbol: WSRegisterCustomImageList and QuoteConsoleTest.lpr(84,1) Error: Undefined symbol: WSRegisterMenu and many other! I dont use them in a console app! thank you again. ---------------------------------------------------------------------- aradeonas · 2014-05-19 20:55 oh! i added LCLBase because i am using GetTickCount and GetPart functions and Graphics unit because of TPicture class in my program,and that make errors i said. how can i use that functions and compile without GTK? ---------------------------------------------------------------------- ahmadian · 2014-05-19 20:56 Hi I have seen this error message on Raspberry PI when I run Lazarus binary from terminal. After many search I used this command and problem solved: Xinit executablefile But the cursor shape is cross instead of arrow. ---------------------------------------------------------------------- aradeonas · 2014-05-19 21:03 thanks ahmadian i give it a try soon. i removed all of the GetTickCount and GetPart functions and Graphics unit and program compile. but its not what i want,i need those in my desktop app. how can i use this units for my console and desktop app? ---------------------------------------------------------------------- Dibo · 2014-05-19 21:22 Well, instead of GetTickCount you can use epiktimer or other solutions for time measuring. About TPicture (Graphics unit)... well, it is indeed part of LCL. Don't know why, probably it is using OS widgetset Api somewhere. Why you need TPicture? Maybe you don't need such big class like TPicture, this is wrapper for FPC graphic units, see uses clause again, you find there FPWritePNG, PNGComn, FPReadPNM, FPWritePNM, FPReadJpeg, FPWriteJpeg, FPReadTiff, FPTiffCmn, FPReadGif units. They are from FCL, not LCL, you can check how TPicture is using these units and do this same without TPicture class. I don't know your needs ---------------------------------------------------------------------- aradeonas · 2014-05-19 21:27 thanks again and again! i will test that but is there a way (with ifdef or ...) to i use tpicture in desktop app and not use it for my console app,because i dont nedd it for console app but it is is unit and i cand delete it! ? ---------------------------------------------------------------------- ahmadian · 2014-05-19 21:34 Avoiding LCL is very hard. I must have some charting and GUI for end user and I don't want the user access to desktop apps. Xinit solve my problem now. It run GUI programs from terminal and no need to enter desktop(LXDE on RPI). ---------------------------------------------------------------------- Dibo · 2014-05-19 21:38 As I said I don't know your needs for TPicture . Especially in console app, why you need it? For conversion between formats? You always can create own unit MyGraphics.pas with TMyPicture and play with FPWritePNG, PNGComn, FPReadPNM, FPWritePNM etc units and just use TMyPicture in your desktop and console app instead of TPicture. Probably a lot of coding but you will have control on everything. Or you can use third party library for graphics, like http://www.imagemagick.org/ , it has port for Free Pascal and I think that it doesn't require LCL ---------------------------------------------------------------------- Dibo · 2014-05-19 21:46 If you realy need LCL routines in your console app then you can also use LCL and build console versions for desktop enviromnents (if it is not a problem for your customer / end point user). For example console app for Qt widgetsets (KDE), Gtk (GNOME, XFCE, Unity, dont' know which RedHat is using). You need to change LCLWidget type in project options (for example GTK) and build binary, then change to Qt and build new one. User will use version which he need ---------------------------------------------------------------------- aradeonas · 2014-05-22 08:23 thanks @ahmadian : Xinit command did not work in my server but thank you. @Dibo : I test both answer but sadly my server din not graphical support. for now i made a new package and with IFDEF for all graphical part.its not a good way but fast and easy for now.