PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: Compiling the FreeBASIC compiler  (Read 813 times)

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8632
  • Windows 10
    • PlanetSquires Software
Compiling the FreeBASIC compiler
« on: September 08, 2018, 12:30:49 PM »

A year or so ago, I downloaded the FreeBASIC compiler source code and tried to compile it with WinFBE. There were problems at the time so I gave up on it.
Today, I decided to give it another try. I was amazed at how easy it was to compile a successful FBC exe this time  :)
Downloaded the code from GitHub. fbc-master
Extracted the zip
Created a WinFBE project
Add The following the "Other Options" in the Project settings (per Marc's post below):    -d ENABLE_STANDALONE
Loaded all files from the \src\compiler folder (this took a while) :)
Closed all of the open Tabs because there was obviously way too many open
Opened the "fbc.bas" file and set it to be the "main" file
All of the other files in the folder were already set to the correct file types based on their file extensions. Cool. I didn't have to do anything special for those files.
Pressed the compile button on fbc.bas
In the status bar you see all of the source code files being compiled from *.bas to *.o object files
The fbc exe gets created 1144KB
Subsequent compiles are lightning fast because only the changed source files are re-compiled. Pretty cool.

Anyway, a pretty insignificant post but it made me happy that if I ever get the nerve to try to hack the compiler source code that at least I'll be able to make working copies of the compiler without having to resort to makefiles and MSYS environment.


« Last Edit: September 10, 2018, 09:55:19 PM by Paul Squires »
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Joerg Buckel

  • FireFly3 Registered User
  • Junior Member
  • *
  • Posts: 51
  • FF3 and WinFBE+WinFBX User
Re: Compiling the FreeBASIC compiler
« Reply #1 on: September 09, 2018, 04:46:57 AM »

Hello Paul
I wanted to try that now, but I'm probably not there yet so far.

With me the process breaks off with a single error. :-)
 
Logged
Greeting from Germany

Joerg

James Fuller

  • FireFly3 Registered User
  • Senior Member
  • *
  • Posts: 278
  • FF3 User
Re: Compiling the FreeBASIC compiler
« Reply #2 on: September 09, 2018, 06:32:38 AM »

Paul,
  That is not insignificant!! Good work!
  Both 32 and 64 bit??

James
Logged

Marc Pons

  • FireFly3 Registered User
  • Junior Member
  • *
  • Posts: 132
  • FF3 User
Re: Compiling the FreeBASIC compiler
« Reply #3 on: September 09, 2018, 07:53:46 AM »

Hi Paul
very good and simple solution , worked fine and compiled both 32 and 64
Logged

Joerg Buckel

  • FireFly3 Registered User
  • Junior Member
  • *
  • Posts: 51
  • FF3 and WinFBE+WinFBX User
Re: Compiling the FreeBASIC compiler
« Reply #4 on: September 09, 2018, 01:59:06 PM »

hmmmmmm. I get following mistakes:

