1.2 + PhysX + Mac == namespace problems
by Dean Calver · in Torque 3D Professional · 12/15/2011 (8:57 am) · 0 replies
So the evil that always ends up hitting a project once its get to a certain size, has reared its head.
PhysX Core on Mac is statically linked and it uses Opcode and classes called SceneManager, Material, ConvexBody etc.
And so does Torque3D 1.2 which upsets the linker.
For Opcode its relatively easy to fix, by simply changing the Opcode namespace in Torque3Ds version to OpcodeT3D but Torque proper doesn't use namespace (which if it did would have stopped this issue anyway).
Renaming things is a problem as many of the classes are exported directly to TorqueScript via console and so also means changing scripts, data files etc.
Longer term Torque needs to go through the boring (though simple) job of adopting a namespace, perhaps GG, perhaps Torque but something that would avoid using the global namespace. Whilst NV PhysX is just to blame (arguable more so, as its a third party library), the reality is libraries do pollute the linker namespace (often to support non namespace aware languages, though in the case they should adopt a prefix all glXXX).
Short term, I'm not really sure... I could just correct the name, update the scripts etc. or perhaps see if I can find a way to convince the Mac toolchain to rename the library's names to something that doesn't clash.
If I get a good solution, I'll let you know!
Deano
PhysX Core on Mac is statically linked and it uses Opcode and classes called SceneManager, Material, ConvexBody etc.
And so does Torque3D 1.2 which upsets the linker.
For Opcode its relatively easy to fix, by simply changing the Opcode namespace in Torque3Ds version to OpcodeT3D but Torque proper doesn't use namespace (which if it did would have stopped this issue anyway).
Renaming things is a problem as many of the classes are exported directly to TorqueScript via console and so also means changing scripts, data files etc.
Longer term Torque needs to go through the boring (though simple) job of adopting a namespace, perhaps GG, perhaps Torque but something that would avoid using the global namespace. Whilst NV PhysX is just to blame (arguable more so, as its a third party library), the reality is libraries do pollute the linker namespace (often to support non namespace aware languages, though in the case they should adopt a prefix all glXXX).
Short term, I'm not really sure... I could just correct the name, update the scripts etc. or perhaps see if I can find a way to convince the Mac toolchain to rename the library's names to something that doesn't clash.
If I get a good solution, I'll let you know!
Deano
About the author
Been a games dev for more years than its comfortable to remember. Have shipped a fair few games, most recently have been Lead Programmer on Brink and Heavenly Sword.