It is currently Wed Apr 24, 2019 5:04 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 31 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: coffIT - create obj and lib static libraries from PB source!
PostPosted: Thu Feb 28, 2008 1:34 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10518
Location: Beyond the pale...
20/01/2010.
There is now a version of coffIT for PB 4.4 (x86 only). The PB 4.4 generated ASM had changed ever so very slightly; enough to confuse the hell out of coffIT! :)

This is to be considered a test version at this moment in time as I have not had time to test it as much as I would like.

This new version adds support for all of PB 4.4's new data-types (when creating PB wrappers) including the new hash maps etc.

See the nxSoftware site for the download.

Tested with PB 4.41 RC1 only.

=====================================


26/05/2008.
coffIT is now compatible with PB 4.2. A certain alteration was required to keep pace with one alteration made to PB's generated ASM code. :)

The download link is in the second post of this thread.

=====================================


09/03/2008. Bugfix.
When creating a static .lib, coffIT (more precisely, Fasm!) would crash out if a 'Data' statement contained repeated addresses of the same procedure.

The download link is in the second post of this thread.

=====================================


04/03/2008. Update - coffIT 2.0 beta 1.
coffIT now offers MSCOFF .obj or MSCOFF static library (.lib) output formats.

I advise reading the relevant parts of the help manual regarding the choice of creating .obj or .lib files, because it is worth understanding how coffIT proceeds here as well as the reason why I would not necessarily suggest using .lib files!

The download link is in the second post of this thread.

=====================================

29/02/2008. Update - coffIT 1.0 beta 2.
In the event of a successful compilation, coffIT generated log files will now list all external functions / symbols required by the resulting .obj or .lib file etc.
This is useful when hoping to use your resulting static library in other programming languages etc.

This is on top of the coffIT generated Purebasic import wrappers which will list all Windows libraries required by the .lib etc.

The download link is in the second post of this thread.

=====================================


Hi,

introducing version 1 of coffIT, a tool for compiling PB source code programs to either MSCOFF object files (.obj) or static library files (.lib). (.lib files will be added for version 2 - most of the code is already in place for this.)

At this stage I am going to reproduce the first page of the coffIT help manual in order to give a little background etc. Static libraries can be a minefield for those new to the idea :

Quote:
Many programming languages allow the developer to create what are termed static libraries; compiled libraries which can be reused in many different projects and (dependencies allowing) across different programming languages.

This is a tried and tested and a very efficient means of reusing code, particularly useful in languages easily lending themselves to a 'modular' style of programming such as C and many Basic programming languages.

Indeed, many language compilers make extensive use of such libraries when building applications and allow the developer to add yet more such libraries to the language, effectively extending the range of commands available to that developer. Purebasic is one such language in which we can easily import libraries written in other languages into our applications through the use of the Import and EndImport statements. Thus our programs can use the same all encompassing libraries which the C programmer has taken for granted for many a year now!

However, whilst Purebasic allows the use of correctly formatted static libraries created in other languages, it does not explicitly allow us to create such libraries either for use in other Purebasic projects or indeed for use with other languages. The Purebasic compiler simply does not offer this facility to the end user, -at least not directly! Indeed, the system of libraries used by Purebasic when building applications is based upon it's own customised format which, whilst allowing for an increased ease of use, does ultimately mean that we can not use these libraries in other programming languages or indeed easily add libraries of our own.

And this is where coffIT comes in to play. It allows us to create standard MSCOFF object files and static libraries (static libs will be added in version 2) which can be used in other Purebasic projects and, dependencies on other libraries allowing, with other programming languages.

And all at the push of a button!


Of course Tailbite will create a static library from PB source, but Tailbite does not allow the developer to export variables from it's libraries etc. coffIT does this, -and more! :)

Features of coffIT include :
  • Export variables, structures, arrays. Export all globals or just selected ones.
  • Re-use assembly code files so that (advanced) programmers are free to make adjustments at the assembly code level to the static libraries etc.
  • Create a Purebasic import wrapper which will ensure that all dependencies (user libraries, external libraries, system libraries etc.) are added to any executable making use of your static library etc.

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! For example, suppose one of your static libs uses the AddGadgetItem() command, then you will not be able to use this library in any language other than PB. This is because any application using your lib will be required to link against PB's gadget library (because of the AddGadgetItem() command), which is only possible for PB itself because no other language has access to PB's user libs (and PB's user libs are not in standard MSCOFF format anyhow!) Static libs which use Win api commands are no problem with other programming languages, however, you just need to ensure that the relevant import libraries are added to the build etc.

Next question : can our static libs be used in other Purebasic applications? The answer is yes. The only problem is forcing Purebasic to add all the necessary user libs and other external libs when linking the final executable. This is far from a trivial concern, but is solved by coffIT by simply requesting that it creates a PB import wrapper when building your static lib. This import wrapper takes responsibility for 'tricking' Purebasic into passing all necessary dependencies to the linker when building the application's executable.

The help manual examines these problems quite thoroughly.

Continued in the next post...

_________________
I may look like a mule, but I'm not a complete ass.


Last edited by srod on Wed Jan 20, 2010 3:12 pm, edited 8 times in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 28, 2008 1:51 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10518
Location: Beyond the pale...
Before rushing ahead and creating .obj files willy nilly like, I do advise that you read the help manual very carefully. Not because coffIT is a difficult program to use, far from it, but because static libs can cause as many problems as they solve. It is worth appreciating their limitations regarding their useage as much as it is their flexibility in certain circumstances etc. Fancy creating your own programming language? Why not create a bank of libraries for use in your language with PB and a tool like coffIT? Heck, you can optimise the assembly code by hand etc.

Using tools like coffIT or Tailbite is a matter of personal preference as much as it is one of need etc.

Right, enough babble - down to the nitty gritty. Oh, one more thing, please read the help manual carefully! :) Those new to static libs could easily file false bug reports when really the problem is one of understanding their limitations and appropriateness in certain situations etc.

