Need Guidance: Combining FreeBasic Files into One Executable & GTK Basics (Beginner Struggles!)
Need Guidance: Combining FreeBasic Files into One Executable & GTK Basics (Beginner Struggles!)
Hello again! I’m back with another FreeBasic question that’s been puzzling me. I’ve been trying to combine multiple .bas files into a single executable. I think I grasp the role of .bi files (headers for declarations?), but I’m completely lost on how to properly link my .bas files together. Do I need to add special headers or directives?
Here’s where my confusion lies:
Combining files: Do I compile each .bas separately and then link them? Or is there a way to include them all in one command?
Project structure: How do I ensure the compiler recognizes dependencies between files?
GTK libraries: The built-in SCREEN command feels limiting. I’d love to experiment with GTK for GUIs, but I’m not sure how to set it up with FreeBasic.
For example:
If I have main.bas, utils.bas, and gui.bas, how do I compile them into one program?
What steps are needed to install/include GTK libraries in FreeBasic projects?
Any advice or simple examples would be incredibly helpful! Even a nudge in the right direction (docs, tools, or workflow tips) would mean a lot. Thank you for your patience with this overwhelmed newbie!
Here’s where my confusion lies:
Combining files: Do I compile each .bas separately and then link them? Or is there a way to include them all in one command?
Project structure: How do I ensure the compiler recognizes dependencies between files?
GTK libraries: The built-in SCREEN command feels limiting. I’d love to experiment with GTK for GUIs, but I’m not sure how to set it up with FreeBasic.
For example:
If I have main.bas, utils.bas, and gui.bas, how do I compile them into one program?
What steps are needed to install/include GTK libraries in FreeBasic projects?
Any advice or simple examples would be incredibly helpful! Even a nudge in the right direction (docs, tools, or workflow tips) would mean a lot. Thank you for your patience with this overwhelmed newbie!
Re: Need Guidance: Combining FreeBasic Files into One Executable & GTK Basics (Beginner Struggles!)
.bi files usually contain thinks like declare function, while .bas have the function with the algorithm & contents
' Main.bas
#include "util.bas"
' Main.bas
#include "util.bas"
Re: Need Guidance: Combining FreeBasic Files into One Executable & GTK Basics (Beginner Struggles!)
Hi, I cannot help with GTK. There are a few examples shipped with freebasic, see:
https://github.com/freebasic/fbc/tree/m ... GUI/GTK%2B
I can not say how useful they are. I have to install some libraries first.
Concerning compiling, you can do:
see: https://www.freebasic.net/wiki/CompilerCmdLine
I however prefer to use include utils.bas and gui.bas in the main.bas.
see: https://www.freebasic.net/wiki/KeyPgInclude
E.g., main.bas:
Where utils.bas and gui.bas only contain subroutines (although not essential).
note: freebasic is not very strict concerning .bi and .bas files
https://github.com/freebasic/fbc/tree/m ... GUI/GTK%2B
I can not say how useful they are. I have to install some libraries first.
Concerning compiling, you can do:
Code: Select all
fbc main.bas utils.bas gui.bas -x myprogram
I however prefer to use include utils.bas and gui.bas in the main.bas.
see: https://www.freebasic.net/wiki/KeyPgInclude
E.g., main.bas:
Code: Select all
#include "utils.bas"
#include "gui.bas"
'main code...
note: freebasic is not very strict concerning .bi and .bas files
Re: Need Guidance: Combining FreeBasic Files into One Executable & GTK Basics (Beginner Struggles!)
Thank you very much too, this has made things much clearer to me.badidea wrote: ↑Apr 13, 2025 22:30 Hi, I cannot help with GTK. There are a few examples shipped with freebasic, see:
https://github.com/freebasic/fbc/tree/m ... GUI/GTK%2B
I can not say how useful they are. I have to install some libraries first.
Concerning compiling, you can do:see: https://www.freebasic.net/wiki/CompilerCmdLineCode: Select all
fbc main.bas utils.bas gui.bas -x myprogram
I however prefer to use include utils.bas and gui.bas in the main.bas.
see: https://www.freebasic.net/wiki/KeyPgInclude
E.g., main.bas:Where utils.bas and gui.bas only contain subroutines (although not essential).Code: Select all
#include "utils.bas" #include "gui.bas" 'main code...
note: freebasic is not very strict concerning .bi and .bas files
Re: Need Guidance: Combining FreeBasic Files into One Executable & GTK Basics (Beginner Struggles!)
Regarding GTK what operating system? On Linux, development packages are usually installed through the distro's package manager. I believe FB's include files support GTK2 (obsolete now) and GTK3.
Windows is a bit more complicated and it's been maybe 15 years since I last tried to bundle up a GTK app for Windows.
Windows is a bit more complicated and it's been maybe 15 years since I last tried to bundle up a GTK app for Windows.
Re: Need Guidance: Combining FreeBasic Files into One Executable & GTK Basics (Beginner Struggles!)
I've been using Linux for years; Windows is already an operating system that pretty much repels me at this point in my life. Currently, I mostly use a window manager like DWM. I don't know which would be better in that case, GTK or QT. I only know that if it's KDE, it's QT, and if it's Gnome, it's GTK. For simplicity, I assume I should use GTK. I'll probably port the programs I make to Windows, since all my friends unfortunately use Windows. But in that case, I was thinking of using a more appropriate solution for Windows, which I honestly have no idea about. I know nothing about Windows, and I haven't bothered to investigate yet.caseih wrote: ↑Apr 15, 2025 19:04 Regarding GTK what operating system? On Linux, development packages are usually installed through the distro's package manager. I believe FB's include files support GTK2 (obsolete now) and GTK3.
Windows is a bit more complicated and it's been maybe 15 years since I last tried to bundle up a GTK app for Windows.
Re: Need Guidance: Combining FreeBasic Files into One Executable & GTK Basics (Beginner Struggles!)
You can't really use Qt from FB. It might be possible to use QtQuick (QML) through a C binding but not the traditional widget-based system that's similar to GTK. The biggest downside to Qt is it's very much a full C++ toolkit (relying on template classes), so interfacing with it from other languages requires writing wrappers in C++ to hold the objects and then expose a C ABI inteface that other languages can talk to.
GTK does work pretty well on Windows. Gimp and Inkscape both use GTK and are available on windows. A windows binary would have to ship with the GTK dlls, rather than rely on some system-wide installation of GTK.
On Linux just make sure you have the GTK 3 development packages installed so you have the linker shared libraries and then the GTK3 examples that come with FB should compile and work.
There are some other alternatives including WX Widgets (wx-c in FB's include directory).
GTK does work pretty well on Windows. Gimp and Inkscape both use GTK and are available on windows. A windows binary would have to ship with the GTK dlls, rather than rely on some system-wide installation of GTK.
On Linux just make sure you have the GTK 3 development packages installed so you have the linker shared libraries and then the GTK3 examples that come with FB should compile and work.
There are some other alternatives including WX Widgets (wx-c in FB's include directory).
Re: Need Guidance: Combining FreeBasic Files into One Executable & GTK Basics (Beginner Struggles!)
I've never made an application that works with GTK, so you've already put me off trying QT. Honestly, I wouldn't even know where to start, but thanks for the info. At least I've confirmed that I have to get into GTK.caseih wrote: ↑Apr 15, 2025 23:53 You can't really use Qt from FB. It might be possible to use QtQuick (QML) through a C binding but not the traditional widget-based system that's similar to GTK. The biggest downside to Qt is it's very much a full C++ toolkit (relying on template classes), so interfacing with it from other languages requires writing wrappers in C++ to hold the objects and then expose a C ABI inteface that other languages can talk to.
GTK does work pretty well on Windows. Gimp and Inkscape both use GTK and are available on windows. A windows binary would have to ship with the GTK dlls, rather than rely on some system-wide installation of GTK.
On Linux just make sure you have the GTK 3 development packages installed so you have the linker shared libraries and then the GTK3 examples that come with FB should compile and work.
There are some other alternatives including WX Widgets (wx-c in FB's include directory).
Re: Need Guidance: Combining FreeBasic Files into One Executable & GTK Basics (Beginner Struggles!)
for GUI applications you could use FLTK- C-1.3.3 for FreeBASIC by D.J.Peters https://www.freebasic.net/forum/viewtopic.php?t=24547
it has quite a number of examples
it has quite a number of examples
Re: Need Guidance: Combining FreeBasic Files into One Executable & GTK Basics (Beginner Struggles!)
Okay, thanks a lot, I'll take a look at it.srvaldez wrote: ↑Apr 16, 2025 14:48 for GUI applications you could use FLTK- C-1.3.3 for FreeBASIC by D.J.Peters https://www.freebasic.net/forum/viewtopic.php?t=24547
it has quite a number of examples
Re: Need Guidance: Combining FreeBasic Files into One Executable & GTK Basics (Beginner Struggles!)
Over the years quite a few people have bemoaned the fact that there's no native GUI system in FB like there is in other BASICs. And this is a legitimate desire, but outside the scope of what FB is. FB is dependent on third-party libraries to fill this roll, as well as editors and GUI designers. Third-party GUI toolkits are generally very complicated and there's a steep learning curve. The curve is worth it, IMO, but still presents challenges.
FB is really more like a bare C compiler with a BASIC syntax than it is like other BASIC systems past and present. This is a blessing and a curse. It's not at all like, or equivalent to Visual BASIC for example.
Since you are on Linux, you might find this BASIC system interesting. It's a compiler, interpreter, development environment all in one, kind of like Visual BASIC. It's called Gambas:
https://gambaswiki.org/website/en/main.html
The learning curve might be far shallower for creating little GUI applications. I believe it is in most distributions' package repository.
FB is really more like a bare C compiler with a BASIC syntax than it is like other BASIC systems past and present. This is a blessing and a curse. It's not at all like, or equivalent to Visual BASIC for example.
Since you are on Linux, you might find this BASIC system interesting. It's a compiler, interpreter, development environment all in one, kind of like Visual BASIC. It's called Gambas:
https://gambaswiki.org/website/en/main.html
The learning curve might be far shallower for creating little GUI applications. I believe it is in most distributions' package repository.