Raylib v3.9 to v4.0 Install method

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

Raylib v3.9 to v4.0 Install method

Post by Axle »

Hi all

I have been hunting around the the FB forums as well as outside for a definitive answer as to how to correctly install external libraries for use in FBC.
I cannot find anything in the official help documents and suggestions from inside the forum are piecemeal and ambiguous. After 2 weeks of reading plus several days of trail and error I have made zero progress in installing a simple library. Is it possible that someone can add the method to the help documents? (Current version FB-manual-1.09.0.chm)

My main focus is in trying to install and use raylib v4.0 and additional headers such as raygui v3.1 with FreeBASIC-1.09.0-win64, but I have also made multiple attempts with FB versions of raylib v3.0 (header.bi included in the default FB install) and FB raylib v3.5.
I would prefer to use the static include libraylib.a as this is the preferred raylib way.

What I have tried so far:
  • Place multiple versions of FB-raylib in the project folder ( and sub folders) using #include "raylib.bi" as well as #inclib "raylib/raylib.a/libraylib.a ++"
  • I have also tried installing the headers for each version to "\FreeBASIC-1.09.0-win64\inc" as well as the associated version of the compiled binaries from "https://github.com/raysan5/raylib" (raylib-4.0.0_win64_mingw-w64.zip, raylib-3.5.0_win64_mingw-w64.zip, raylib-3.0.0-Win64-mingw.zip)to FreeBASIC-1.09.0-win64\lib\win64
    I originally started this exercise in FreeBASIC-1.08.1-win64
  • The most common error I encounter is "\FreeBASIC-1.09.0-win64\bin\win64\ld.exe: cannot find -lraylib" and have attempted to rename raylib.a
  • I have tried using the raylib.bi v3.0 that is installed with FBC, except the binaries are not present (I can't work out why you would place the headers in without the compiled binaries as Ray offers the lib under a liberal Mit lecence.). I have added the raylib-3.0.0-Win64-mingw.zip files to match and I still get the linker errors
I have just found another FB-raylib scrap at viewtopic.php?p=275632&hilit=raylib#p275632 http://shiny3d.de/public/libs/fbraylib/fbraylib-3.0.zip Which I have not yet attempted.
I know raylib works in FB because I have seen multiple references in the forums, yet not one description of how to and where to correctly place the library files :(
I have even seen suggestions of using the msvc binaries which to the best of my knowledge are not compatible with GCC MinGW :(

I would really like to get at a minimum raylib v3.0 working so I can work out what is required to update to raylib V4.0.
It would also be reassuring to know that I can add other simple libraries to FB if required. I use numerous other languages including C and Python and never have this much difficulty.

Any help with a step by step for what is required to install a 3rd party library will be greatly appreciated?
Axle
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Raylib v3.9 to v4.0 Install method

Post by paul doe »

You've tried everything except placing the lib where the final, compiled executable is!
Axle wrote: May 31, 2022 8:28 ...
I have even seen suggestions of using the msvc binaries which to the best of my knowledge are not compatible with GCC MinGW :(
...
Not something you should be concerned about. I tested the releases with fbc and they all work fine regardless of the runtime they were compiled with. Just make sure to be consistent when allocating/releasing memory and you should have no troubles.

Here's the set of headers for raylib 3.5:
viewtopic.php?p=279286#p279286

To test the examples, simply put a copy of a binary of raylib on the /examples folder and compile them.
Axle
Posts: 67
Joined: May 31, 2022 6:49
Location: Australia

Re: Raylib v3.9 to v4.0 Install method

Post by Axle »

Hi paul doe,

As I have said I cannot even get it to compile as it couldn't find the binaries lib.a
I have tried every version I can find and I either get linker errors lib.a not found, or linker error + a long list of other missing binary object from other libraries.

^ This included using a variety of the examples contained in the FB-Bi downloads.

I have tried EVERY version with the same result :(

What name Lib file *.a should I place in the \lib directory to match with the installed raylibv3.0.bi ?
Axle
Posts: 67
Joined: May 31, 2022 6:49
Location: Australia

Re: Raylib v3.9 to v4.0 Install method

Post by Axle »

Hi all

So what I have atm which at least compiles as a shared library...

https://github.com/glasyalabolas/fb-raylib (raylib v3.5)
With headers to \FreeBASIC-1.09.0-win64\inc

and

raylib-3.0.0-Win64-mingw (raylib v3.0)
with binaries
-libraylib_static.a
-libraylib.dll.a
-libraylib.dll
to \FreeBASIC-1.09.0-win64\lib\win64

And the example from
https://github.com/glasyalabolas/fb-ray ... shapes.bas compiles as would be expected for a normal install...

And as per expected the compiled shapes_basic_shapes.exe runs with the libraylib.dll in the path.

So, Using the v3.5 headers with the v3.0 binaries is the only time I have achieved a successful compile of the example!

I deleted the FreeBASIC intall and unpacked a clean version and retested using v3.5 headers and 3.5 binaries and compilation fails!
This has been my experience with every "Matched" version of FB-raylib and binaries from v3.0 (Default shipped with FB without binaries), FB-raylib v3.5, and FB-raylib v4.0.

Q1a.So, what is the default method of install location for the static and Implicitly linked binaries? (\FreeBASIC-1.09.0-win64\lib\win64\ ?)
Q1b.So, what is the default method of install location for the headers lib.bi ? (\FreeBASIC-1.09.0-win64\inc\ ?)
Q2.And, we cant use any library from the project folder like any other language, correct ?

Q3.How do I compile using the static linked library.. Is this a switch/define in the project source, or is it in the lib.bi header?
(I see "#define RAYGUIDEF Declare" in the header so I assume that placing #define RAYGUIDEF" should static link at compile?)

Any thoughts on attempting to match the FB-header versions with the correct Binary Lib versions?

Ultimately I need to get a working (trustworthy) version that I can use as a model to create the raylib v4.0, and raygui v3.5 includes. I have done some test samples using fbfrog so I need something to comapre the outputs again while I am learning to create the headers.

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

Re: Raylib v3.9 to v4.0 Install method

Post by Axle »

And sorry, I took that from the raygui header :(
I can't find any defines for using the static or shared in raylib.bi
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Raylib v3.9 to v4.0 Install method

Post by D.J.Peters »

Your raylib v4 download isn't for FreeBASIC it's a static mingw 64 build for C++ !
Note if you rebuild raylib V4.0 it comes in a bundle with a mingw c++ environment that isn't compatible to the FreeBASIC bin utils !

Here this static package are build for FreeBASIC (Windows 32/64-bit Linux 32/64-bi)

viewtopic.php?p=275638

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

Re: Raylib v3.9 to v4.0 Install method

Post by Axle »

Hi D.J.Peters (Correction/Joshy) Sorry, I thought I had mixed names up.

"Your raylib v4 download isn't for FreeBASIC it's a static mingw 64 build for C++ !"
No, raylib is ISOC99
The binaries are built for mingw-w64 (or 32 if you want) The header was a converted raylib.bi v4.0 .. So it should match with the binaries.
https://github.com/WIITD/*

What is the difference between fbraylib-3.0.zip and the official raylib-3.0.0-Win64-mingw.zip (Other than missing some headers on the compiler binary)?

I did try these binaries previously and they failed, but because it's 2 versions back I may have tested it with the 3.5 examples.

The version you mention v3.0 doesn't appear to have any of the additional header or raygui, which is why I gave up and tried focusing on the 3.5 version (Which still doesn't work correctly).

Ultimately I need to create the V40 headers including the raygui v3.1 headers as well as compile the binaries.. Mingw-w64 compiled binaries should work with FreeBASIC seeing that it is really just GCC MinGW-w64. C99 is C99 so the binaries should all be version compatible.

I will try again with the "Alternative Unknown" build you linked too. But it wont be of much use in the end even if I get it to compile.
You must forgive me if I am a bit skeptical about about unknown builds with no source or description!

Axle
Last edited by Axle on Jun 02, 2022 1:52, edited 2 times in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Raylib v3.9 to v4.0 Install method

Post by D.J.Peters »

You are right is C99 now but you have to compile it comlete with the same gcc tool chain as FreeBASIC used.

There isn't any precompiled rayLib 4.x you can use directly with FreeBASIC !

The rayLib installer comes with it's own tool chain (for windows and MAC) !

FreeBASIC can't handle all the structs BYVAL
FreeBASIC wrote:D:\downloads\programmierung\3d\raylib\raylib-freebasic-main\raylib.bi(856) warning 18(2): The length of the parameters list is too large, consider passing UDT's BYREF, BeginVrStereoMode
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)
FreeBASIC wrote:D:\FreeBASIC\bin\win32\ld.exe: ./libraylib.a(utils.o): bad reloc address 0x4 in section `.rdata'
This is why I build rayLib 3.x as static lib for FreeBASIC (32/64-bit Windows and Linux) with a compatible tool chain.

You can try to download or build rayLib 4.x with all extra parts GUI, 2D physic, etc. as dynamic lib *.dll for Windows and *.so for Linux.

In this case the lib used it's own runtime (from the tool chain rayLib was build with) and FreeBASIC doesn't run in to trouble while importing rayLib functions from the dynamic rayLib.

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

Re: Raylib v3.9 to v4.0 Install method

Post by Axle »

Hi D.J.Peters (Correction)

Thank you. Now I am starting to make sense of it. (..."you have to compile it comlete with the same gcc tool chain as FreeBASIC used".
Is this the same tool chain that is supplied in the FB official install with included GCC?
And as there is no makefile or mingw32-make.exe in the FB compiler set (I DID attempt to compile raylib in the FC tool chain) what are you using for the build of raylib (shared or even static)?
And would you build the library using FBC.exe or \FreeBASIC-1.09.0-win64\bin\win64gcc.exe ?
For the raylib builds I have been using "mingw32-make PLATFORM_DESKTOP" or "mingw32-make PLATFORM_DESKTOP SHARED" ++.
I am assuming (again) from looking over the FB Libraries that FB uses load-time dynamic linking (Implicit).
I have been using raylib in C to get a feel for it. I am compiling and testing from both w64devkit shipped with the raylib install as well as my default TDM-GCC-64 (gcc version 9.2.0) chain.

Have to forgive me, I am used to working in C (GCC MinGW), my use of FB is just to offer some context examples of BASIC along side of C and Python for books I am writing on programming fundamentals for my lecturer and fellow students. I don't really use FB otherwise :) But I have to keep the source flow and logic the same (near line by line) across all 3 languages as well as for Win and ubuntu. Raylib and raygui was the only library that came up with bindings across all 3 languages so that I can offer some basic examples for graphics (SDL-BGI graphics.h like) a little 2D image rendering and basic GUI and common controls. There seams to be a lot of differences in the raylib API from 3.5 to 4.0 so attempting to mix them will be problematic for me..

I will see if I can get FB raylib 3.5 and the binaries you pointed to up and running and use it as a guide/template for creating raylib/gui v4.0/3.1 FB headers (I have done some comparisons with the outputs from fbfrog) and do some research on compiling from the FB GCC tool chain.

Thank you again
Axle

P.S. I have asked about the correct location to place library files(Header, Libs and Bins) and this seams to be an unanswerable mystery? Any other language I have used you can place them in the project folder or basically anywhere in the system environment path/s, but I am guessing FB is restricted to it's FB \inc and \lib (But again, I can't find an answer to this)

P.S.S. I don't know if this exist in raylib v3.0 or v3.5/7 but raylib v4.0 has a C++14 binary mask at ~line 2306. I changed it from 0b01000000 to 0x40 to stay with the C99 std but haven't tested it against UTF-8 or Linux yet, but should be OK.
Last edited by Axle on Jun 02, 2022 1:50, edited 1 time in total.
Axle
Posts: 67
Joined: May 31, 2022 6:49
Location: Australia

Re: Raylib v3.9 to v4.0 Install method

Post by Axle »

Hi D.J.Peters (Correction I think)
Just going back over some of the different bindings versions..

paul doe appears to have created a version 3.5 of the binaries V3.0 you linked to.
https://github.com/glasyalabolas/fb-raylib
Port of raylib 3.5 headers and examples for FreeBasic

Which appears to be reasonably complete set of headers including raygui.
Do you know if there is a pre-compiled (FB build) of the binaries lib.a, lib.dll.a and lib.dll ??
Or do I have to contact @paul doe to get them?

It's really frustrating that there are all these raylib FB headers everywhere and no one puts any documentation or offers the matching binaries to go with it :(
Bit like offering up a ham and cheese sandwich without any ham and cheese filling lol
Axle
Last edited by Axle on Jun 02, 2022 1:51, edited 1 time in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Raylib v3.9 to v4.0 Install method

Post by D.J.Peters »

Why do you will use a none working static 4.0 version if you can use a working static 3.x version ?

The rayGui is a header only solution from Haubitze so it should work also:

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

Re: Raylib v3.9 to v4.0 Install method

Post by Axle »

Hi D.J.Peters/Joshy
"Why do you will use a none working static 4.0 version if you can use a working static 3.x version ?"

At this time NO version is working for me. And I have tried with every raylib binder available... Multiple times.

If I can get at least 1 version (V3.5 would be a start as the binders for the library appear complete) compiling the same version examples, that would be a start.

The biggest difficulties I am encountering appear to be linker errors.
The documentation with regards to correctly using any additional C based library in FB is virtually not existent which makes what should be a simple task exceptionally difficult.
The lack of any documentation with any of the current FB binder headings makes the entire process a guessing game.
FBC ships with a partial support for the older version 3.0 of raylib, but unlike any other libraries shipped with the FBC package there is NO binaries, either static or shared.
I am finding this extremely frustrating :(

"The rayGui is a header only solution from Haubitze so it should work also:"
raygui relies upon the equivalent raylib version as a dependency to work. It can be used as a stand alone, but you have to create/add the raylib library dependencies your self.

Why version 4.0?
Version 4.0 (raylib + extras) is the most recent and up to date release. V4.0 is what I am using in C and Python on Windows x86-64 and Ubuntu x86-64.
raygu 3.1 is the most recent version used in the same context as above.

I am writing 6 books/guides. "Beginners Guide To Programming - [module]" (Beginner to intermediate).
I have completed the first 2 " - Programming and Coding Overview" and "- Development Environment Overview"
Both currently in a final draft release with one of our tertiary training institutes in Australia for peer review and feedback so that I can make correction before release.

The books are "Programming" orientated as opposed to being language orientated. To offer programming and coding examples and keep the language independence I chose to offer ALL examples in C, FreeBASIC and Pyhthon 3. All examples are cross platform with a focus on Windows x86-64 and Ubuntu(flavours). All example will read (almost)exactly the same, side by side, line for line between the 3 languages except for the basic keyword/syntax differences. This allows the reader to focus on the common constructs(Flow, Logic, Methodology etc.) of all 3 languages keeping the focus on "programming" as opposed to "Language specific coding".

Why these 3 languages?
After much research, time, effort and past experience; C, FB and Py came up as the best "Natural" match. Python 3 is currently the most popular used language and the most common used in many educational environments. I am a bit of a C language proponent as most SOCs and SBCs (IoT) are heavily grounded in C based firmware. Python is heavily influence by C and BASIC. I usually write and test the examples for all 3 languages side by side at the same time, although I tend to use C as the test base and translate to FB and Python from the C source. Interestingly FB translates almost line for line to Python.

The final 4 books will introduce the use of Libraries and "intermediate" programming methods. One booklet will cover the description of libraries as well as there correct installation, use in development and transport the library runtime with a project release. The final 3 books will each be more language specific, but all code examples must to be able to be read side by side in a "Rosetta Stone" fashion and all use the same libraries and versions. I will introduce Command line programming with "Curses", Simple BGI style graphics with "raylib", data ploting either with raylib or "GNUPlot", GUI and basic common controls with "raygui", Audio with "raylib" (aka miniaudio), Video MM still to be decided (VLC, MPV, ffmpeg); but I may just pull it down (in size and complexity) to a simple MPEG-/2 using PL_MPEG; and cover Simple database use with flat file CSV and SQLite.

I have made FB somewhat central to these books and guides. Raylib/raygui is the simple lightweight choice for graphics and GUI basics. raylibv4.0 and rayguiv3.1 are working well on C and Python. I thought using raylib/raygui in FB would be a straight forward exercise like C and python seeing that it has supposedly been included in the FBC set for some time (raylibv3.0) but this turns out to not be the case.

If I can find or be pointed to the correct documentation on installing and using C libraries and FB bindings in FBC then it shouldn't be a difficult task (I would think), but I can't even find a basic outline on the correct locations to place a library in FB (header, binary static-shared). Most languages will recognize a library from the project folder, along side of the standar library for the language, or basically anywhere in the system path environment. In C we also need to set the location of some libraries for the linker.
I have searched the documentation for FB, searched the forum, asked, and still have no official or correct information with regards to the above.

Compiling raylib/extras and raygui is not difficult in C and although sprinkled around various makefiles and descriptions in the raysan5 wiki.
Suggestion of using msvc binaries in linking with a GCC based compiler (FBC) make me shake my head. Yes, I know that you can do it with some pointer and memory allocation trickery using "Explicit Runtime linking" to the dll, but its not a good practice and fraught with dangers when asking a green student to do it.

I ran up a few versions of raylib/raygui headers with fbfrog to peruse and there is likely enough information https://documentation.help/FreeBASIC/Tu ... WithC.html to do the conversion for raylibv4.0 myself if I see an early version of the library working correctly in FB. I am quite familiar with writing C libraries static and shared, and I have been coding in BASIC since I was 12 (40 years) so I am sure I can work it out as long as I have correct documentation/information to begin with :) C and BASIC dialects are my native tongue, but I am familiar with and will code in some 50 different languages if needed.

I searched the help docs and forums on linking these raylib headers in case that was the issue, except I can't find any "Non-Ambiguous" documents or references on linking in FBC. Generaly libraries will contain essential information such as version, license, compiling options, linking etc. Most of the converted raylib.bi shared around FB and the net have no documentation or required information. (As a note; I have noticed that some don't even contain the essential licence references required by Ramon Santamaria.)

In the end I am sure all of the above will come to have an indirect benefit on the FreeBASIC support base and users once the books are released into the public space.

So, my current challenge/s is/are:
1. Getting a complete and working copy of raylib/raygui compiling from the version examples on FBC Windows x86-64, and FBC Ubuntu x86-64. I will accept any working version including both libraries to start with. raylib and raygui are designed to be used with static linking in C, but due to OOP memory pointer allocation differences I will be happy to run with Implicit Load-Time Dynamic Linking for the moment. I will work out the static linking when I create the version 4.0 bindings.
2. Create the raylib v4.0 bindings as well as the raygui 3.1 bindings.
3. Complete the 3 books with raylib/raygui working correctly in FB, as well as providing the correct instructions for the readers to set up and use the library in FBC.

I will be greatful for any "Genuine and Correct" support documents that you can list to aid me in this task.
Axle
Post Reply