Assistance with correct install and implimentation of Raylib.gui

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
Axle
Posts: 67
Joined: May 31, 2022 6:49
Location: Australia

Assistance with correct install and implimentation of Raylib.gui

Post by Axle »

Hello FB Board

Can anyone in the FB forum explain the correct method to implement raylib and raygui (Any working version) in FreeBASIC-1.09.0 x86-64.
Preferable for Windows 8.1 through 10 (11 is optional) either with FBIde or WinFBE.

Correct library components to be used.
Correct location of the library components for compiling.
Correct Indented method of implementation in a FreeBASIC project.(A working example would be helpful)

Axle
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: Assistance with correct install and implimentation of Raylib.gui

Post by Kuan Hsu »

Axle wrote: Jun 02, 2022 23:01 Hello FB Board

Can anyone in the FB forum explain the correct method to implement raylib and raygui (Any working version) in FreeBASIC-1.09.0 x86-64.
Preferable for Windows 8.1 through 10 (11 is optional) either with FBIde or WinFBE.

Correct library components to be used.
Correct location of the library components for compiling.
Correct Indented method of implementation in a FreeBASIC project.(A working example would be helpful)

Axle
Dynamic Link Library version:

(1) Go to raylib github, download release V4.0.0 win64 version, https://github.com/raysan5/raylib/relea ... gw-w64.zip, unzip to a folder( in my case is k:/raylib-4.0.0_win64_mingw-w64 )
(2) Go to https://github.com/WIITD/raylib-freebasic, Download the zip, in my case, I unzip all *.bi to k:/raylib-4.0.0_win64_mingw-w64/include, then modified line#6 in raylib.bi,

Code: Select all

#inclib "raylib"
to

Code: Select all

#inclib "raylibdll"
(3) In my case, I use http://downloads.sourceforge.net/fbc/Fr ... z?download FBC compiler
(4) Test.bas

Code: Select all

#include "raylib.bi"

Dim As Const Integer screen_width = 800
Dim As Const Integer screen_height = 450

InitWindow(screen_width, screen_height, "Hello World")
SetTargetFPS(60)

While Not WindowShouldClose()
	BeginDrawing()
		ClearBackground(RAYWHITE)
		DrawText("Hello World from raylib and FreeBasic!", 200, 200, 20, GRAY)
	EndDrawing()
Wend

CloseWindow()
(5) "fbc64.exe" "G:/CodingPark/MyCode/FB/rayTest/Test.bas" -i "K:/raylib-4.0.0_win64_mingw-w64/include" -p "K:/raylib-4.0.0_win64_mingw-w64/lib"
(6) copy the raylib.dll and 64bit libwinpthread-1.dll( in FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win64 ) put together with Test.exe, run Test.
Axle
Posts: 67
Joined: May 31, 2022 6:49
Location: Australia

Re: Assistance with correct install and implimentation of Raylib.gui

Post by Axle »

Hi Kuan Hsu
Thank you for the concise reply :)

To Confirm:

(5) So to compile the FreeBASIC source code using the raylib binaries I must provide the links "-p" to the the location of the lib.h/lib.a.lib,dll.a and lib.dll the location to the FBC on the command line?
And is this the case when using any library included in FBC or just some cases, such as libraries not included by default with FBC?

(2) Changing #inclib "raylib" to #inclib "raylibdll"... Does this mean that the downloadable source is broken atm and can only be used as shared object?
If so, is this "#inclib "raylibdll""using Implicit or Explicit linking? I ask as I have not seen DyLibLoad() in the source or the lib.bi files, so I assume Implicit.

(6) Calls from libwinpthread-1.dll is a common common compile time linking errors I repeatedly get with many of my attempts to implement many of the raylib binders in FBC. Usually when I attempt to link statically to libraylib.a Back to (2) above, are most of the binders using one of the "shared Linking" methods?

I have attempted to use the https://github.com/WIITD/raylib-freebasic on numerous attempts along side of my many attempts using the other available binders, unfortunately documentation is missing in all cases so I was not aware of the need for the change to the lib.bi files or the run time dependencies (libwinpthread-1.dll) (I have been using the library in C with static linking previously).

