FLTK headers for FreeBasic OOP (no C wrapper)
FLTK headers for FreeBasic OOP (no C wrapper)
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)
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)
Re: FLTK headers for FreeBasic OOP (no C wrapper)
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_
Re: FLTK headers for FreeBasic OOP (no C wrapper)
Interesting. I will take a look at this later when I get some free time.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: FLTK headers for FreeBasic OOP (no C wrapper)
Good job if all works but your hard coded Linux stuff makes FLTK FreeBASIC include files no more platform independent !
Joshy
Joshy
Re: FLTK headers for FreeBasic OOP (no C wrapper)
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?)
Re: FLTK headers for FreeBasic OOP (no C wrapper)
Anyone tested it?
Re: FLTK headers for FreeBasic OOP (no C wrapper)
I have but only windows 10 64 bits. No, I don't use WSL.
Re: FLTK headers for FreeBasic OOP (no C wrapper)
tested on linux distribution based on ubuntu 20.04
libfltk1.3-dev - installed
test01.bas
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()'
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_
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()'
Re: FLTK headers for FreeBasic OOP (no C wrapper)
Same (as Coolman) here, when trying to compile for 64-bit. Ubuntu Mate 18.04:
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:(.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.
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.
Re: FLTK headers for FreeBasic OOP (no C wrapper)
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?
Also, is the behavior different if you compile with "-gen gas" or with "-gen gcc" ?
Also, which version of the compiler are you using?
Re: FLTK headers for FreeBasic OOP (no C wrapper)
fltk1.3 (1.3.4-6)angros47 wrote:Which version of FLTK are you using?
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
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()'
Re: FLTK headers for FreeBasic OOP (no C wrapper)
In the file "Fl_Group.bi" try adding, at the end:
Does it fix the issue?
Code: Select all
private function Fl_Group.as_group() as Fl_Group_ ptr
return @this
end function
Re: FLTK headers for FreeBasic OOP (no C wrapper)
Yes, with both "gen gcc" and "gen gas" compile and run ok.
Re: FLTK headers for FreeBasic OOP (no C wrapper)
Thanks. Also compiles & runs the code fine BTW.Coolman wrote:for freebasic 64 bit, you must use -gen gas64