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.
Post Reply
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

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

Post by angros47 »

I am glad to hear. So, you have already helped me finding and fixing a mistake
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

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

Post by angros47 »

Added several updates
oyster
Posts: 274
Joined: Oct 11, 2005 10:46

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

Post by oyster »

well, this is the information in MSYS2+Mingw64 on windows 10 64 bits. Lastest `FLTK-headers-for-FreeBasic-main.zip` is downloaded directly from https://github.com/angros47/FLTK-headers-for-FreeBasic . Your simple code is used as `a.bas`
```basic
#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_
```

however
```
$ /e/msys64/home/USER/_basic/freebasic/bin/fbc.exe --version
FreeBASIC Compiler - Version 1.10.0 (2022-05-19), built for win64 (64bit)
Copyright (C) 2004-2022 The FreeBASIC development team.


$ /e/msys64/home/USER/_basic/freebasic/bin/fbc.exe -gen gas64 a.bas
C:\tmp\FLTK-headers-for-FreeBasic-main\Fl.bi(347) error 41: Calling convention does not match DECLARE prototype in 'private sub Fl.damage(d as long)'
C:\tmp\FLTK-headers-for-FreeBasic-main\Fl.bi(351) error 41: Calling convention does not match DECLARE prototype in 'private function Fl.abi_check(val_ as const long) as long'
C:\tmp\FLTK-headers-for-FreeBasic-main\Fl.bi(355) error 41: Calling convention does not match DECLARE prototype in 'private function Fl.scheme() as const zstring ptr'
C:\tmp\FLTK-headers-for-FreeBasic-main\Fl.bi(359) error 41: Calling convention does not match DECLARE prototype in 'private function Fl.is_scheme(_name as const zstring ptr) as long'
C:\tmp\FLTK-headers-for-FreeBasic-main\Fl.bi(363) error 41: Calling convention does not match DECLARE prototype in 'private function Fl.damage() as long'
C:\tmp\FLTK-headers-for-FreeBasic-main\Fl.bi(367) error 41: Calling convention does not match DECLARE prototype in 'private function Fl.modal() as Fl_Window_ ptr'
C:\tmp\FLTK-headers-for-FreeBasic-main\Fl.bi(371) error 41: Calling convention does not match DECLARE prototype in 'private function Fl.grab() as Fl_Window_ ptr'
C:\tmp\FLTK-headers-for-FreeBasic-main\Fl.bi(375) error 41: Calling convention does not match DECLARE prototype in 'private function Fl.event() as long'
C:\tmp\FLTK-headers-for-FreeBasic-main\Fl.bi(379) error 41: Calling convention does not match DECLARE prototype in 'private function Fl.event_x() as long'
C:\tmp\FLTK-headers-for-FreeBasic-main\Fl.bi(383) error 41: Calling convention does not match DECLARE prototype in 'private function Fl.event_y() as long'
C:\tmp\FLTK-headers-for-FreeBasic-main\Fl.bi(383) error 133: Too many errors, exiting

```
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

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

Post by angros47 »

Does the same issue occur also with FreeBasic 1.09?
Coolman
Posts: 294
Joined: Nov 05, 2010 15:09

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

Post by Coolman »

works perfectly under linux ubuntu 64 bits 20.04 (freeBasic 1.09).

you have done an impressive job. just need some freebasic examples to make it perfect.
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

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

Post by angros47 »

Thank you!

@oyster
Try putting at the beginning of your code (before the include lines) the line:

Code: Select all

extern "c++"
And

Code: Select all

end extern 
At the end
oyster
Posts: 274
Joined: Oct 11, 2005 10:46

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

Post by oyster »

do you mean

Code: Select all

extern "c++"

#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_

end extern
if so, I get
$ /e/prg/BASIC/fb/FreeBASIC-1.09.0-win32/fbc.exe -gen gcc a.bas
a.bas(13) error 96: Illegal inside a compound statement or scoped block in 'fl.run_'

$ /e/prg/BASIC/fb/FreeBASIC-1.09.0-win64/fbc.exe -gen gas64 a.bas
a.bas(13) error 96: Illegal inside a compound statement or scoped block in 'fl.run_'
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

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

Post by D.J.Peters »

I'm not at home so I can't test it but maybe the extern keyword must be placed after the include files !
Joshy

Code: Select all

#include once "Fl_Window.bi"
#include once "Fl_Button.bi"
extern "c++"

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_
end extern
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

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

Post by angros47 »

Try with:

Code: Select all

extern "c++"

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

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_
oyster
Posts: 274
Joined: Oct 11, 2005 10:46

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

Post by oyster »

I give up, since libraries, which do not exist on Windows OS, are used by this lib

Code: Select all

$ /e/msys64/home/USER/_basic/freebasic/bin/fbc.exe -gen gas64 a.bas
ld.exe: cannot find -lX11: No such file or directory
ld.exe: cannot find -lXrender: No such file or directory
ld.exe: cannot find -lXext: No such file or directory

angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

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

Post by angros47 »

Try removing the related "inclib" in file FL.bi
oyster
Posts: 274
Joined: Oct 11, 2005 10:46

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

Post by oyster »

congratulations, it works in my MSYS+Mingw^4 on Windows 64 bits now. And I made a pull request on github.
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

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

Post by SARG »

oyster wrote: Sep 03, 2022 11:15 $ /e/prg/BASIC/fb/FreeBASIC-1.09.0-win32/fbc.exe -gen gcc a.bas
a.bas(13) error 96: Illegal inside a compound statement or scoped block in 'fl.run_'

$ /e/prg/BASIC/fb/FreeBASIC-1.09.0-win64/fbc.exe -gen gas64 a.bas
a.bas(13) error 96: Illegal inside a compound statement or scoped block in 'fl.run_'
Jus an information, whatever the backend (gcc/gas) you use you will always get the same fbc compilation error.
The only difference is when the C or asm code is emitted but at this time all your code has been completely checked.
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

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

Post by angros47 »

Merged the pull request into the main branch
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

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

Post by angros47 »

I made several changes to Fl_Window.bi, so I ask the ones who tested my example to try with the new version
Post Reply