Also I have a need for the raygui version 3.1... But if I can get this working it is a start and I can look at creating the raygui.bi 3.1 myself. <- this is an extended part of why I am asking about correct implementation.

If this works I will post back and confirm.

Much appreciation
Axle
Axle
Posts: 67
Joined: May 31, 2022 6:49
Location: Australia

Re: Assistance with correct install and implimentation of Raylib.gui

Post by Axle »

@Kuan Hsu

P.S.
Just curious; How does "FreeBASIC-1.09.0-winlibs-gcc-9.3.0.7z" differ from "FreeBASIC-1.09.0-win64.7z"? (The later is what I have been using since last year) Other than containing both x86 and x86-64 version in one. Also noting that it displays GCC 9.3.0 in both downloads.
Axle
Posts: 67
Joined: May 31, 2022 6:49
Location: Australia

Re: Assistance with correct install and implimentation of Raylib.gui

Post by Axle »

Hi @ Kuan Hsu

Did you test this information as working for the above example!?

raylib.bi
error 59: Illegal specification, at parameter 3 (width) of constructor stdcall(as single, as single) in 'constructor Rectangle(x as single, y as single, width as single, height as single)'

Using Keyword "width" as a variable. This binder is broken and unusable!

I will repeat my question with highlighted points for additional readabilty
Can anyone in the FB forum explain the correct method to implement raylib and raygui (Any working version)
For anyone else, Please only offer "GENUINE" Working answers.
Over one week of this nonsense now!

Axle
Xusinboy Bekchanov
Posts: 782
Joined: Jul 26, 2018 18:28

Re: Assistance with correct install and implimentation of Raylib.gui

Post by Xusinboy Bekchanov »

Axle wrote: Jun 03, 2022 11:23 raylib.bi
error 59: Illegal specification, at parameter 3 (width) of constructor stdcall(as single, as single) in 'constructor Rectangle(x as single, y as single, width as single, height as single)'

Using Keyword "width" as a variable. This binder is broken and unusable!
Change this constructor to:

Code: Select all

Constructor Rectangle(x As Single, y As Single, Width1 As Single, height As Single)
	This.x = x
	This.y = y
	This.width = Width1
	This.height = height
End Constructor
You must also copy raylib.dll to the folder of the resulting exe file.
I tested it.

Then there will be no errors.
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: Assistance with correct install and implimentation of Raylib.gui

Post by Kuan Hsu »

D.J.Peters wrote: May 31, 2022 14:54 and the bin tools comes with FreeBASIC for example the linker "ld" can't handle the static rayLib (if not build with the same gcc tool chain)
D.J.Peters had already pointed why static raylib issue.

The Static Library version: (Test 64bit)
(1) Go to raylib github, download release V4.0.0 win64 version, https://github.com/raysan5/raylib/relea ... gw-w64.zip, unzip to a folder( in my case is k:/raylib-4.0.0_win64_mingw-w64 )( The pre-compiled libraries were built under gcc-8.1.0 )
(2) Go to https://github.com/WIITD/raylib-freebasic, Download the zip, in my case, I unzip all *.bi to k:/raylib-4.0.0_win64_mingw-w64/include, then add a new line in raylib.bi:

Code: Select all

#elseif defined(__FB_WIN32__)
    #inclib "opengl32"
    #inclib "gdi32"
    #inclib "winmm"
    #inclib "shell32"     ' <- Add this line
#endif
(3) Download the FBC compiler with the same raylib pre-compiled gcc version toolchain, like FreeBASIC-1.09.0-win64-gcc-8.1.0.7z
(4) Test.bas
(5) "fbc.exe" "G:/CodingPark/MyCode/FB/rayTest/Test.bas" -i "K:/raylib-4.0.0_win64_mingw-w64/include" -p "K:/raylib-4.0.0_win64_mingw-w64/lib"
(6) Run Test (without dll )