The coffIT download includes :
  • The coffIT executable (duh!).
  • The help manual. Please read...... :twisted:
  • A series of examples which I will add to as appropriate. Some of these examples are discussed within the help manual.
  • The result of compiling my EsGRID (the lite version) library with coffIT with accompanying .obj file, import wrapper file and a demo program. This is included (without source) to illustrate that coffIT can be used with complex libraries. All the other examples are quite trivial! Of course you get a useable grid control out of this as well! :)

This early version of coffIT is packed with the default English language file. I will not seek translations until work on version 2 is complete.

Link removed.

_________________
I may look like a mule, but I'm not a complete ass.


Last edited by srod on Wed Jan 20, 2010 3:10 pm, edited 3 times in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 28, 2008 3:24 am 
Offline
Addict
Addict
User avatar

Joined: Sat Jun 30, 2007 8:04 pm
Posts: 3237
This is fantastic, srod!

Does coffIT suffer the same problem as TailBite where older libraries might not compile within a newer version of PureBasic?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 28, 2008 3:41 am 
Offline
Addict
Addict

Joined: Mon May 29, 2006 1:01 am
Posts: 1965
Location: Outback
Bloody oath!

srod trek - going where very few have gone before. :D

_________________
Dare2 cut down to size


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 28, 2008 4:58 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Sep 17, 2007 10:28 am
Posts: 141
Location: P.O.P
great!

_________________
POiNT.OF.PRESENCE group


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 28, 2008 9:19 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
Thanks :D :D :D

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 28, 2008 10:19 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10518
Location: Beyond the pale...
Mistrel wrote:
This is fantastic, srod!

Does coffIT suffer the same problem as TailBite where older libraries might not compile within a newer version of PureBasic?


Certainly does! :)

Such problems are more likely to arise when creating libraries which use some of PB's user libraries. Your resulting static libs are then only useable in Purebasic applications anyhow and so in this respect, it is just like Tailbite.

Creating static libs which use only PB keywords and Win api functions should not be so susceptible to being broken, even if subsequently used in PB applications etc. Using such libs in other programming languages should not be so hindered however.

_________________
I may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 28, 2008 10:30 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
srod wrote:
Such problems are more likely to arise when creating libraries which use some of PB's user libraries. Your resulting static libs are then only useable in Purebasic applications anyhow and so in this respect, it is just like Tailbite.

I may be wrong but I think it may be solved by using LIB files instead of OBJ, _if_ the LIB contains all PB dependancies. But then there may be a 'wrapper' license issue.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 28, 2008 10:35 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10518
Location: Beyond the pale...
I'm not sure about that Gnozal. I don't think that POLIB is equipped to look inside Purebasic user libraries in order to extract the relevant function code etc. POLIB expects standard .lib and .obj files. Besides version 2 of coffIT will create .libs from only the functions in the PB source file given to it (it splits the functions like Tailbite). It will not add any external libraries - except to declare all external symbols. All other dependencies are added at the link stage and are left to the underlying development environment.

_________________
I may look like a mule, but I'm not a complete ass.


Last edited by srod on Thu Feb 28, 2008 12:58 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: coffIT - create obj and lib static libraries from PB sou
PostPosted: Thu Feb 28, 2008 11:34 am 
Offline
Addict
Addict

Joined: Mon May 29, 2006 1:01 am
Posts: 1965
Location: Outback
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:
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!

_________________
Dare2 cut down to size


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 28, 2008 11:37 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10518
Location: Beyond the pale...
Dare, at this stage I think I'm going to move to the new forum. Could you please repost this query in the new thread about to hit the streets? :)

_________________
I may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 28, 2008 3:39 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 12, 2005 3:35 am
Posts: 803
Location: Germany(Hessen)
A cool tool.
Thanks for free sharing.

Best regards

Wolf


PS: I made a little coffIT-article in the newsarea of purebasic-lounge.com.

_________________
German blog about IT and programming
German PB forums


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 28, 2008 5:48 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10518
Location: Beyond the pale...
Hroudtwolf wrote:
PS: I made a little coffIT-article in the newsarea of purebasic-lounge.com.


Now the only problem with that is that it's in German! :wink:

Thanks Wolf - much appreciated.

_________________
I may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 28, 2008 5:57 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Feb 21, 2006 12:37 pm
Posts: 119
Removed.


Last edited by hellhound66 on Wed Mar 19, 2008 11:29 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 28, 2008 10:56 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10518
Location: Beyond the pale...
28/2/2008. Bug fix.
coffIT would crash out if the linker complained with an error when compiling a source file to a .obj file. An absurd thing to do when you think about it! Doh! :roll:

The download link is in the second post of this thread.

Have also added an example of how to use coffIT in conjunction with POLIB to create a static .lib file from multiple object files.
coffIT version 2 will do this automatically, but in the mean time ......
:)

_________________
I may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 31 posts ]  Go to page 1, 2, 3  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye