Page 1 of 4
coffIT - create obj and lib static libraries from PB source!
Posted: Thu Feb 28, 2008 11:38 am
by srod
Posted: Thu Feb 28, 2008 11:45 am
by Dare
Not a bug report, just a query! Copied exacto from other forum and I'm just after what is safe. Eg, some things like Import, Interface, Psuedotypes. Esp Import would need care if available.
srod wrote:The help manual examines these problems quite thoroughly.
I have been through the manual a few times (fortunately it is easy to read and small) but I still need to request some clarification. Sorry!
srod wrote:Of course the first question is whether static libs created with PB can be used in other languages? The answer is yes, providing that your library does not use any commands which reside within any of PB's user libraries!
I assume this means all variables, types and operators and the following (I assume again) non-library commands:
Code: Select all
Break : Continue
Define
Dim : ReDim
End
Enumeration : EndEnumeration
For : Next
ForEach : Next
Global
Gosub : Return
Goto
If : Else : ElseIf : EndIf
Import : EndImport
Interface : EndInterface
Macro : EndMacro
NewList
Procedure : EndProcedure
Protected
Prototype
Pseudotype
Repeat : Until
Select : EndSelect
Shared
Static
Structure : EndStructure
Swap
While : Wend
With : EndWith
Would that be a complete list or have I missed something (or included something I shouldn't)?
Just making sure before I do something stupid and wonder what happened.
Have only played with the examples but this looks really exciting. Great job mate!
Posted: Thu Feb 28, 2008 12:02 pm
by srod
Sorry, horrendous bug found!!!
Back in a mo...

Posted: Thu Feb 28, 2008 12:18 pm
by srod
Particularly clumsy bug fixed.

New version uploaded.
@Dare, all of the commands you've listed look fine to me. The proof of the pudding though is in the eating! Some things you just have to try and see what happens.
As for using the Import keyword in a .obj / .lib - that is fine; I've already tested this and it seems to work fine.
In fact rather than me arsing around, let me add an example of this right now!
Back in a mo...

Posted: Thu Feb 28, 2008 12:29 pm
by srod
@Dare, I've added the following example to the coffIT download :
Code: Select all
;coffIT demo program.
;By Stephen Rodriguez.
;Import an external lib.
Import "User32.lib"
MsgBox(Window.l, Body$, Title$, Flags.l) As "_MessageBoxA@16"
EndImport
ProcedureDLL CallImport(hWnd, text$)
MsgBox(hWnd, text$, "Hello from coffIT!", 0)
EndProcedure
Run this through coffIT to create a .obj file.
Now when using the resulting 'ImportExternalLib.obj' in an application you must simply ensure that user32.lib is added to the application at the linking stage. In the case of building a PB application, if you use the coffIT generated import wrapper, then the wrapper will ensure that user32.lib is indeed added at the link stage. (It does this by simply adding an empty Import / EndImport for the 'user32.lib' import library)
Simple!
**EDIT : coffIT ignores macros (except the one used to export variables). Use macros by all means in your source, but avoid using a macro to mask a Procedure definition or a global variable definition etc.
Posted: Thu Feb 28, 2008 1:21 pm
by milan1612
Great work srod
When can we expect the second version (*.lib output)?
And btw. does the name refer to the COFF format or
your immense COFFee consum during the creation? 
Posted: Thu Feb 28, 2008 1:24 pm
by srod
milan1612 wrote:Great work srod
When can we expect the second version (*.lib output)?
And btw. does the name refer to the COFF format or
your immense COFFee consum during the creation? 
After I've had some sleep!
I've got some other work to do at the moment - a few days worth, this will give coffIT's existing bugs time to show themselves etc.
Once version 1 has been demonstrated as being relatively stable then I will complete version 2, which adds .lib support. The truth is that the majority of the code is already in place for this. It's a case of reorganising and adding a little more logic in places.
Posted: Thu Feb 28, 2008 3:07 pm
by Dare
Hi Mate,
Thanks for the answers. Don't overdo the working. Or only if it means $$$.

Posted: Thu Feb 28, 2008 6:26 pm
by Pureabc
Excellent!
Thanks Srod.
Posted: Thu Feb 28, 2008 7:10 pm
by srod
You're welcome Pureabc.
@Milan : there is nothing stopping you using coffIT to create .libs right now (before version 2 is released).
All you need to do is split your source into individual source files, -say one for each function.
Run each function/file through coffIT and then use POLIB on all the resulting .obj files to create a .lib.
The only thing is that you will need to export all data (e.g. variables) which needs to be shared amongst the functions etc. and also export all 'internal' functions so that they are accessible throughout the library.
Posted: Thu Feb 28, 2008 7:12 pm
by BriceManuel
I have to say my concern is the same as Dare's. I had to buy another language to make DLLs since I can't use PB's DLLs in anything else but PB. I am not sure how a lib will circumvent this as any DLL or lib written using PB will naturally be making use of PBs commands, wouldn't it?
Posted: Thu Feb 28, 2008 7:18 pm
by srod
Static libs are not intended to replace dll's Brice because, as you know, dll's have already passed through the linking stage and so using PB functions in a dll is not a problem.
.libs (if you intend using them in other languages) should stick to the basic command set + Win api. You would of course build up a library of routines this way until you had a rich base of functions etc.
Of course, with c static libs, things are made somewhat easier by the runtime library; which is always an option in PB. There's no reason why static libs created with PB cannot make use of the c runtime etc. I certainly intend to.
On an aside, I must admit that I've had no problems using PB created dll's with other languages. Is there any particular language you've had problems with when attempting to use PB created dll's?
On another aside, can you check your pm's please Brice?

Posted: Thu Feb 28, 2008 7:25 pm
by BriceManuel
Seriously and honestly, I am still confused, but its certainly not the first time

Posted: Thu Feb 28, 2008 9:40 pm
by milan1612
srod wrote:@Milan : there is nothing stopping you using coffIT to create .libs right now (before version 2 is released).
All you need to do is split your source into individual source files, -say one for each function.
Run each function/file through coffIT and then use POLIB on all the resulting .obj files to create a .lib.
The only thing is that you will need to export all data (e.g. variables) which needs to be shared amongst the functions etc. and also export all 'internal' functions so that they are accessible throughout the library.
Didn't know that, I'm gonna give it a try...
Thanks for the hint

Posted: Thu Feb 28, 2008 9:44 pm
by srod
I'll knock up a quick example for you.