need help with PK SDK - build simple lib

Just starting out? Need help? Post your questions and find answers here.
jack
Addict
Addict
Posts: 1337
Joined: Fri Apr 25, 2003 11:10 pm

need help with PK SDK - build simple lib

Post by jack »

I was unsuccessful trying to build the VC simple library using VC 2019, can you show me step by step how to do it ?
User avatar
idle
Always Here
Always Here
Posts: 5097
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: need help with PK SDK - build simple lib

Post by idle »

I assume you mean pb sdk. I looked at it recently and thought it required a lot of effort for no additional benefit, as we can now code a user lib in pb that compiles to a static lib with one click and we can then use it in compiled form in a project directly or share the source and the binary.
jack
Addict
Addict
Posts: 1337
Joined: Fri Apr 25, 2003 11:10 pm

Re: need help with PK SDK - build simple lib

Post by jack »

hi idle
yes I mean the PB SDK, I disagree that there are no benefits in using user libraries built using C
User avatar
idle
Always Here
Always Here
Posts: 5097
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: need help with PK SDK - build simple lib

Post by idle »

jack wrote: Sat Jun 18, 2022 10:41 pm hi idle
yes I mean the PB SDK, I disagree that there are no benefits in using user libraries built using C
What do you mean no benefits, compared to what my tool does?

You have full control of the c compiler
you can use either gcc or clang
You can code it in PB, C and later fasm (it's being added)
Its easy to modify, debug or unit test the code directly in your project from the PB IDE
You can share the code or just the lib or both.
You don't have to manually tell it which libs your using
you don't have to write a desc file to tell the ide what the functions are
you don't have to package it to deploy it other than a zip file
if the user has a later version of PB they can just recompile it from the source.

All it takes to create a static lib with my tool is

Code: Select all

CompilerIf #PB_Compiler_IsMainFile 
  
  !//makestatic c:\path\that\exists\libfoo.a; 
    
  ProcedureDLL Foo_Mul(a,b)   
    ProcedureReturn a * b 
  EndProcedure 
  
  ProcedureDLL Foo_Div(a,b) 
    ProcedureReturn a / b        
  EndProcedure 
 
 ;compiler if debug unit test stuff...   
  
CompilerElse 
 
  ;the import to the lib  
  ImportC "libFoo.a"
    Foo_Mul(a,b) 
    Foo_Div(a,b) 
  EndImport    
     
CompilerEndIf   




And since it's the c backend doing the compiling you've got absolutely no disadvantages.

here is an x64 version of your decfloat lib
https://www.dropbox.com/s/269yf3kkdl60cpl/test.zip?dl=0
jack
Addict
Addict
Posts: 1337
Joined: Fri Apr 25, 2003 11:10 pm

Re: need help with PK SDK - build simple lib

Post by jack »

hello idle :)
I appreciate all your help, the static example is interesting, however I expect that if it were written in pure C it would be at least 2 times faster, besides that, I was planning on using memory allocation/de-allocation so as not to use the stack.
using an array in the structure simplifies the user experience but it's limited to what you can do and if you run out of stack memory the program would simply crash.
I could just make a static lib in C but the user experience is not as good than if you had a user lib, with a user lib with the corresponding res file you get hints in the IDE as you type in your program.
btw, your test lib is fixed at 100 digits which is probably a good limit anyway for this implementation
User avatar
idle
Always Here
Always Here
Posts: 5097
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: need help with PK SDK - build simple lib

Post by idle »

It's easy to make it dynamic on the heap with allocatememory on a pointer and no I don't think it would make any speed difference as such. Gcc and clang are pretty good at optimizing the pb generated code I will adapt it later today.
Post Reply