Setting up freebasic for Os dev

New to FreeBASIC? Post your questions here.
Post Reply
Boromir
Posts: 463
Joined: Apr 30, 2015 19:28
Location: Oklahoma,U.S., Earth,Solar System
Contact:

Setting up freebasic for Os dev

Post by Boromir »

I'm trying to set up freebasic to compile an OS.
http://wiki.osdev.org/FreeBASIC

Code: Select all

A normal install of FreeBasic is in most cases configured to build for the system it was installed on. That means that it will try to compile programs for linux or windows OSes, rather than your own.

To fix this, you should build at the very least a crosscompiling binutils (2.17 or later recommended). While you're at it, you can also build GCC, which comes in handy once you start porting software written in C (that includes the runtime).

FreeBasic stores its auxiliary binaries in the bin directory, or a subdirectory thereof. To get started quickly, replace ld, ar and as with the versions built in the previous step. Note that this stops FreeBasic from working on its previous host. Under windows, the bin directory is subdivided into platforms, and you can add a new one rather than modifying the existing one. To use this, create the 'linux' directory, copy i586-elf-ld, i586-elf-ar and i586-elf-as, and rename them to ld, ar and as. When running freebasic you can use the -t linux command line switch to compile for your OS instead of windows, allowing you to continue using Freebasic normally for non-os development. The Linux version does not come with this target switch - here you'll have to replace the bundled binaries with your own versions.
It says to put my new "ld, ar and as" into Freebasic's bin directory replacing the originals. But the Linux version of Freebasic doesn't have these?
St_W
Posts: 1627
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Setting up freebasic for Os dev

Post by St_W »

Those tools are only included in a "standalone" build of Freebasic (which is enabled for the windows builds, but not for the linux builds usually in official releases). In a non-standalone environment FB will use the system's ld, as, ar, etc. You could simply override by setting your PATH to include a directory containing your own binutils, but the better and cleaner solution is to provide bibaries with a target prefix and specify that when compiling FB programs. E.g. call it "x86-mysystem-ld" instead of "ld" and pass "x86-mysystem" as target to FB.

Btw there exist already a OS written in FB which might be a good place to get some inspiration: https://github.com/thrimbor/frost
Definitely worth a look.
Post Reply