wxWidgets for FreeBASIC?

New to FreeBASIC? Post your questions here.
TheDcoder
Posts: 44
Joined: Jul 09, 2016 11:43
Location: India
Contact:

Re: wxWidgets for FreeBASIC?

Post by TheDcoder »

That is cool! I will check IUP out, thanks for the suggestion :)
Munair
Posts: 1286
Joined: Oct 19, 2017 15:00
Location: Netherlands
Contact:

Re: wxWidgets for FreeBASIC?

Post by Munair »

I also looked at the wxwidgets bindings. It's indead an older version, unfortunately.
TheDcoder
Posts: 44
Joined: Jul 09, 2016 11:43
Location: India
Contact:

Re: wxWidgets for FreeBASIC?

Post by TheDcoder »

I cannot compile any of the examples for IUP :-/

Code: Select all

E:\Projects\FreeBASIC\IUP>fbc textbox.bas
C:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: cannot find -liup
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: wxWidgets for FreeBASIC?

Post by D.J.Peters »

TheDcoder wrote:I cannot compile any of the examples for IUP :-/
I`m sure you can compile all FreeBASIC FLTK-c examples :-)

Joshy
Munair
Posts: 1286
Joined: Oct 19, 2017 15:00
Location: Netherlands
Contact:

Re: wxWidgets for FreeBASIC?

Post by Munair »

Regarding GUI libs available for FB (on Linux):

1. I cannot get IUP to work shipped with FBC 1.05. Probably the bindings contain errors. When trying to compile the example file buttons.bas I get the following output:
fbc -w all "buttons.bas"
buttons.bas(30) warning 3(1): Passing different pointer types, at parameter 2 of IUPSETFUNCTION()
buttons.bas(31) warning 3(1): Passing different pointer types, at parameter 2 of IUPSETFUNCTION()
ld: cannot find -liup
ld: cannot find -lpangox-1.0
2. FLTK doesn't seem to honor the system's theme and renders controls in a very basic gtk1-like manner. Not very attractive.

3. wxwidgets has old bindings and may also be too complex.

4. GTK seems the best choice: it integrates natively on GTK-based desktops, but also looks good on KDE (Qt). It may not be the easiest choice for GUI programming in FB, although I believe that's open for debate. Example code written in C can be translated to FB without much effort.
Last edited by Munair on Nov 09, 2017 12:34, edited 1 time in total.
St_W
Posts: 1619
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: wxWidgets for FreeBASIC?

Post by St_W »

TheDcoder wrote:I cannot compile any of the examples for IUP :-/

Code: Select all

E:\Projects\FreeBASIC\IUP>fbc textbox.bas
C:\PROGRA~2\FREEBA~1\bin\win32\ld.exe: cannot find -liup
You need to download IUP, without the libraries it simply can't work.
Here are the files: https://sourceforge.net/projects/iup/files/
And here is the documentation of IUP: http://webserver2.tecgraf.puc-rio.br/iup/ (which would have explained that you need to link the iup library on its "Getting Started" page ...)
And please read some documentation about libraries as you don't seem to have much of a clue yet how they work:
https://freebasic.net/wiki/ProPgPrebuiltLibraries
https://freebasic.net/wiki/ProPgSharedLibraries
https://freebasic.net/wiki/ProPgStaticLibraries

Munair wrote:1. I cannot get UIP to work shipped with FBC 1.05. Probably the bindings contain errors. When trying to compile the example file buttons.bas I get the following output:
fbc -w all "buttons.bas"
buttons.bas(30) warning 3(1): Passing different pointer types, at parameter 2 of IUPSETFUNCTION()
buttons.bas(31) warning 3(1): Passing different pointer types, at parameter 2 of IUPSETFUNCTION()
ld: cannot find -liup
ld: cannot find -lpangox-1.0
2. FLTK doesn't seem to honor the system's theme and renders controls in a very basic gtk1-like manner. Not very attractive.

3. wxwidgets has old bindings and may also be too complex.

4. GTK seems the best choice: it integrates natively on GTK-based desktops, but also looks good on KDE (Qt). It may not be the easiest choice for GUI programming in FB, although I believe that's open for debate. Example code written in C can be translated to FB without much effort.
1. Do you know the PEBKAC principle? I don't understand why especially beginners tend to blame the compiler or its infrastructure first instead of searching the error in their code. In pratice compiler errors etc. are very unlikely (although they definitely exist) and most of the time it's the user's fault. So don't stay a noob and start learning (see above for some documentation links where you could start). You're facing the same issue as explained above. As you're using Linux: note that libraries are usually installed system-wide, so I'd recommend to do that (alternative: adjust loader path). (on Windows libraries are usually just put into the application folder)

2. Indeed, because FLTK renders everything itself and doesn't use the system's native APIs.

3. Old bindings: agree; Complex: You will need to learn how to use any GUI library you choose. It won't work well if you don't read documentation of the according library or look at examples/tutorials.

4. GTK is probably a good choice if you target Linux only, because it's either installed by default or easily installable via a package manager. On other platforms like Mac OSX and Windows it has the same problems as FLTK: it feels "alien".
Munair
Posts: 1286
Joined: Oct 19, 2017 15:00
Location: Netherlands
Contact:

Re: wxWidgets for FreeBASIC?

Post by Munair »

St_W wrote:1. Do you know the PEBKAC principle? I don't understand why especially beginners tend to blame the compiler or its infrastructure first instead of searching the error in their code.
Despite my recent sign-up to this forum, I'm not a beginner. Regarding the above example, it is straight from a fresh fb-installation with provided include files. I did not write or adjust any code. I just opened the example file and tried to compile it. From the same installation I started coding with GTK, which works perfectly. ;)

I'm also not blaming the compiler. I would if I would find a compiler bug. This isn't one. These are third-party bindings and I cannot compile the example because IUPSETFUNCTION() apparently expects a different pointer type. Off course, I could start hacking around to solve the problem, but I prefer to spend my time writing a GUI for Linux using GTK.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: wxWidgets for FreeBASIC?

Post by MrSwiss »

Munair wrote:From the same installation I started coding with GTK, which works perfectly. ;)
This is only, because you are on Linux (see: St_W, point 4 above).
On Win you'll have the same issues, as with FLTK (headers, but no lib's.).
Munair
Posts: 1286
Joined: Oct 19, 2017 15:00
Location: Netherlands
Contact:

Re: wxWidgets for FreeBASIC?

Post by Munair »

MrSwiss wrote:
Munair wrote:From the same installation I started coding with GTK, which works perfectly. ;)
This is only, because you are on Linux (see: St_W, point 4 above).
On Win you'll have the same issues, as with FLTK (headers, but no lib's.).
No, I got FLTK to work as well, although I had some problems installing the library files correctly at first.

The two errors regarding different pointer types apply to these two lines in the example file buttons.bas:

Code: Select all

IupSetFunction( "ok_act", @ok_onclick ) 
IupSetFunction( "close_act", @close_onclick )
These errors are related to binding definitions.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: wxWidgets for FreeBASIC?

Post by MrSwiss »

Munair wrote:These errors are related to binding definitions.
As already stated (at the beginning of thread), the whole wxWigets thingy is quite old ...
Munair
Posts: 1286
Joined: Oct 19, 2017 15:00
Location: Netherlands
Contact:

Re: wxWidgets for FreeBASIC?

Post by Munair »

After a quick peak, the pointer type problem may be resolved when the iup library is installed, but I'm not sure about it. In the include files I found:

Code: Select all

type Ihandle as Ihandle_
type Icallback as function(byval as Ihandle ptr) as long
IupSetFunction(byval name as const zstring ptr, byval func as Icallback) as Icallback
but I cannot get the definition for Ihandle_
Munair
Posts: 1286
Joined: Oct 19, 2017 15:00
Location: Netherlands
Contact:

Re: wxWidgets for FreeBASIC?

Post by Munair »

MrSwiss wrote:
Munair wrote:These errors are related to binding definitions.
As already stated (at the beginning of thread), the whole wxWigets thingy is quite old ...
I was referring to IUP, not wxwidgets...
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: wxWidgets for FreeBASIC?

Post by MrSwiss »

Munair wrote:
MrSwiss wrote:As already stated (at the beginning of thread), the whole wxWigets thingy is quite old ...
I was referring to IUP, not wxwidgets... same difference
Btw: this thread is about wxWigets ...
St_W
Posts: 1619
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: wxWidgets for FreeBASIC?

Post by St_W »

Munair wrote:Regarding the above example, it is straight from a fresh fb-installation with provided include files. I did not write or adjust any code. I just opened the example file and tried to compile it. From the same installation I started coding with GTK, which works perfectly.
Yes, because you seem to have installed the GTK libraries already. Of course you need to do the same thing with the IUP library/libraries. Just like you did with FLTK (the only difference is that you can use the official libraries directly and do not need wrapper libraries as for FLTK or wxWidgets). If you're not a beginner you actually should know that as it's the same as with C/C++ (= the programming languages Linux, Windows, etc. are built upon). In fact FB just uses GNU ld, the same linker that is used for linking C applications, and what you see is it's output:
ld: cannot find -liup
ld: cannot find -lpangox-1.0
It clearly tells you that it can't find libraries "iup" and "pangox-1.0" (libraries are specified with "-l" on the linker command line). So you either haven't installed them at all, or in some location that the linker cannot find (see https://freebasic.net/wiki/CompilerOptp) or the library file is invalid (e.g. if you are providing a 32-bit library when compiling a 64-bit application).
Munair wrote:The two errors regarding different pointer types apply to these two lines in the example file buttons.bas:

Code: Select all

IupSetFunction( "ok_act", @ok_onclick )
IupSetFunction( "close_act", @close_onclick )
These errors are related to binding definitions.
These are definitely not good, especially in an example, but they are only warnings, not errors. The application will compile just fine with warnings only. Nevertheless it's something that should be fixed (probably in the example code, but I haven't take a look yet).

//edit: just had a quick look at the warnings: the callback functions "ok_onclick" and "close_onclick" should return a "long" instead of an "integer". That is a slight error in the example; it seems they haven't been fully adapted for 64-bit support. Nevertheless the application should work even without fixing that. To fix it just replace the return type "... as integer" by "... as long".
Btw. compiler warnings (or errors) are independent from a library file, as this is used during linking, not during compilation.
Munair
Posts: 1286
Joined: Oct 19, 2017 15:00
Location: Netherlands
Contact:

Re: wxWidgets for FreeBASIC?

Post by Munair »

Because I got the warnings (yes they are not errors), I did not try to install the libraries. I may do that at a later time. I feel comfortable with the fact that the FB gtk bindings work correctly with the libraries that come with my Debian distro.

I agree with MrSwiss that this thread is about wxwidgets, although viewpoints with other GUI solutions may be of benefit.
Post Reply