Where can I get a Recent-Git-Build of FreeBASIC?

For other topics related to the FreeBASIC project or its community.
dodicat
Posts: 6687
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Where can I get a Recent-Git-Build of FreeBASIC?

Postby dodicat » Apr 26, 2014 21:11

Getting back to UDT var length arrays for a minute:

It is hardly worth while (for matrix types anyway) creating a constructor or using a let operator to copy values into a matrix.
It would have been good to directly use my matrix=type<matrix>({{...),{...},{...}}).
But since that cannot be, using data is perhaps the simplest method.

Here is an alternative linear equation solver using the Cramer method.
The matrix determinant function is used for this method.

I notice in the function matrix.solve I am not allowed to use RETURN. ??
Apart from that it seems fair enough.
So I'll but out of this thread for a while.
Cheers!

Code: Select all

Type matrix
    Dim As Double element(Any,Any)
    Declare Operator Cast() As String
    Declare Function determinant() As Double
    Declare Function solve(As matrix) As matrix
End Type

'matrix multiply
Operator *(m1 As matrix,m2 As matrix) As matrix
Dim rows As Integer=Ubound(m1.element,1)
Dim columns As Integer=Ubound(m2.element,2)
If Ubound(m1.element,2)<> Ubound(m2.element,1)Then
Print "Can't do"
Exit Operator
End If
Dim As matrix ans
Redim ans.element(1 To rows,1 To columns)
Dim rxc As Double
For r As Integer=1 To rows
    For c As Integer=1 To columns
        rxc=0
        For k As Integer = 1 To Ubound(m1.element,2)
            rxc=rxc+m1.element(r,k)*m2.element(k,c)
        Next k
        ans.element(r,c)=rxc
    Next c
Next r
Operator= ans
End Operator

'rounding function
Function round (a As Double,b As Integer) As Double
    Var y = (Abs(a)-Int(Abs(a))) * (10 ^ b),i=Int(y):y-=i
    If y >= .5 Then i+= 1
    i /= (10 ^ b)
    Var r = Int(Abs(a))+i
    If a < 0 Then r = -r
    Return r
End Function

'matrix printer
Operator matrix.cast() As String
Dim As String ans,comma
For a As Integer=1 To Ubound(this.element,1)
    For b As Integer=1 To Ubound(this.element,2)
        If b=Ubound(element,2) Then comma="" Else comma=" , "
        ans=ans+Str(round(element(a,b),12))+comma
    Next b
    ans=ans+Chr(10)
Next a
Operator= ans
End Operator

Function matrix.determinant() As Double
    Dim As Double det=1
    Dim As Integer n=Ubound(this.element),sign=1
    Dim As matrix b=(This)
    #macro pivot(num)
    For p1 As Integer  = num To n - 1
        For p2 As Integer  = p1 + 1 To n 
            If Abs(b.element(p1,num))<Abs(b.element(p2,num)) Then
                sign=-sign
                For g As Integer=1 To n
                    Swap b.element(p1,g),b.element(p2,g)
                Next g
            End If
        Next p2
    Next p1
    #endmacro
    For k As Integer=1 To n-1
        pivot(k)
        For row As Integer =k To n-1
            If b.element(row+1,k)=0 Then Exit For
            Var f=b.element(k,k)/b.element(row+1,k)
            For g As Integer=1 To n
                b.element((row+1),g)=(b.element((row+1),g)*f-b.element(k,g))/f
            Next g
        Next row
        det=det*b.element(k,k)
    Next k
    Return sign*det*b.element(n,n)
End Function

'column swapper for Cramer method
Function CRAMERswaps(m As matrix,c As matrix,column As Integer) As matrix
    Var _new=m
    For z As Integer=1 To Ubound(_new.element)
        _new.element(z,column)=c.element(z,1)
    Next z
    Return _new
End Function

Function matrix.solve(rhs As matrix) As matrix
    Var m=this.determinant
    Dim As matrix result
    Redim result.element(1 To Ubound(this.element),1 To 1)
    Dim As matrix ans
    If m Then
        ' do CRAMER column substitutions
        For column As Integer=1 To Ubound(this.element)
            ans= CRAMERswaps(This,RHS,column)
            result.element(column,1)=ans.determinant/m
        Next column
    Else
        Print "Main matrix is most likely singular"
        Exit Function
    End If
    Function= result
    'return result
End Function
'=====================================================
Screen 19
Windowtitle "Cramer method"
Dim As matrix m,rhs

