News:

Welcome to RetroCoders Community

Main Menu

how to set up FreeBASIC for compiling running and coding

Started by ron77, Sep 11, 2022, 11:42 AM

Previous topic - Next topic

ron77

Hello here is how you can configure notepad++ for compiling freeBASIC code using the plugin Nppexec

1. first download freeBASIC compiler (either 32 bit or 64 bit) extract and save it where you remember

2. install notepad++ and in Plugins -> Plugins Admin... choose to install the plugin Nppexec and restart notepad++

3. open a freeBASIC .bas file and Press F6 and save this script:

npp_save

CD $(CURRENT_DIRECTORY)

"path-to-the-freebasic-compiler-fbc.exe" -s console -gen gcc -Wc -Ofast -Wc -Wno-maybe-uninitialized -exx -w all "$(FILE_NAME)"

4. save this script to compile with fbc.exe (freebasic compiler)

5. to RUN the executable press F5 and select the executable and click "Run"

6. for comments in freebasic to work correctly by "Ctrl + Q" or "Ctrl + K" shortcuts:

Open Notepad++ language config file:
C:\Users\<user name>\AppData\Roaming\Notepad++\langs.xml
Scroll down to  <Language name="freebasic" (or other depending on what language you want to modify)
Add to commentLine="" a ' like so commentLine="'" 
Restart Notepad++

that's it :)

johnno56

Ron,

As you may be aware, I run with Linux and Notepad++ may or may not run correctly, using Wine.
I do have Geany installed, which comes with a freebasic config file, but I was wondering if you could list any other IDE's that may be suitable?

Thank you.

J
May your journey be free of incident.  Live long and prosper.

ron77

hello, johnno56 the notepad++ might very well not work correctly under wine under Linux -

I used freebasic in the past under Linux, and I found that the options for an IDE where the following.

1. (number one the simplest and easiest) Geany IDE - comes ready-made for freebasic

2. (number two) Poseidon FB IDE - which for linux comes as an AppImage - the only downside is that the freebasic CHM help files - documentation will have to be opened by another app (kchmviewer or some other)...

here is the link from FB Site: https://freebasic.net/forum/viewtopic.php?t=23935

3. (third option a bit complex to install but worthwhile) is IUP_FB_EDITOR which you need to install first IUP libraries on your linux and make a configuration file - then the IDE should work just fine including CHMVIEW lib to enable the view of the chm documentation files

here is the link: https://www.freebasic.net/forum/viewtopic.php?t=26030

my advice to you is to try Geany or Poseidon FB IDE as you do not have to make changes to your system too much so...

hope you find this useful and thank you for clearing that Linux should also be supported using freebasic on this forum - btw may I ask what distro of linux you are using? I used to use UBUNTU 20.04

ron77

johnno56

Ron,

Thank you for replying so quickly and thank you for the suggestions.

I will probably use geany as I already have it installed. I am currently using the freebasic config file to run RCBasic. RCBasic now has a 'Studio', so it looks like I am going to learn that as well, which should return freebasic back to geany... Ah. More learning... Gotta love it... lol

I will check out Poseidon and get back to you...

I am current using Linux Mint 20.3 (compatible with Ubumtu 20.04)

May your journey be free of incident.  Live long and prosper.

johnno56

Ron,

D/L PoseidonFB; Set paths to compiler and terminal.

Entered a simple 'hello world' program and compiled...

cls
print "Hello World"

It returned with 'ld: cannot find -lncurses'

Are there any detailed instruction for setting up Poseidon for Linux?

I did notice a cool function to modify the overall 'theme' colours. Are there a collection of themes or would I need to experiment? Moo Ha Ha...
May your journey be free of incident.  Live long and prosper.

johnno56

Never mind - found out libncurses was not installed... Doh!
May your journey be free of incident.  Live long and prosper.

johnno56

Hmm... New problem.

libncurses installed ok with no further error message.

I re-ran 'hello world' and it ran and compiled successfully! Unfortunately there was no visual results. I searched for FB examples and found fb world radio. Extracted into a folder. Loaded the 'bas' file into the IDE. Ran and compiled successfully but did not produce a visual display. I ran the world radio exe file via wine and it kind of worked. Clicked a city. Had to cancel the exe for the website to come up. But it played the music just fine. Typical Wine I suppose. But Poseidon just runs and compiles without any othe on screen display.

I will reconfigure Geany and try that way...

J
May your journey be free of incident.  Live long and prosper.

ron77

hello, john :)

before giving up on Poseidon FB IDE, maybe give it another chance by going to the bottom left corner and clicking the bottom option (I forgot what it was called "non costume compiler option") anyway when you click there. the small window should pop up there click the "configure" option then another small window opens and press the plus small icon and give a name to the compiler option you are about to configure then enter then in "compiler:" set the compiler path to the fbc compiler and in "compiler opts:" set your BUILD COMMANDS something like "-s console -exx" for example - then close and click the bottom left corner again and select the name which you gave to the compiler option and then try to "compile and run" any .bas file and tell us the results








another important thing is regarding the world radio app, it used a GUI library called FLTK-c, and for it to compile and run correctly on linux you need to copy the ".so" libraries files to "usr/local/lib" folder or "usr/lib" folder on your linux system (windows uses the ".dll" libraries inside the program folder...) as you can see by the instructions of FLTK-c library for freebasic in this post: https://www.freebasic.net/forum/viewtopic.php?t=24547

i guess that's pretty much it...


ron77

johnno56

Followed the instructions then 'run and compile'. The attached image is all that was produced.

You cannot view this attachment.
May your journey be free of incident.  Live long and prosper.

ron77

okay you forgot one thing just one tinny thing

add at the last line of your code the command 'sleep' so the program won't terminate instantly and you can see the print on the terminal/console/screen

you are almost there :)

johnno56

Console now displayed 'hello world' and waited for a keypress...

"Doctor. We have a pulse!"

Thank you for the assist... Much appreciated...

You do realise that graphics are next?... lol
May your journey be free of incident.  Live long and prosper.

ron77

it was my pleasure johnno56...

btw cool avatar - star trek Mr. Spok :)

And here I'll share with you my default build commands for compiling freeBASIC code both on Linux and windows...

-s console -gen gcc -Wc -Ofast -Wc -Wno-maybe-uninitialized -exx -w all

I highly recommend it :)

kind regards
ron77

johnno56

Thanks Ron. That is one long string of options... Do not tell me what each part does... I need to check that out for myself... Now, time to fire up the my machine's Terminal... Moo Ha Ha...

J

ps: Just looked up the options... '-Who-maybe-uninitialized' was not listed. What does 'this' option do?
May your journey be free of incident.  Live long and prosper.

ron77

hi johnno56

Since FBC version 1.08.0 the compiler would warn that "variables might not be initialized." the only trouble is Poseidon FB  would treat those warnings as compilers errors and would not compile the source code the '-Who-maybe-uninitialized' simply asks the compiler not to give such warnings...

johnno56

May your journey be free of incident.  Live long and prosper.