Hello. I tried different exemples of compression : zlib, quicklz, bz2 lzo and so
Sounds like a general beginner issue on my config accessing related libraries :
F:\FB64\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win64\ld.exe: cannot find -llzo2
Dezipped stand alone. Using Fbide.
Thanks.
zlib and co help appreciated
-
- Posts: 538
- Joined: Dec 02, 2011 22:51
- Location: France
Re: zlib and co help appreciated
Hi Lost Zergling.
Go into the fb distribution folder and find bin/win32 or win64.
You will see zlib1.dll in each folder.
My distro is:
C:\Users\Computer\Desktop\fb\FreeBASIC-1.09.0-winlibs-gcc-9.3.0
copy the dll into a test folder and use this code to test
Note: the namespace is not needed, you can get rid of it.
Go into the fb distribution folder and find bin/win32 or win64.
You will see zlib1.dll in each folder.
My distro is:
C:\Users\Computer\Desktop\fb\FreeBASIC-1.09.0-winlibs-gcc-9.3.0
copy the dll into a test folder and use this code to test
Code: Select all
Namespace Zlibrary
#inclib "zlib1"
Extern "C"
Declare Function compressBound(Byval sourceLen As Ulong) As Ulong
Declare Function uncompress(Byval dest As Ubyte Ptr, Byval destLen As Uinteger Ptr, Byval source As Ubyte Ptr, Byval sourceLen As Ulong) As Long
Declare Function compress(Byval dest As Ubyte Ptr, Byval destLen As Uinteger Ptr, Byval source As Ubyte Ptr, Byval sourceLen As Ulong) As Long
declare function compress2(byval dest as ubyte ptr, byval destLen as uinteger ptr, byval source as const ubyte ptr, byval sourceLen as uLong, byval level as long) as long
End Extern
Function getpassedinfo(text As String,Byref passed_length As Integer) As String
Dim As String var1,var2
Dim As Integer pst
#macro splice(stri,char,var1,var2)
pst=Instr(stri,char)
var1="":var2=""
If pst<>0 Then
var1=Mid(stri,1,pst-1)
var2=Mid(stri,pst+1)
Else
var1=stri
End If
#endmacro
splice(text,"|",var1,var2)
text=var2
passed_length=Valint(var1)
Return text
End Function
'================= UNPACK ===============
Function unpack(InString As String) As String
Dim As Integer passed_length
Dim As String text=getpassedinfo(InString,passed_length)
Dim As Integer stringlength,destinationlength
stringlength=Len(text)
destinationlength =passed_length
Dim As Ubyte Ptr source
Dim As Ubyte Ptr destination =Callocate(destinationlength,1)
source=@text[0]
Var mistake=uncompress(destination,@destinationlength, source, stringlength)
If mistake<>0 Then Print "There was an error":Sleep:End
Dim As String uncompressed
uncompressed=String(destinationlength,0)
For i As Integer = 0 To destinationlength- 1
uncompressed[i]=(destination[i])
Next
Deallocate destination
Return uncompressed
End Function
'=================== PACK ============
Function pack(InString As String) As String
Dim As String text=InString
Dim As Integer stringlength,destinationlength
stringlength=Len(text)
destinationlength = compressBound(stringlength)
Dim As Ubyte Ptr source
Dim As Ubyte Ptr destination =Callocate(destinationlength,1)
source=@text[0]
Var mistake=compress(destination, @destinationlength, source, stringlength)
If mistake <>0 Then Print "There was an error"
Dim As String compressed
compressed=String(destinationlength,0)
For n As Integer=0 To destinationlength-1
compressed[n]=destination[n]
Next n
compressed=stringlength &"|"+compressed
Deallocate destination
Return compressed
End Function
End Namespace
using zlibrary
dim as string s="0123456789 FreeBASIC 9876543210 " + time+" "
for n as long=1 to 6
s+=s
next
print "'";s;"'"
print
print "compressed string:"
var t=pack(s)
print t
print
var up= unpack(t)
print "'";up;"'"
print
print "compress ratio ";len(t)/len(up)
sleep
-
- Posts: 538
- Joined: Dec 02, 2011 22:51
- Location: France
Re: zlib and co help appreciated
I Got it 64 bits ok : Thank you a lot ! (I do still a problem with my search path but your exemple works nicely)
Re: zlib and co help appreciated
I have made a static 64 bit library, 120 kb.
This would be easier to access, either put it with your fb source or put it in lib/win64.
If you have gcc on your system you can compile zlib directly
https://zlib.net/
If not I can put it on mediafire file sharing site.
This would be easier to access, either put it with your fb source or put it in lib/win64.
If you have gcc on your system you can compile zlib directly
https://zlib.net/
If not I can put it on mediafire file sharing site.
-
- Posts: 538
- Joined: Dec 02, 2011 22:51
- Location: France
Re: zlib and co help appreciated
Hello dodicat. I do not use gcc, but your code fits what I was looking for. Perhaps I ll try extern c and try to compile zlib sources using fb but that is not mandatory. Before that, I have some work on my lzle lib to allow reserved ascii codes, and fix some bugs with hashashtag and tracking, with a whole retesting. I have been inactive for almost a long time, so I may go ahead carefully with my own code