Keypoint: The same gcc version
Last edited by Kuan Hsu on Jun 03, 2022 13:26, edited 1 time in total.
Axle
Posts: 67
Joined: May 31, 2022 6:49
Location: Australia

Re: Assistance with correct install and implimentation of Raylib.gui

Post by Axle »

Hi Kuan Hsu (Appologies)
D.J.Peters had already pointed why static raylib issue.
I am attempting to compile the examples using the shared dll as suggested. (Aka, deleting the lib.a definitions from \lib )

"I unzip all *.bi to k:/raylib-4.0.0_win64_mingw-w64/include, then add a new line in raylib.bi:"
Yes this is what I have been doing for a week and a half. (But I did do multiple command line test compiles from a cmd batch file as suggested by @Kuan Hsu)

"You must also copy raylib.dll to the folder of the resulting exe file."
Yes this is normal practice in any language, or in the system environment path.

"#inclib "shell32" ' <- Add this line"
Something that I am finding disappointing and frustration in this exercise is lack of any documentation. (Which is why I have no choice but to ask)
I have had to work of of the dependencies list from @Raysan5.

"( The pre-compiled libraries were built under gcc-8.1.0 )" So unlike the the std GCC Mingw tool chain, the FBC can only handle libraries compiled in the same GCC version. So if I were to compile the current raylib v4.0 under gcc version 9.2.0 it should work with the current fbc GCC v9.3.0?
(I will do a test using FBC gcc-8.1.0 first just to follow your instruction and confirm that it works first)

With regards to the use of the function "width" (This.width = Width1) as a variable. FBC instructions on converting C headers to Fb header (.bi) suggest using aliases for name conflicts. Width is used multiple times throughout the raylib.bi in all available versions of the binders, and oddly enough this is the first time I encountered the conflict. But anyway, wont this create a variable name conflict between the header definition and the compiled library? Or am I mistaken in that?
(Regardless I will change all of the width defines and test with your instructions).

If I sound cranky and frustrated it is because I am. I apologize for that as I am typically a friendly happy and easy person to get along with.
Over week to implement a simple library that is already included in the FBC default install is doing my head in :(
This was a 1 hour task to read the makefiles and docs sprinkled through the C library and have it compiling(the library a number of different GCC Mingw stacks) as well as compiling the examples from the pre-built binaries from @Raysan5).
I am a bit perplexed as to why this is so difficult here.

It getting late for me so I'll post back my progress in the morning. If I get one working I will follow the same and attempt to get the raylibv3.5(raygui v2,8) compiling as it is more complete.
If I can get that far I will be willing to dive into the C to BI conversion docs (+fbfrog) and use the current raylib.bi as a guide to get v40/v3.2gui done, but that will be down the road a little. 1 step at a time.

Axle
Xusinboy Bekchanov
Posts: 782
Joined: Jul 26, 2018 18:28

Re: Assistance with correct install and implimentation of Raylib.gui

Post by Xusinboy Bekchanov »

Axle wrote: Jun 03, 2022 13:05 With regards to the use of the function "width" (This.width = Width1) as a variable. FBC instructions on converting C headers to Fb header (.bi) suggest using aliases for name conflicts. Width is used multiple times throughout the raylib.bi in all available versions of the binders, and oddly enough this is the first time I encountered the conflict.
The error is only in this line, nowhere else.
Axle wrote: Jun 03, 2022 13:05 But anyway, wont this create a variable name conflict between the header definition and the compiled library? Or am I mistaken in that?
(Regardless I will change all of the width defines and test with your instructions).
The definition does not depend on the name of the function/constructor parameters. Only depends on the types of parameters passed to the function/constructor.
This function parameter is used only in this constructor, it is not visible outside of this constructor. Therefore, changing width to width1 only affects this constructor.
Axle
Posts: 67
Joined: May 31, 2022 6:49
Location: Australia

Re: Assistance with correct install and implimentation of Raylib.gui

Post by Axle »

Hi Kuan Hsu

