Recent

Author Topic: Download, install, and connect libraries on FPC (GTK)  (Read 614 times)

yyttyy

  • New Member
  • *
  • Posts: 15
Download, install, and connect libraries on FPC (GTK)
« on: October 19, 2020, 11:39:30 pm »
I'm New! OS: Linux mint. I googled a lot and didn't Google anything, so I had to come here. I have FPC version 3.0.4 and I want to use the gtk library in my project, namely, as I understand it, it still contains Glib, gdk and gtk itself. Here, in my directory with fpc (/usr/lib/x86_64-linux-gnu/fpc/3.0.4/units/x86_64-linux/) there is only gtk2 in which there is almost nothing, and as I understand the functions, types, data structures and constants themselves are described in a slightly different place, which is called the source code. Here is my path to the source (/usr/share/fpcsrc/3.0.4/packages/) and there is also only a gtk2 folder in which gtk.pas and very little is written in it. In General, when I was figuring out where to get the functions themselves, constants, and so on. on some site I saw that one person says: It is necessary to download the source code of Pascal and look at the functions already described there (in fact, from there I learned about the source code) and threw a link to the source code of my version of FPC (3.0.4). I downloaded it and there is a gtk1 folder, in which everything is just described! But the question is why it is not in my source code in the system. If it should not be, then how to "install"this library. Please describe the solution to this problem in as much detail as possible, because I'm quite new)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1050
  • Former Delphi 1-7, 10.2 User
Re: Download, install, and connect libraries on FPC (GTK)
« Reply #1 on: October 20, 2020, 01:25:23 am »
Welcome!

I suggest you try the Wiki article Installing Lazarus on Linux which attempts to detail the process for new users. The Wiki also has lots of other useful information. After the Main Page, the Wiki Portals (New Users, HowTo Demos, and Linux) are good places to start.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (Parallels VM)

yyttyy

  • New Member
  • *
  • Posts: 15
Re: Download, install, and connect libraries on FPC (GTK)
« Reply #2 on: October 20, 2020, 09:44:13 am »
Thank u of course, but i need only in GTK. As i understand Lazarus is IDE. I just want to use GTK library in project. So i dont want Lazarus.

PascalDragon

  • Hero Member
  • *****
  • Posts: 2402
  • Compiler Developer
Re: Download, install, and connect libraries on FPC (GTK)
« Reply #3 on: October 20, 2020, 09:59:49 am »
I'm New! OS: Linux mint. I googled a lot and didn't Google anything, so I had to come here. I have FPC version 3.0.4 and I want to use the gtk library in my project, namely, as I understand it, it still contains Glib, gdk and gtk itself. Here, in my directory with fpc (/usr/lib/x86_64-linux-gnu/fpc/3.0.4/units/x86_64-linux/) there is only gtk2 in which there is almost nothing, and as I understand the functions, types, data structures and constants themselves are described in a slightly different place, which is called the source code. Here is my path to the source (/usr/share/fpcsrc/3.0.4/packages/) and there is also only a gtk2 folder in which gtk.pas and very little is written in it. In General, when I was figuring out where to get the functions themselves, constants, and so on. on some site I saw that one person says: It is necessary to download the source code of Pascal and look at the functions already described there (in fact, from there I learned about the source code) and threw a link to the source code of my version of FPC (3.0.4). I downloaded it and there is a gtk1 folder, in which everything is just described! But the question is why it is not in my source code in the system. If it should not be, then how to "install"this library. Please describe the solution to this problem in as much detail as possible, because I'm quite new)

When you install FPC on a Linux distribution it's installed precompiled, meaning that all units for the platform are available as object files which is all that is technically needed to correctly compile applications using these units. Especially to interface with third party libraries (like GTK is) the units are simple import units.

The source code of the FPC distribution is only required to look at the source code and to understand the functionality. Even if you don't want to write Lazarus applications, but directly GTK applications, it is recommended to use an IDE, because it highly helps with navigating the source code.

For directly writing GTK applications I suggest you to take a look at the examples in $fpcsrc/packages/gtk2/examples (where $fpcsrc is the directory where you have the source code for FPC). Also I suggest you not to use gtk1 one as that is already rather old. You should concentrate on gtk2 instead or even use the GTK3 bindings provided with Lazarus in $lazdir/lcl/interfaces/gtk2/gtk3bindings (though I don't know if they can be easily used outside of Lazarus).

yyttyy

  • New Member
  • *
  • Posts: 15
Re: Download, install, and connect libraries on FPC (GTK)
« Reply #4 on: October 20, 2020, 11:18:50 am »
Thank u for the help! I understand that the fpc root directory contains precompiled files. But going to fpcsrc/packages/gtk2/examples there are examples,Yes , but where is the description of all functions, constants, and so on?

yyttyy

  • New Member
  • *
  • Posts: 15
Re: Download, install, and connect libraries on FPC (GTK)
« Reply #5 on: October 20, 2020, 11:19:36 am »
So, I may be a little stupid, but instead of using glib, gtk, I prescribed uses glib2, gtk2 and everything worked. But I did not prescribe gtk and glib with 2 for a reason. I still don't understand where it takes functions from gtk2 that should be in the gtk1 file (module). That's all I don't understand. I go to the gtk2 source and there it uses glib 2 and some other standard modules. I go to glib2 and there are generally only standard modules. Question: where are the functions from gtk1, the source and not the source of which is not in the system at All. For me, this is some kind of magic.

PascalDragon

  • Hero Member
  • *****
  • Posts: 2402
  • Compiler Developer
Re: Download, install, and connect libraries on FPC (GTK)
« Reply #6 on: October 20, 2020, 01:21:57 pm »
Thank u for the help! I understand that the fpc root directory contains precompiled files. But going to fpcsrc/packages/gtk2/examples there are examples,Yes , but where is the description of all functions, constants, and so on?

You need to look at the documentation provided by the GTK developers. FPC only provides imports for the GTK libraries, it does not provide GTK itself. We're not providing documentation for the Windows API either for example.

So, I may be a little stupid, but instead of using glib, gtk, I prescribed uses glib2, gtk2 and everything worked. But I did not prescribe gtk and glib with 2 for a reason. I still don't understand where it takes functions from gtk2 that should be in the gtk1 file (module). That's all I don't understand. I go to the gtk2 source and there it uses glib 2 and some other standard modules. I go to glib2 and there are generally only standard modules. Question: where are the functions from gtk1, the source and not the source of which is not in the system at All. For me, this is some kind of magic.

If you look at the source of the gtk2 (which is located in $fpcsrc/packages/gtk2/src/gtk+/gtk/gtk2.pas) you can see that it includes various include files and that is where the function declarations come from.

Everything you need to develop with GTK2 is contained in the compiled units that are located in (on your system) /usr/lib/x86_64-linux-gnu/fpc/3.0.4/units/x86_64-linux/gtk2 and all the source needed is inside $fpcsrc/packages/gtk2/src. The glib and gtk units are not required for GTK2 (and would probably lead to problems anyway as most systems nowadays don't have GTK1 installed).

yyttyy

  • New Member
  • *
  • Posts: 15
Re: Download, install, and connect libraries on FPC (GTK)
« Reply #7 on: October 20, 2020, 03:09:00 pm »
Ok, I understand, thank you for help!

PascalDragon

  • Hero Member
  • *****
  • Posts: 2402
  • Compiler Developer
Re: Download, install, and connect libraries on FPC (GTK)
« Reply #8 on: October 21, 2020, 09:31:37 am »
If you have more specific problems of using some GTK construct in FPC, feel free to ask.  :)

 

TinyPortal © 2005-2018