Static linked library

Mac OSX specific forum
spacebuddy
Enthusiast
Enthusiast
Posts: 364
Joined: Thu Jul 02, 2009 5:42 am

Static linked library

Post by spacebuddy »

Is there anyway to create a static linked library (.a) or convert a dynamic library (.so) to static in PB x86?
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Re: Static linked library

Post by jack »

I know how to build a dynamic lib from a static lib but not the other way around, my guess is that it can be done but it's beyond my expertise.
btw you can use otool to view the libraries disassembled, for example, compile this example that's included with PB to dynamic lib.

Code: Select all

Structure MYSTRUCTURE 
  StringVariableA.s 
  StringVariableB.s 
  IntegerVariableA.i 
  FloatVariableA.f 
EndStructure 

ProcedureDLL AttachProcess(Instance) 
  ;this is an array of the structure 
  Global Dim TORETURN.MYSTRUCTURE(300) 
EndProcedure 

ProcedureDLL MyFunction() 
  For x = 0 To 300 
    TORETURN(x)\StringVariableA = "StringA " + Str(x) 
    TORETURN(x)\StringVariableB = "StringB " + Str(x) 
    TORETURN(x)\IntegerVariableA = x 
    TORETURN(x)\FloatVariableA = x + 0.5 
  Next x 

ProcedureReturn @TORETURN() 
EndProcedure
then assuming you named it mydylib you will get mydylib.so, to view the disassembly of the library launch terminal and enter the following
otool -tv mydylib.so
so my guess is that since the library can be disassembled, with enough work one could write a program that would extract the objects and build a static lib.
Post Reply