All that was required was change of the variable name in the rectangle structure width/width1
as well as the correct linker paths, and #inclib "raylibdll".
Thank you, as this was my first question when I cam to the forum. (correct linker paths)

Using your method fbcompile.cmd

Code: Select all

SET PATH=%PATH%;C:\Dev-FreeBASIC\FreeBASIC-1.09.0-win64

fbc.exe "C:/Dev-FreeBASIC/_Raylib_Test/raylib-freebasic_v4.0/Examples_35/shapes_basic_shapes.bas" -i "C:/Dev-FreeBASIC/_Raylib_Test/raylib-freebasic_v4.0/Examples_35/include" -p "C:/Dev-FreeBASIC/_Raylib_Test/raylib-freebasic_v4.0/Examples_35/lib"

pause
Works

In FBIde (Compiler command)

Code: Select all

"<$fbc>" "<$file>" -v -exx  -i "C:/Dev-FreeBASIC/_Raylib_Test/raylib-freebasic_v4.0/Examples_35/include" -p "C:/Dev-FreeBASIC/_Raylib_Test/raylib-freebasic_v4.0/Examples_35/lib"
Works

In FBIde (Compiler command) without linker paths.. with includes and libs in the FBC \inc and \lib

Code: Select all

"<$fbc>" "<$file>" -v -exx
Works

I think it turns out that the only significant change required was the #inclib "raylib" to #inclib "raylibdll".
I have done this test may times previously as above using #inclib "raylib" and getting the ld,exe ... : undefined reference ...

I will retest the above with a fresh FBC install etc new and confirm. I will then do the same for the other binder version (*.bi)
The other headers are static header only raymath.bi, raygui.bi So I will have another look at them and see how I go.
I will also retry compiling the C raylibs in the same GCC version 9.2.0/9.3.0 with regards to the header only as static.

