The main problem was that you were trying to initialize structs from the globals block, whose initializers needed to be moved to the onInit method.
library BuildingLib uses Table
struct BT // Building Type
Table taOrder //= Table.create()
Table taIndex //= Table.create()
//TableArray ta = TableArray = TableArray[0x2000]
private static method onInit takes nothing returns nothing
set taOrder = Table.create()
set taIndex = Table.create()
endmethod
//static hashtable hash = InitHashtable()
static integer count = 1
static method create takes integer id, string order, integer limit_1, integer limit_2, integer limit_3 returns BT
local thistype b = .allocate()
set BT.taOrder[String2OrderIdBJ(order)] = BT.count
set BT.taIndex[id] = BT.count
//call SaveInteger(BT.hash, String2OrderIdBJ(order), 0, BT.count)
//call SaveInteger(BT.hash, id, 1, BT.count)
set BT.count = BT.count + 1
return b
endmethod
static method getBuildingIndexByOrder takes integer order returns integer
return BT.taOrder[order]
//return LoadInteger(BT.hash, order, 0)
endmethod
static method getBuildingIndexByType takes integer uid returns integer
return BT.taIndex[uid]
//return LoadInteger(BT.hash, uid, 1)
endmethod
static method getBuildingIndexByUnit takes unit u returns integer
return BT.taIndex[GetUnitTypeId(u)]
//return LoadInteger(BT.hash, GetUnitTypeId(u), 1)
endmethod
endstruct
endlibrary