Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-01

libQT4Pas - Why it is needed?

30 messages · 15 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Krzysztof

Hi,

I am wondering. If I build application for linux using gtk2 widgetset for GNOME (or XFCE etc.) and send this program to my friend, then he can run it without any external librarys (of course if he have gnome too), this same thing on windows. But why when I build application on KDE interface I need some external libQT4Pas to run it and my friend need it too (he have KDE so all QT librarys too)? There is no libGTK4Pas so why exists layer libQT4Pas? What is difference between GTK and QT librarys?

Regards

Jonas Maebe
to Krzysztof
Krzysztof wrote 5 lines
But why when I build application on KDE interface I need some external libQT4Pas to run it and my friend need it too (he have KDE so all QT librarys too)? There is no libGTK4Pas so why exists layer libQT4Pas? What is difference between GTK and QT librarys?

GTK offers a plain C interface. QT only offers a C++ interface. FPC does not (fully) support directly calling external C++ libraries. LibQT4Pas offers a plain C interface to QT for use by FPC.

Jonas

Michael Van Canneyt
to Krzysztof: I am wondering. If I build application for linux using gtk2 widgetset for GNOME (or XFCE…
Krzysztof wrote 10 lines
Hi, I am wondering. If I build application for linux using gtk2 widgetset for GNOME (or XFCE etc.) and send this program to my friend, then he can run it without any external librarys (of course if he have gnome too), this same thing on windows. But why when I build application on KDE interface I need some external libQT4Pas to run it and my friend need it too (he have KDE so all QT librarys too)? There is no libGTK4Pas so why exists layer libQT4Pas? What is difference between GTK and QT librarys?

GTK has a procedural C interface, it is exposed in the GTK libraries. The FPC compiler understands this interface.

Qt is written in C++, and exposes C++ classes in the Qt libraries. The FPC compiler does not know how to handle C++ classes. Therefor, a 'procedural' interface to the C++ needs to be made, and this is libQT4Pas. It is generated by a GCC.

Michael.

Krzysztof
to Michael Van Canneyt

Just as I thought - it is object class thing. So if "FPC does not (fully) support directly calling external C++ libraries" there are plans to support it? This will be great

2012/1/29 Michael Van Canneyt :

Show quoted text 30 lines
On Sun, 29 Jan 2012, Krzysztof wrote: > Hi, > > I am wondering. If I build application for linux using gtk2 widgetset > for GNOME (or XFCE etc.) and send this program to my friend, then he > can run it without any external librarys (of course if he have gnome > too), this same thing on windows. But why when I build application on > KDE interface I need some external libQT4Pas to run it and my friend > need it too (he have KDE so all QT librarys too)? There is no > libGTK4Pas so why exists layer libQT4Pas? What is difference between > GTK and QT librarys? GTK has a procedural C interface, it is exposed in the GTK libraries. The FPC compiler understands this interface. Qt is written in C++, and exposes C++ classes in the Qt libraries. The FPC compiler does not know how to handle C++ classes. Therefor, a 'procedural' interface to the C++ needs to be made, and this is libQT4Pas. It is generated by a GCC. Michael. _______________________________________________ fpc-pascal maillist  -   http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Lars
to Krzysztof

Do other languages like python use the plain c interface, or C++?

how about something like ruby, lua, objective C, php ..

Krzysztof wrote 42 lines
Just as I thought - it is object class thing. So if "FPC does not (fully) support directly calling external C++ libraries" there are plans to support it? This will be great 2012/1/29 Michael Van Canneyt : > > > On Sun, 29 Jan 2012, Krzysztof wrote: > >> Hi, >> >> I am wondering. If I build application for linux using gtk2 widgetset >> for GNOME (or XFCE etc.) and send this program to my friend, then he >> can run it without any external librarys (of course if he have gnome >> too), this same thing on windows. But why when I build application on >> KDE interface I need some external libQT4Pas to run it and my friend >> need it too (he have KDE so all QT librarys too)? There is no >> libGTK4Pas so why exists layer libQT4Pas? What is difference between >> GTK and QT librarys? > > > GTK has a procedural C interface, it is exposed in the GTK libraries. > The > FPC compiler understands this interface. > > Qt is written in C++, and exposes C++ classes in the Qt libraries. The > FPC > compiler does not know how to handle C++ classes. > Therefor, a 'procedural' interface to the C++ needs to be made, and this > is > libQT4Pas. It is generated by a GCC. > > Michael. > > _______________________________________________ > fpc-pascal maillist  -   > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
waldo kitty
to Lars
Lars wrote
Do other languages like python use the plain c interface, or C++? how about something like ruby, lua, objective C, php ..

:( i don't nderstand why one would want to apply interpreted script languages, al la BASIC, to today's tasks... sure, these are neat and "more modern" but they are still interpreted scripting languages :(

Show quoted text 48 lines
Krzysztof wrote: > Just as I thought - it is object class thing. So if "FPC does not > (fully) support directly calling external C++ libraries" there are > plans to support it? This will be great > > 2012/1/29 Michael Van Canneyt: >> >> >> On Sun, 29 Jan 2012, Krzysztof wrote: >> >>> Hi, >>> >>> I am wondering. If I build application for linux using gtk2 widgetset >>> for GNOME (or XFCE etc.) and send this program to my friend, then he >>> can run it without any external librarys (of course if he have gnome >>> too), this same thing on windows. But why when I build application on >>> KDE interface I need some external libQT4Pas to run it and my friend >>> need it too (he have KDE so all QT librarys too)? There is no >>> libGTK4Pas so why exists layer libQT4Pas? What is difference between >>> GTK and QT librarys? >> >> >> GTK has a procedural C interface, it is exposed in the GTK libraries. >> The >> FPC compiler understands this interface. >> >> Qt is written in C++, and exposes C++ classes in the Qt libraries. The >> FPC >> compiler does not know how to handle C++ classes. >> Therefor, a 'procedural' interface to the C++ needs to be made, and this >> is >> libQT4Pas. It is generated by a GCC. >> >> Michael. >> >> _______________________________________________ >> fpc-pascal maillist - >> http://lists.freepascal.org/mailman/listinfo/fpc-pascal >> > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
zeljko
to Krzysztof: Just as I thought - it is object class thing. So if "FPC does not (fully) support…
Krzysztof wrote
Just as I thought - it is object class thing. So if "FPC does not (fully) support directly calling external C++ libraries" there are plans to support it? This will be great

Maybe it is possible (or will be possible) to use C++ class, but I don't see light at the end of tunnel for eg override virtual routine from such C++ class which is possible by C interface or howto attach callback (event) from pascal to C++. So if it isn't possible then what's the point with C++ support ?

zeljko

Show quoted text 31 lines
2012/1/29 Michael Van Canneyt : > On Sun, 29 Jan 2012, Krzysztof wrote: >> Hi, >> >> I am wondering. If I build application for linux using gtk2 widgetset >> for GNOME (or XFCE etc.) and send this program to my friend, then he >> can run it without any external librarys (of course if he have gnome >> too), this same thing on windows. But why when I build application on >> KDE interface I need some external libQT4Pas to run it and my friend >> need it too (he have KDE so all QT librarys too)? There is no >> libGTK4Pas so why exists layer libQT4Pas? What is difference between >> GTK and QT librarys? > > GTK has a procedural C interface, it is exposed in the GTK libraries. The > FPC compiler understands this interface. > > Qt is written in C++, and exposes C++ classes in the Qt libraries. The > FPC compiler does not know how to handle C++ classes. > Therefor, a 'procedural' interface to the C++ needs to be made, and this > is libQT4Pas. It is generated by a GCC. > > Michael. > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
zeljko
to waldo kitty: :( i don't nderstand why one would want to apply interpreted script languages, al la…
waldo kitty wrote 7 lines
On 1/29/2012 17:38, Lars wrote: > Do other languages like python use the plain c interface, or C++? > > how about something like ruby, lua, objective C, php .. : :( i don't nderstand why one would want to apply interpreted script :languages,

I've understand that he asks how python bindings works then ? Probably same way as our libQt4Pas. You cannot use Qt python without python bindings for qt
- so no direct C++ usage.

zeljko

Felipe Monteiro de Carvalho
to Lars: Do other languages like python use the plain c interface, or C++? how about something…
Lars wrote
Do other languages like python use the plain c interface, or C++? how about something like ruby, lua, objective C, php ..

No idea, but Python, ruby, lua and php do not generate real programs but instead are just scripts which run in a interpreter, which is immensely different from a real program.

A more close comparison to Pascal might be asking what Fortran, Cobol, Ada or other similar compiled languages do, and I think that all of those would need a C interface.

I know very well Java due to Android work, which cannot bind to anything directly. It requires a special format using plain procedures in a special way, so it is like a C interface, or a plan Pascal procedural interface. It is called JNI and it will never accept C++

Felipe Monteiro de Carvalho
Graeme Geldenhuys
to Jonas Maebe: GTK offers a plain C interface. QT only offers a C++ interface. FPC does not (fully)…
Jonas Maebe wrote
GTK offers a plain C interface. QT only offers a C++ interface. FPC does not (fully) support directly calling external C++ libraries. LibQT4Pas offers a plain C interface to QT for use by FPC.

Can one statically bind the LibQt4Pas into a FPC program, thus not require to ship an external libqt4pas DLL/SO? If possible, that might solve the original posters problem.

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net
waldo kitty
to zeljko: I've understand that he asks how python bindings works then ? Probably same way as our…
zeljko wrote 18 lines
On Monday 30 of January 2012 03:28:45 waldo kitty wrote: > On 1/29/2012 17:38, Lars wrote: > > Do other languages like python use the plain c interface, or C++? > > > > how about something like ruby, lua, objective C, php .. > : > :( i don't nderstand why one would want to apply interpreted script > :languages, I've understand that he asks how python bindings works then ?

i may have easily misunderstood the OP's post... i tend to read in literan english format... ie: if you say eggs are round, that is where i base my response unless it is very obvious that there is something else to consider which i point out ;

zeljko
to waldo kitty
waldo kitty wrote
i may have easily misunderstood the OP's post... i tend to read in literan english format... ie: if you say eggs are round, that is where i base my response unless it is very obvious that there is something else to consider which i point out ;

I think that this question was pretty clear:

"Do other languages like python use the plain c interface, or C++?"

zeljko

Lars
to waldo kitty: :( i don't nderstand why one would want to apply interpreted script languages, al la…
waldo kitty wrote 12 lines
On 1/29/2012 17:38, Lars wrote: > Do other languages like python use the plain c interface, or C++? > > how about something like ruby, lua, objective C, php .. :( i don't nderstand why one would want to apply interpreted script languages, al la BASIC, to today's tasks... sure, these are neat and "more modern" but they are still interpreted scripting languages :(

Eh, I meant how does ruby, lua, objective c, and similar tools bind the C++ api. Do they use an automatic tool that converts QT C++ objects to procedural? or by hand, someone converts the objects to procedures and structs? Or do they use the c++ objects directly to python objects..

Lars
to Felipe Monteiro de Carvalho: No idea, but Python, ruby, lua and php do not generate real programs but instead are just…
Felipe Monteiro de Carvalho wrote 8 lines
On Sun, Jan 29, 2012 at 11:38 PM, Lars wrote: > Do other languages like python use the plain c interface, or C++? > > how about something like ruby, lua, objective C, php .. No idea, but Python, ruby, lua and php do not generate real programs but instead are just scripts which run in a interpreter, which is immensely different from a real program.

"Real Programmers"...

When you use pascal to build web programs you use templates, right.. so you are interpreting templates. When you read an INI file you are interpreting the INI file. Some pascals, safe ones, are interpreted. Like Oberon, or UCSD Pascal. When you parse an Edit.Text and check it to make sure there is not some user error on input, you are interpreting things. Compiled programs are not fully compiled, they always contain some run time interpretation. When you use regexes they are interpreted. When you use wildcards in search boxes they are interpreted. From my testing, CGI programs that are compiled binaries, are actually SlowER than PHP programs. I am no fan of PHP , but it is pretty fast.

Show quoted text 5 lines
A more close comparison to Pascal might be asking what Fortran, Cobol, Ada or other similar compiled languages do, and I think that all of those would need a C interface.

True, but still interesting to know if Python objects are somehow compatible with C++ objects, as a kind of academic exersise.. how do they do it? Possibly they just bind to procedural API, but it would be cool if they somehow did it more effectively. I also mentioned Objective C in my request but I have no idea if objective c even has a QT binding..

Show quoted text 5 lines
I know very well Java due to Android work, which cannot bind to anything directly. It requires a special format using plain procedures in a special way, so it is like a C interface, or a plan Pascal procedural interface. It is called JNI and it will never accept C++

That's good information and adds to the knowledge.. of how they do it. Cool.

Sven Barth
to zeljko: Maybe it is possible (or will be possible) to use C++ class, but I don't see light at the…
"zeljko" wrote 11 lines
On Sunday 29 of January 2012 22:16:45 Krzysztof wrote: > Just as I thought - it is object class thing. So if "FPC does not > (fully) support directly calling external C++ libraries" there are > plans to support it? This will be great Maybe it is possible (or will be possible) to use C++ class, but I don't

see light at the end of tunnel for eg override virtual routine from such C++ class which is possible by C interface or howto attach callback (event) from pascal to C++. So if it isn't possible then what's the point with C++ support ?

The C++ support in the compiler isn't advanced enough to even remotely think about that yet.

Regards,
Sven

zeljko
to Den Jean: even with support for calling c++ methods, the many inlined functions are still an issue
Den Jean wrote 7 lines
On Monday 30 January 2012 09:28:00 wrote: > There are no plans to support it, since every C++ compiler uses it's own > (incompatible) format, and G++ changes it format regularly, so I was > given to understand. even with support for calling c++ methods, the many inlined functions are still an issue

Yes, there's only one thing which can put some light over it, and that is if qt nokia decides to create pure C bindings as separate packages (dlls) for qt libs .. but it won't happen .... so long live libQt4Pas

zeljko

Sven Barth
to Unknown author: There are no plans to support it, since every C++ compiler uses it's own (incompatible)…
Show quoted text 12 lines
On Sun, 29 Jan 2012, Krzysztof wrote: > Just as I thought - it is object class thing. So if "FPC does not > (fully) support directly calling external C++ libraries" there are > plans to support it? This will be great There are no plans to support it, since every C++ compiler uses it's own (incompatible) format, and G++ changes it format regularly, so I was

given to understand.

I wouldn't say that there is no plan for C++ support as some code for this already exists in the compiler.
While it's true that different C++ compilers are incompatible to each other and that also G++ likes to change its formats now and then, the basic memory layout in G++ is rather stable. The biggest problems is getting this supported at all, interfacing with the C++ Std library and things like virtual methods, etc.

Regards,
Sven

Ludo Brands
to Lars: Eh, I meant how does ruby, lua, objective c, and similar tools bind the C++ api. Do they…
Show quoted text 7 lines
Eh, I meant how does ruby, lua, objective c, and similar tools bind the C++ api. Do they use an automatic tool that converts QT C++ objects to procedural? or by hand, someone converts the objects to procedures and structs? Or do they use the c++ objects directly to python objects..

The smoke wrapper http://techbase.kde.org/Development/Languages/Smoke is used by a lot of these languages. See also
http://lists.trolltech.com/qt-interest/2006-08/thread00721-0.html.

Smoke is actually a tool that generates runtime wrappers for c++ libraries. It supports virtual methods, multiple inheritance etc.

Ludo

zeljko
to Ludo Brands
Ludo Brands wrote 13 lines
> Eh, I meant how does ruby, lua, objective c, and similar > tools bind the > C++ api. Do they use an automatic tool that converts QT C++ objects to > procedural? or by hand, someone converts the objects to > procedures and structs? Or do they use the c++ objects > directly to python objects.. The smoke wrapper http://techbase.kde.org/Development/Languages/Smoke is used by a lot of these languages. See also http://lists.trolltech.com/qt-interest/2006-08/thread00721-0.html. Smoke is actually a tool that generates runtime wrappers for c++ libraries. It supports virtual methods, multiple inheritance etc.

Yes there's smoke but that's all... no docs - exactly nothing. I've tried to dig into and try to get out how to create simplest wrapper, lost 3-4 hours with result = 0.

zeljko

Lukasz Sokol
to Sven Barth: given to understand. I wouldn't say that there is no plan for C++ support as some code…
Sven Barth wrote 10 lines
I wouldn't say that there is no plan for C++ support as some code for this already exists in the compiler. While it's true that different C++ compilers are incompatible to each other and that also G++ likes to change its formats now and then, the basic memory layout in G++ is rather stable. The biggest problems is getting this supported at all, interfacing with the C++ Std library and things like virtual methods, etc. Regards, Sven

In layman's terms : what is the 'support level' required for this to even /start/ working at all(even if not perfect at first) and what is considered '100% supported' ? So that people who /know/ things (not me I'm afraid) can tinker it to make it better ?

L.

Sven Barth
to Lukasz Sokol
Lukasz Sokol wrote 16 lines
On 30/01/2012 11:25, Sven Barth wrote: > I wouldn't say that there is no plan for C++ support as some code for > this already exists in the compiler. While it's true that different > C++ compilers are incompatible to each other and that also G++ likes > to change its formats now and then, the basic memory layout in G++ is > rather stable. The biggest problems is getting this supported at all, > interfacing with the C++ Std library and things like virtual methods, > etc. > > Regards, Sven > In layman's terms : what is the 'support level' required for this to even /start/ working at all(even if not perfect at first) and what is considered '100% supported' ? So that people who /know/ things (not me I'm afraid) can tinker it to make it better ?

I don't know what you want to get at, but what currently works can be seen in the following test files:

http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/tests/test/cg/tcppcl1.pp?revision=16684&view=markup http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/tests/test/cg/tcppcl2.pp?revision=16684&view=markup

The corresponding C++ files are

http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/tests/test/cg/obj/cpptcl1.cpp?revision=15239&view=markup http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/tests/test/cg/obj/cpptcl2.cpp?revision=15239&view=markup

Basically this means that name mangling works and calling static methods of C++ classes. That's it currently. I had planned to extend the support a bit (you'll see my name in one of the commit messages), but I got sidetracked with other projects like NativeNT port, helper types and generics (not to mention my non-FPC-related projects).

Regards,
Sven

Andrew Haines
to Graeme Geldenhuys: Can one statically bind the LibQt4Pas into a FPC program, thus not require to ship an…
Graeme Geldenhuys wrote 9 lines
On 29 January 2012 16:31, Jonas Maebe wrote: > > GTK offers a plain C interface. QT only offers a C++ interface. FPC does not (fully) support directly calling external C++ libraries. LibQT4Pas offers a plain C interface to QT for use by FPC. > Can one statically bind the LibQt4Pas into a FPC program, thus not require to ship an external libqt4pas DLL/SO? If possible, that might solve the original posters problem.

It seems to me that you could compile qt4pas.c (or what ever the source file(s) of libqt4pas.so is) into a qt4pas.o and just link them statically with {$link qt4pas.o} which then would leave out the requirement for libqt4pas.so to be distributed with any program using the qt interface. The gpl? license may or may not make that possible though.

Regards,

Andrew

Krzysztof
to Andrew Haines
Show quoted text 9 lines
It seems to me that you could compile qt4pas.c (or what ever the source file(s) of libqt4pas.so is) into a qt4pas.o and just link them statically with {$link qt4pas.o} which then would leave out the requirement for libqt4pas.so to be distributed with any program using the qt interface. The gpl? license may or may not make that possible though. Regards, Andrew

This sounds interesting

zeljko
to Andrew Haines: It seems to me that you could compile qt4pas.c (or what ever the source file(s) of…
Andrew Haines wrote 16 lines
On 01/30/12 02:19, Graeme Geldenhuys wrote: > On 29 January 2012 16:31, Jonas Maebe wrote: >> GTK offers a plain C interface. QT only offers a C++ interface. FPC does >> not (fully) support directly calling external C++ libraries. LibQT4Pas >> offers a plain C interface to QT for use by FPC. > > Can one statically bind the LibQt4Pas into a FPC program, thus not > require to ship an external libqt4pas DLL/SO? If possible, that might > solve the original posters problem. It seems to me that you could compile qt4pas.c (or what ever the source file(s) of libqt4pas.so is) into a qt4pas.o and just link them statically with {$link qt4pas.o} which then would leave out the requirement for libqt4pas.so to be distributed with any program using the qt interface. The gpl? license may or may not make that possible though.

hm..this looks pretty interesting. Have you tried that ?

zeljko

waldo kitty
to zeljko: I think that this question was pretty clear: "Do other languages like python use the…
zeljko wrote 9 lines
On Monday 30 of January 2012 08:35:23 waldo kitty wrote: > i may have easily misunderstood the OP's post... i tend to read in literan > english format... ie: if you say eggs are round, that is where i base my > response unless it is very obvious that there is something else to consider > which i point out ; I think that this question was pretty clear: "Do other languages like python use the plain c interface, or C++?"

i understood that to mean "when interfacing with dlls" or similar :?

Vladimir Zhirov
to Lars: Do other languages like python use the plain c interface, or C++? how about something…
Do other languages like python use the plain c interface, or C++? how about something like ruby, lua, objective C, php ..

AFAIK, Lua uses automatically generated plain C binding. When I looked at it, the binding generator consisted of the following parts:
1) A C++-based program to parse C++ source and extract

   required information as XML;

2) A Lua program to build plain C binding based on this XML
3) A CMake scripts to manage building of the above parts and generated binding itself.

The corresponding source code is hosted here:
https://github.com/mkottman/lqt

zeljko
to Vladimir Zhirov
Vladimir Zhirov wrote 12 lines
> Do other languages like python use the plain c interface, or > C++? > how about something like ruby, lua, objective C, php .. AFAIK, Lua uses automatically generated plain C binding. When I looked at it, the binding generator consisted of the following parts: 1) A C++-based program to parse C++ source and extract required information as XML; 2) A Lua program to build plain C binding based on this XML 3) A CMake scripts to manage building of the above parts and generated binding itself.

Wow, that's "something" ! :)
Few years ago in age of Kylix 3 Andreas Hausladen builded C bindings for Qt3 via doxygen which created xml files and then small app builded bindings from that xml files - even virtual methods overriding was supported. So if someone have enough doxygen knowledge it is possible to create automatic C bindings with some efforts.

zeljko