Thank you.
Sorry for getting my cranky on :(
Axle
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: Assistance with correct install and implimentation of Raylib.gui

Post by Kuan Hsu »

Axle wrote: Jun 03, 2022 13:05 "( The pre-compiled libraries were built under gcc-8.1.0 )" So unlike the the std GCC Mingw tool chain, the FBC can only handle libraries compiled in the same GCC version. So if I were to compile the current raylib v4.0 under gcc version 9.2.0 it should work with the current fbc GCC v9.3.0?
(I will do a test using FBC gcc-8.1.0 first just to follow your instruction and confirm that it works first)
Axle wrote: Jun 03, 2022 14:11 I think it turns out that the only significant change required was the #inclib "raylib" to #inclib "raylibdll".
I have done this test may times previously as above using #inclib "raylib" and getting the ld,exe ... : undefined reference ...
I think YES, I've tested 32bit static library by build the raylib from sources, because of I test FBC 32bit with gcc 9.3.0 / 8.1.0 / 7.1.0 all won't worked, after re-built the library it worked OK.
In the other word, if we need static link, choose the FBC compiler, download the mingw then re-build the raylib from source; if dynamic link, just change to "raylibdll".
Axle wrote: Jun 03, 2022 14:11 In FBIde (Compiler command)
For a while if you have free time, maybe you can test my poseidonFB IDE, I think it will more convenient. :D
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Assistance with correct install and implimentation of Raylib.gui

Post by D.J.Peters »

A short how to static vs dynamic

imagine this folder structure

drive:\raylib
drive:\raylib\lib\win32\libraylib.a
drive:\raylib\lib\win32\libraylib.dll.a
drive:\raylib\lib\win64\libraylib.a
drive:\raylib\lib\win64\libraylib.dll.a

drive:\raylib\bin32\raylib.dll
drive:\raylib\bin64\raylib.dll

drive:\raylib\raylib.bi
drive:\raylib\test01.bas

In both cases 32/64-bit FreeBASIC used 'BY DEFAULT' the dynamic import library 'libraylib.dll.a' and the binary test01.exe used raylib.dll und must be executed in the same folder.
fbc32 test01.bas -p lib/win32 -l raylib -x bin32/test01.exe
fbc64 test01.bas -p lib/win64 -l raylib -x bin64/test01.exe

In both cases 32/64-bit FreeBASIC used the 'STATIC' 'libraylib.a' and the binary test01.exe can be executed from any folder
fbc32 test01.bas -static -p lib/win32 -l raylib
fbc64 test01.bas -static -p lib/win64 -l raylib

so you have use #inclib "raylib" for static and dynamic linking the fbc command switch "-static" will select a static linking and by default a dynamic linking.

Joshy

Of course you don't need to use the command line use a *.bi file instead somthing like this:

Code: Select all

#ifdef STATIC_BUILD
 #cmdline "-static"
#endif
#ifdef __FB_WIN32__
 #ifndef __FB_64BIT__
  #libpath "lib/win32"
 #else
  #libpath "lib/win64"
 #endif 
#endif
#inclib "raylib" ' <--- !!! allways the same for static and dynamic linking !
' bla bla lba :-)
I self don't like this kind of folder structure
this is why I build all libraries for FreeBASIC with a different name

drive:\raylib\lib\libraylib-static-32.a
drive:\raylib\lib\libraylib-static-64.a
drive:\raylib\lib\raylib-32.dll.a
drive:\raylib\lib\raylib-64.dll.a

drive:\raylib\raylib.bi
drive:\raylib\test01.bas

drive:\raylib\raylib-32.dll
drive:\raylib\raylib-64.dll

Code: Select all

#ifdef STATIC_BUILD
 #ifndef __FB_64BIT__
  #inclib "raylib-static-32" 
 #else
  #inclib "raylib-static-64"  
 #endif
#else 
 #ifndef __FB_64BIT__
  #inclib "raylib-32" 
 #else
  #inclib "raylib-64"  
 #endif  
#endif
Axle
Posts: 67
Joined: May 31, 2022 6:49
Location: Australia

Re: Assistance with correct install and implimentation of Raylib.gui

Post by Axle »

Kuan Hsu wrote: Jun 03, 2022 14:49 For a while if you have free time, maybe you can test my poseidonFB IDE, I think it will more convenient. :D
I compared FBIde against WinFBE (Both much the same except for the extra FBC/GCC Switches built in to WinFBE.) Both have pros and cons in my context, although both do the job that is required.
Context:
  • I have to keep a very close feel of use in the Code editor or IDE across both Windows and Ubuntu. On Ubuntu I am using Geany as it has the similar SciTE feel on both platforms with FBIde on Windows.
  • I have to keep a Beginning/Learner orientation in the Editors/IDEs and Code examples.
  • This all has to be repeated with the source code examples reading virtually line for line in C, FB and Python (On Windows and Ubuntu) with the example being cross compilable.
  • Ultimately this all ends up in series of 6 Booklets aimed at getting beginners through the fundamentals of programming without scaring them away, with an emphasis on programming method as opposed to being language specific. aka the reader should learn to have some ability to understand the flow and logic from a flow chart and be able to recognize this regardless of the language, thus the "Rosetta Stone" approach for everything.
poseidonFB
Most definitely give it a shot (especially if it is working on both Win and Deb)
Current editors WIn | Deb
C - Dev-C++ (Embarcadero build 2021) | Code::Blocks
FB - FBIde | Geany
Py3 Thonny | Thonny


D.J.Peters wrote: Jun 03, 2022 20:25
The folder structure you have shown is typically how I would place files in C (GCC-MinGW) \bin \inc \lib although I will keep libraries in the project folder for some projects, setting bin, include, lib and linker paths as required.. I don't normally work of the command line and in most cases I am working off a make file to compile a library or something. SO, This confirms my question (Answered) about setting the paths for linking (aka I was doing the right thing at the beginning) :)

"fbc64 test01.bas -p lib/win64 -l raylib -x bin64/test01.exe"
and
"fbc64 test01.bas -static -p lib/win64 -l raylib"

The above was one of the original questions about sorting out the linker ld,exe errors (Some libraries I tried from memory were missing the dependencies -libgcc, -lopengl32, -lgdi32, -lwinmm although I did read somewhere in the C source or makefile "LDLIBS = -static-libgcc -lopengl32 -lgdi32 -lwinmm -static –lpthread" when building raylib from C.

lraylib vs -lraylib vs -l raylib <- etc was throwing me off
and
The FB Help was a bit scant on the use of #inclib "libname" <- I wasn't sure if the precompiler #header or gcc command line switch was the correct
usage in FB.

Quote:Kuan Hsu Chanage #inclib "raylib" to #inclib "raylibdll"
vs
"so you have use #inclib "raylib" for static and dynamic linking..."
#inclib "raylib" ' <--- !!! allways the same for static and dynamic linking !
I was looking for something along the lane of #inclib "raylib" + fbc ... -static-lraylib" <- note my incorrect syntax

Anyways Joshy, I feel confident that you have answered the questions I was getting confused over. I week or so of cram reading over the help docs, forum posts and other outside suggestions had my head in circles in the end. So that's why I came to the forum to ask for the correct method/s

The examples are an excellent help and I was looking across some of the examples for the correct formats, so thank you for confirming that for me

I apologize if I had communicated my questions poorly, and also for any frustration that showed through my posts.

Once I get on top of this I will write up raylib install, implementation guide (Some based upon what you have posted, yes I am reading and taking notes of what you suggest, and testing the suggestions) and post back as some form of guide, but I will let you know first.

Thank you
Axle
Axle
Posts: 67
Joined: May 31, 2022 6:49
Location: Australia

Re: Assistance with correct install and implimentation of Raylib.gui

Post by Axle »

@D.J.Peters and other board moderators.

This is not for self promotion and for "Context Only".

The following booklets are currently in "Draft Preview" with one of our AU tertiary institutes awaiting peer review from faculty staff and fellow students. My head of training and lecturer is an excellent mentor and gives up a portion of his free time to review and offer corrections to my work, above and beyond his pay and indentured training responsibilities.

As such, I will gift the final 6 books to the tertiary institute as a supplement for the indentured programming and coding modules, and as a thank you for my lecturers support. They will end up in the public space at some point if initial feedback is positive :)

So you are welcome to pass the PDFs to other mods if you wish, but for internal viewing and not yet for public distribution.

Again, Just for context about my questions, not for self promotion.
(The originals are supplied with source code)

5 downloads - 24 hour expiry
https://wormhole.app/P4JlN#ucGSIvrkDHCP1xXXsnhPdA

Axle

P.S. I had a peek at your YT. Ol mate does good with that guitar :P
Axle
Posts: 67
Joined: May 31, 2022 6:49
Location: Australia

Re: Assistance with correct install and implimentation of Raylib.gui

Post by Axle »

@Kuan Hsu or anyone that has an answer to this
Hi Kuan Hsu

In the previous help suggestions you recommended copying the libwinpthread-1.dll RT.
What is the purpose and where does the dependency on this dll come from?

I haven't encountered a requirement for it previously with the FBC exe outputs.

raylib as best I can tell has only required -lopengl32 -lgdi32 -lwinmm all of which the dlls usually exist on windows systems.
And I cant find any #includes in the raylib.bi for it. Raylib doesn't have any other dependencies as far as I can tell.

I did see somewhere on a forum someone suggesting (LDLIBS = -static-libgcc -lopengl32 -lgdi32 -lwinmm -static –lpthread), But that was related to cross compiling on Linux.

I get odd behavior with/without it existing beside the fbc output executable.
Without the dll the application will open the console window, but will not open the GUI window instance unless I run it as administrator (W10 x64).
If I have the libwinpthread-1.dll present it opens both the console and GUI window from a standard user account without having to invoke the run as administrator and the UAC.

I have searched everywhere looking for runtime dependencies for exes output by FBC and cant find anything, and I cant even find a doc on libwinpthread-1.dll other than the license for it. With a basic window and raylib the only dependency other than the 3 above would be the MSVCRT.dll

Any thought on why this is?
Axle
Post Reply