How do you make PB code into a library?

Everything else that doesn't fall into one of the other PB categories.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

How do you make PB code into a library?

Post by netmaestro »

without using tailbite...

Say I have this code:

Code: Select all

ProcedureDll.l CreateStandardWindow(w.l, h.l) 
   Win=OpenWindow(#PB_Any,0,0,w,h,#PB_Window_Systemmenu|#PB_Window_ScreenCentered,"Standard Window") 
   ProcedureReturn Win 
Endprocedure 


and I want to make a library command out of it so it's available to me whenever I want to use it. How is this done? How does Tailbite do it?
Last edited by netmaestro on Tue Feb 21, 2006 3:43 pm, edited 4 times in total.
BERESHEIT
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post by va!n »

i think the pb compiler will convert your code to ASM and then it will compiled to an OBJ file... the linker will link the OBJ file to the final exe.. just an idea...
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Re: How do you make PB code into a library?

Post by Rings »

netmaestro wrote:without using tailbite...

Say I have this code:

Code: Select all

ProcedureDll.l CreateStandardWindow(w.l, h.l)
   Win=OpenWindow(#PB_Any,0,0,w,h,#PB_Window_Systemmenu|#PB_Window_ScreenCentered,"Standard Window")
   ProcedureReturn Win
Endprocedure
and I want to make a library command out of it so it's available to me whenever I want to use it. How is this done? How does Tailbite do it?
Tailbite comes with source, so study them :)
SPAMINATOR NR.1
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Yes, src.pack - how do I install it?
Last edited by netmaestro on Tue Feb 21, 2006 3:44 pm, edited 2 times in total.
BERESHEIT
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

Pu it in the TailBite directory, then open TBManager.exe, and click on "Extract sources"
El_Choni
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Ah, thanks. That's the ticket.
Last edited by netmaestro on Tue Feb 21, 2006 3:45 pm, edited 2 times in total.
BERESHEIT
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

if don't mind tagging along a dll, you could just make a dll and a .def file and then an import lib, see viewtopic.php?t=15687
then just import the functions (PB 4)
for example

Code: Select all


ImportC "MSVCRT.LIB"
  sprintf.l(result.s,num_format.s,number.d) As "_sprintf"
  sprintq.l(number.q,result.s,radix.l) As "__ui64toa"
  atoi64.q(number.s) As "__atoi64"
EndImport

;example use
n.l
s.s
y.q
Avogadro.d=6.0221415e23
s=Space(25)        ;allocate space
sprintf(s,"%18.15e",Avogadro)
debug s
n=sprintf("","%18.15e",Avogadro) ;supply a null "" as destination, to get the character length needed to "print" to string. 
debug "number of characters required to print "+str(n)
y=atoi64("123")
Last edited by jack on Tue Feb 07, 2006 5:58 am, edited 2 times in total.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Thank you Jack. That's a very helpful post.
Last edited by netmaestro on Tue Feb 21, 2006 3:46 pm, edited 2 times in total.
BERESHEIT
DarkDragon
Addict
Addict
Posts: 2347
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

Don't try to do a Linux Tailbite, it's nearly done(just a few parts are missing).
bye,
Daniel
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

DarkDragon wrote:Don't try to do a Linux Tailbite, it's nearly done(just a few parts are missing).
Only thing left would be a OSX tailbite ;)
DarkDragon
Addict
Addict
Posts: 2347
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

Shannara wrote:
DarkDragon wrote:Don't try to do a Linux Tailbite, it's nearly done(just a few parts are missing).
Only thing left would be a OSX tailbite ;)
Don't know, because I don't have a mac :-S . If I would get the money from Fred I would do it.
bye,
Daniel
Post Reply