'square matrices only for linear equation systems
Redim m.element(1 To 6,1 To 6)
Redim rhs.element(1 To 6,1 To 1)

Restore System1
For r As Integer=1 To 6
    For c As Integer=1 To 6
        Read M.element(r,c)
    Next c
Next r


For r As Integer=1 To 6
    Read rhs.element(r,1)
Next r

Print "Matrix ":Print m
Print "RHS ":Print rhs
Print "Determinant of matrix = ";:Print m.determinant
Print
Print "Solution of linear equations"
Print  m.solve(rhs)
Print
Print "Check answer (matrix x solution = RHS)  "
Print m*m.solve(rhs)
Print "Done"

Sleep
System1:
Data 10,2,3,9,0,0, _
-5,8,0,-3,-8,1, _
7,1,2,-1,9,2, _
-9,12,-2,-11,0,0, _
9,3,-2,.5,0,-.9, _
-9,-.03,-10,-1,0,0



Data -6,0,4.008,-1,3.33,3

 
dkl
Site Admin
Posts: 3212
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Where can I get a Recent-Git-Build of FreeBASIC?

Postby dkl » Apr 26, 2014 21:16

When returning a "class", FB allows either Return or Function = foo/Exit Function, but not both. That's due to their current implementation which would conflict when used at the same time, unlike for simple data types like Integer where both can be used within the same function.
fxm
Posts: 9946
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Where can I get a Recent-Git-Build of FreeBASIC?

Postby fxm » Apr 26, 2014 22:01

'RETURN' mixed with 'FUNCTION =' or 'EXIT FUNCTION' is unsupported when returning objects with constructors:
see dkl's post at http://www.freebasic.net/forum/viewtopic.php?p=196012#p196012

I think this restriction (already in fbc version 0.17) has never been noted in the documentation, if not by the compiler error message!
fxm
Posts: 9946
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Where can I get a Recent-Git-Build of FreeBASIC?

Postby fxm » Apr 27, 2014 9:31

Documentation updated:
KeyPgFunction ⇒ FxMwikki [Mixing Return and Function= is unsupported when returning objects with constructors]
St_W
Posts: 1504
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Where can I get a Recent-Git-Build of FreeBASIC?

Postby St_W » Apr 29, 2014 19:38

Recent Git-Builds for DOS, Windows (32/64 bit) and Linux (32/64 bit) platforms are and will be available at:

http://users.freebasic-portal.de/stw/builds/

I have set up a small Jenkins CI Server that automatically triggers builds for the platforms mentioned above when a change is pushed to the FreeBasic master branch at Github. The server is running since february this year, but its bandwidth is very limited. To allow public downloads it does now upload the the latest builds (in case any new builds exist / any changes exist) every night (at around 2:00 GMT+1) to Sebastian's fast FBP Server (see link above).

The file name contains the Jenkins build id and the build date. The packages are currently using ZIP-Compression (done by 7zip). The content of the various packages differs. e.g. the windows and dos packages contain the toolchain binaries (mingw / djgpp), the linux version only contains the compiled binaries.
Please note that you may have to force page reload/refresh (usually by hitting F5, Ctrl+F5 or similar) to see the latest uploads (at least Firefox requires me to do that).

If you have any comments, questions, suggestions, improvements do not hesitate to tell me.
fxm
Posts: 9946
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Where can I get a Recent-Git-Build of FreeBASIC?

Postby fxm » May 03, 2014 12:59

Could we have a full win32 build (.zip) without using mingw?
St_W
Posts: 1504
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Where can I get a Recent-Git-Build of FreeBASIC?

Postby St_W » May 04, 2014 11:46

I currently have two win32 build-jobs: one using mingw and another one using tdm-gcc. As far as I know the official FreeBasic builds are made using the MinGW toolchain again; after a few Versions were built with the tdm-gcc toolchain.

I have forgotten to include 2 DLLs needed for win32 mingw in the package, these will be included in the next builds. Additionally the toolchain binaries will be upx compressed to save space. These settings will be used for new builds from now on. Please tell me if and which other files should be included / excluded.

I've manually triggered a new win32 mingw build which includes these changes: http://users.freebasic-portal.de/stw/bu ... -05-04.zip
fxm
Posts: 9946
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Where can I get a Recent-Git-Build of FreeBASIC?

Postby fxm » May 04, 2014 13:19

fxm wrote:Could we have a full win32 build (.zip) without using mingw?

Version 0.90.1 released, dkl wrote:
Win32 Binaries

I spoke about the second bullet (FreeBASIC-0.90.1-win32.zip), as MOD builds!


[Edit]
OK with the last build above.
Last edited by fxm on May 04, 2014 15:10, edited 1 time in total.
St_W
Posts: 1504
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Where can I get a Recent-Git-Build of FreeBASIC?

Postby St_W » May 04, 2014 14:19

The mingw package should contain everything that is needed to compile a freebasic program except Microsoft C Runtime. So no additional mingw installation or tools are needed. The compiled programs do not depend on any external mingw libraries either. That's why I didn't understand your request for a build "without using mingw".

I've compared my package to the release package and a package by MOD. What is not included currently in my packages is:
- gdb and gprof
- examples
- most third-party include files
- third-party import libraries
- readme, changelog, doc folder
If I understood you correctly you want all that stuff included in the package, right? Third-Party import libs are currently not generated so give me some time for changing that. I will change the packaging job to include all these files. Please tell me if I've missed something.

I hope that's what you want :-)
fxm
Posts: 9946
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Where can I get a Recent-Git-Build of FreeBASIC?

Postby fxm » May 04, 2014 15:05

Excuse me but I only tested your previous builds that don't worked!
With the build 067, all is right.
Not necessary to add any files.
Thanks.
maxarg
Posts: 7
Joined: May 21, 2014 7:09

Re: Where can I get a Recent-Git-Build of FreeBASIC?

Postby maxarg » May 21, 2014 7:47

@MOD

Hi to All! I'm new to this forum.
Excellent work MOD for the x64 build, but I'm unable to compile 64bit dll with exported functions

Public Function Test_Exp(i As integer) As Integer Export
Return 1
End Function

*** Error: Cannot export TEST_EXP@8: symbol not found

Some hints?

Thanks a lot
dkl
Site Admin
Posts: 3212
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Where can I get a Recent-Git-Build of FreeBASIC?

Postby dkl » May 21, 2014 15:46

Oh, looks like fbc is still using the @N suffix for stdcall procedures on 64bit, even though there's no stdcall on 64bit. That should be easy to fix though.

Overall however, building 64bit Win32 DLLs or Linux .so's isn't working yet anyways, as fbc doesn't use -fPIC when invoking gcc, and the FB runtime libraries aren't built with -fPIC, and fbc doesn't use the -fPIC-specific gcc libraries/objects, and so on.
maxarg
Posts: 7
Joined: May 21, 2014 7:09

Re: Where can I get a Recent-Git-Build of FreeBASIC?

Postby maxarg » May 21, 2014 17:09

@dkl

Thank you a lot for the explanation,
i tried to "force" the CDecl calling convention and the compilation was successful but with a warning, :-|
...\ld.exe: warning: cannot find entry symbol _Dll MainCRTStartup@12; defaulting to 0000000010001000
But DLL was generated and Dll_export_viewer shows now the exported function (not decorated)

Do you think that in the near future fbc will be able to generate x64 libraries?

Cheers to you and all the fbc team, ;-)
Massimiliano
dkl
Site Admin
Posts: 3212
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Where can I get a Recent-Git-Build of FreeBASIC?

Postby dkl » May 22, 2014 0:02

The -e _DllMainCRTStartup@12 ld argument is hard-coded in fbc, that also needs adjustment. I'll have to check what MinGW-w64 uses in this case, but probably just _DllMainCRTStartup (without the @N suffix).

Yea, I'm going to work on that soon - it's needed for the next release. I wouldn't want to release 64bit support without supporting building DLLs.
maxarg
Posts: 7
Joined: May 21, 2014 7:09

Re: Where can I get a Recent-Git-Build of FreeBASIC?

Postby maxarg » May 22, 2014 8:28

@dkl
Hi, give a look at this scenario (fbc 0.91 32bit DLL invoked by VB6):

'freebasic 32bit DLL
Public Function TEST_DLL StdCall (ByVal dllName As String) As Any Ptr Export
Return DylibLoad(dllName)
End Function

'VB6 form
Private Declare Function TEST_DLL Lib "D:\TEST\TEST.dll" Alias "TEST_DLL@4" (ByVal dllName As String) As Long

Private Sub Form_Load()
Debug.Print TEST_DLL("user32")
End Sub

VB6 crash in dll load with 0.91devel, with fbc 0.90.1release all is OK
I'm doing something wrong?

Many thanks

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests