FLTK headers for FreeBasic OOP (no C wrapper)

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
angros47
Posts: 2073
Joined: Jun 21, 2005 19:04

FLTK headers for FreeBasic OOP (no C wrapper)

Post by angros47 »

https://github.com/angros47/FLTK-headers-for-FreeBasic

Currently a work in progress, not yet complete, but most widgets are already implemented. I have tested it with version FLTK 1.3.5, compiled for Linux. The ABI is version 1.3.0. I haven't tested under windows.

So far, it seems to work, and allows to use FLTK with the OOP interface (during the porting I have also found and reported a couple of bugs of FreeBasic compiler that have now been fixed, so last version of the compiler is recommended)
angros47
Posts: 2073
Joined: Jun 21, 2005 19:04

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by angros47 »

This is a simple example of the syntax:

Code: Select all

#include once "Fl_Window.bi"
#include once "Fl_Button.bi"

dim w as Fl_Window = Fl_Window(940,380,"Window")
	dim b as Fl_button = Fl_button(10,30,150,30,"This is a button")
w.end_()

w.show


fl.run_
Imortis
Moderator
Posts: 1879
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by Imortis »

Interesting. I will take a look at this later when I get some free time.
D.J.Peters
Posts: 8528
Joined: May 28, 2005 3:28
Contact:

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by D.J.Peters »

Good job if all works but your hard coded Linux stuff makes FLTK FreeBASIC include files no more platform independent !

Joshy
angros47
Posts: 2073
Joined: Jun 21, 2005 19:04

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by angros47 »

Linux-specific code is minimal. Once everything will work, I guess it's possible to add the needed precompiler directives to compile for Windows and Mac, as well (perhaps even for DOS?)
angros47
Posts: 2073
Joined: Jun 21, 2005 19:04

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by angros47 »

Anyone tested it?
oyster
Posts: 249
Joined: Oct 11, 2005 10:46

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by oyster »

I have but only windows 10 64 bits. No, I don't use WSL.
Coolman
Posts: 277
Joined: Nov 05, 2010 15:09

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by Coolman »

tested on linux distribution based on ubuntu 20.04

libfltk1.3-dev - installed

test01.bas

Code: Select all

#include once "Fl_Window.bi"
#include once "Fl_Button.bi"

dim w as Fl_Window = Fl_Window(940,380,"Window")
	dim b as Fl_button = Fl_button(10,30,150,30,"This is a button")
w.end_()

w.show
fl.run_
the compilation succeeds if -gen gcc is used and the program starts otherwise there is an error at compilation :

ld: test01.o:(.data.rel+0xe8): undefined reference to `Fl_Group::as_group()'
ld: test01.o:(.data.rel+0x168): undefined reference to `Fl_Group::as_group()'
badidea
Posts: 2537
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by badidea »

Same (as Coolman) here, when trying to compile for 64-bit. Ubuntu Mate 18.04:

Code: Select all

00_test.o:(.data.rel+0xe8): undefined reference to `Fl_Group::as_group()'
00_test.o:(.data.rel+0x168): undefined reference to `Fl_Group::as_group()'
Compilation failed.
When trying 32-bit, I run into linker problems (ld: cannot find -lstdc++) although I installed every possible 32-bit version of libstdc++

Edit, I fixed my 32-bit libstdc++ issue, now with 32-bit FLTK 1.3:

Code: Select all

00_test.o: In function `vtable for Fl_Group':
(.data+0x80): undefined reference to `Fl_Group::as_group()'
00_test.o: In function `vtable for Fl_Window':
(.data+0xd0): undefined reference to `Fl_Group::as_group()'
Compilation failed.
angros47
Posts: 2073
Joined: Jun 21, 2005 19:04

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by angros47 »

Which version of FLTK are you using?

Also, is the behavior different if you compile with "-gen gas" or with "-gen gcc" ?

Also, which version of the compiler are you using?
badidea
Posts: 2537
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by badidea »

angros47 wrote:Which version of FLTK are you using?
fltk1.3 (1.3.4-6)
angros47 wrote:Also, which version of the compiler are you using?

Code: Select all

fbc32 --version
FreeBASIC Compiler - Version 1.09.0 (2022-01-01), built for linux-x86 (32bit)
Copyright (C) 2004-2021 The FreeBASIC development team.

Code: Select all

fbc64 --version
FreeBASIC Compiler - Version 1.09.0 (2022-01-01), built for linux-x86_64 (64bit)
Copyright (C) 2004-2021 The FreeBASIC development team.
angros47 wrote:Also, is the behavior different if you compile with "-gen gas" or with "-gen gcc" ?

Code: Select all

fbc64 -gen gcc 00_test.bas  
00_test.o:(.data.rel+0xe8): undefined reference to `Fl_Group::as_group()'
00_test.o:(.data.rel+0x168): undefined reference to `Fl_Group::as_group()'

Code: Select all

fbc64 -gen gas 00_test.bas  
error 83: Selected -gen gas|gas64 ASM backend is incompatible with CPU, x86-64
And after switching to libfltk1.3-dev:i386:

Code: Select all

fbc32 -gen gcc 00_test.bas  
00_test.o:(.data.rel+0x84): undefined reference to `Fl_Group::as_group()'
00_test.o:(.data.rel+0xc4): undefined reference to `Fl_Group::as_group()'

Code: Select all

fbc32 -gen gas 00_test.bas  
00_test.o: In function `vtable for Fl_Group':
(.data+0x80): undefined reference to `Fl_Group::as_group()'
00_test.o: In function `vtable for Fl_Window':
(.data+0xd0): undefined reference to `Fl_Group::as_group()'
angros47
Posts: 2073
Joined: Jun 21, 2005 19:04

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by angros47 »

In the file "Fl_Group.bi" try adding, at the end:

Code: Select all

private function Fl_Group.as_group() as Fl_Group_ ptr
	return @this
end function
Does it fix the issue?
badidea
Posts: 2537
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by badidea »

Yes, with both "gen gcc" and "gen gas" compile and run ok.
Coolman
Posts: 277
Joined: Nov 05, 2010 15:09

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by Coolman »

badidea wrote: Aug 18, 2022 7:51 Yes, with both "gen gcc" and "gen gas" compile and run ok.
for freebasic 64 bit, you must use -gen gas64
badidea
Posts: 2537
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: FLTK headers for FreeBasic OOP (no C wrapper)

Post by badidea »

Coolman wrote:for freebasic 64 bit, you must use -gen gas64
Thanks. Also compiles & runs the code fine BTW.
Post Reply