G:\WinFBE_Suite\FreeBASIC-1.06.0\bin\win32\ld.exe: G:\fbc-master\src\compiler\fbc.o: bad reloc address 0x60 in section `.data'

linking failed: 'G:\WinFBE_Suite\FreeBASIC-1.06.0\bin\win32\ld.exe' terminated with exit code 1
Can someone tell me why I'm getting this mistake?
Logged
Greeting from Germany

Joerg

Wilko Verweij

  • FireFly3 Registered User
  • Junior Member
  • *
  • Posts: 159
  • PB10 - FF3.7 User; Win 10
    • CHEAQS
Re: Compiling the FreeBASIC compiler
« Reply #5 on: September 09, 2018, 03:45:21 PM »

Hi Joerg,
What do you see if you go to the tab 'Compiler log file'?
Logged

Joerg Buckel

  • FireFly3 Registered User
  • Junior Member
  • *
  • Posts: 51
  • FF3 and WinFBE+WinFBX User
Re: Compiling the FreeBASIC compiler
« Reply #6 on: September 10, 2018, 04:56:23 AM »

Hi Joerg,
What do you see if you go to the tab 'Compiler log file'?
Hello Wilko

I've attached the LOG file.
Logged
Greeting from Germany

Joerg

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8632
  • Windows 10
    • PlanetSquires Software
Re: Compiling the FreeBASIC compiler
« Reply #7 on: September 10, 2018, 08:05:03 AM »

The missing function, FBGETOPTION, is located in "FB.BAS". I didn't notice a "FB.O" compiled object in the log output so maybe you didn't add fb.bas to the project?
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Joerg Buckel

  • FireFly3 Registered User
  • Junior Member
  • *
  • Posts: 51
  • FF3 and WinFBE+WinFBX User
Re: Compiling the FreeBASIC compiler
« Reply #8 on: September 10, 2018, 08:55:33 AM »

Hello Paul
You are my hero today. :-)
The Fb.bas in my directory only had a size of 370 bytes.
The original fb.bas file had 35,683 bytes.
In this case the file was probably damaged.
Now I have replaced the file and can compile it without problems.
Many thanks for this not "incidental" information and for viewing the log file.
Logged
Greeting from Germany

Joerg

Jean-pierre Leroy

  • FireFly3 Registered User
  • Senior Member
  • *
  • Posts: 468
  • expect nothing, be prepared for everything ...
Re: Compiling the FreeBASIC compiler
« Reply #9 on: September 10, 2018, 09:42:07 AM »

Just a question : FreeBASIC compiler is written in FreeBASIC ?
Logged

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8632
  • Windows 10
    • PlanetSquires Software
Re: Compiling the FreeBASIC compiler
« Reply #10 on: September 10, 2018, 09:59:16 AM »

Just a question : FreeBASIC compiler is written in FreeBASIC ?
The main compiler is written in FreeBASIC however the runtime library and graphics libraries are written in C. Imortis starting re-writing the runtime library in FB https://www.freebasic.net/forum/viewtopic.php?f=8&t=25923
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Marc Pons

  • FireFly3 Registered User
  • Junior Member
  • *
  • Posts: 132
  • FF3 User
Re: Compiling the FreeBASIC compiler
« Reply #11 on: September 10, 2018, 11:07:54 AM »

Hi Paul

As I"ve already said, it compiled fine for 32/64, but after that new created fbc.exe does not work very well

the connected As.exe  application and linker need to know where to be found

so you have to put a complementary compiling argument        -d ENABLE_STANDALONE

before creating the exe  put it on the project options  for 32 and 64

that compiling option will assume the relative position of the needed folders...

Logged

Marc Pons

  • FireFly3 Registered User
  • Junior Member
  • *
  • Posts: 132
  • FF3 User
Re: Compiling the FreeBASIC compiler
« Reply #12 on: September 10, 2018, 01:33:10 PM »

Hi Paul again,

I was so interrested on your trick to simplify the fbc.exe compilation and jump immediatly on it,
 because i was trying to implement 2 new intrinsic defines on the compiler (i've put a request, but did not expect fast reaction)

__FB_CONSOLE__   and   __FB_GUI__

to make something like that
Code: [Select]
#if __FB_CONSOLE__
print "Console mode"
print : print "Any key to close"
sleep
#endif

#if __FB_GUI__
#include "windows.bi"
messagebox(0, "Gui mode", "info",0)
#endif


and i suceed much faster with your ide project feature

only adding some lines in 4 files is enougth
in fbc.bas ; fb.bi ; fb.bas ; symb-define.bas      the lines are marked with   '***** console/gui

it work without any difficulty on 32 or 64   :)

i put under the modified files on the zip   and the exe files created

i will put a link on freebasic forum to here .
« Last Edit: September 10, 2018, 02:02:26 PM by Marc Pons »
Logged

Marc Pons

  • FireFly3 Registered User
  • Junior Member
  • *
  • Posts: 132
  • FF3 User
Re: Compiling the FreeBASIC compiler
« Reply #13 on: September 15, 2018, 05:19:37 AM »

hi
to inform the  rolling freebasic version has implemented the __FB_GUI__ define
so now we can test the -s console or -s gui compiling argument, in fact 1 define is enougth because as default (without -s option) a console is visible

test with
Code: [Select]
#if __FB_GUI__
#include "windows.bi"
messagebox(0, "Gui mode", "info",0)
#else
print "Console mode"
print : print "Any key to close"
sleep
#endif

to JosÚ (from freebasic forum)
Quote
Re: Feature request: instrisic Defines for console / gui mode
Postby Josep Roca ╗ Sep 13, 2018 14:37
If the suggestion is implemented, additional features can be added like flagging as an error the use of SLEEP without parameters in an application compiled as a Windows GUI.

your request is not implemented, in fact i was also trying to implement that (plus the fxm remark)
but not easy (at least for me ) to do it.

as a general remark, you can see the quite fast reaction of freebasic mainteners to requests.
I think with the talented people here, it is a strong possibility to correct, adapt, expand the freebasic compiler.
Logged

Joerg Buckel

  • FireFly3 Registered User
  • Junior Member
  • *
  • Posts: 51
  • FF3 and WinFBE+WinFBX User
Re: Compiling the FreeBASIC compiler
« Reply #14 on: September 18, 2018, 02:11:33 PM »

Hello Together
I compiled the compiler with WinFBE without errors, but didn't use it at all.
Now I came up with exactly this idea. :-)

But source code, which can be compiled with the original compilers without error messages, aborts with the self-created compilers.

Below the error message.

FreeBASIC Compiler - Version 1.06.0 (09-17-2018), built for win64 (64bit)
Copyright (C) 2004-2016 The FreeBASIC development team.
target: win64, x86-64, 64bit
compiling: G:\WinFBE_Suite\Sample_Projects\TEST-PROJEKT\Window.bas -o G:\WinFBE_Suite\Sample_Projects\TEST-PROJEKT\Window.c (main module)
G:\WinFBE_Suite\Sample_Projects\TEST-PROJEKT\Fenster.bas(619) error 23: File not found, "WinFormsX\WinFormsX.bi"

Do the self-created compilers work for you?
Logged
Greeting from Germany

Joerg
Pages: [1] 2