Skip to content

Unnecessary use of LoadOpenSimLibrary("osimActuators") in tests #4139

@francoisk

Description

@francoisk

The LoadOpenSimLibrary("osimActuators") calls fail in my setup because the shared library filename contains versioning information. (I'm packaging OpenSim for build2 which means reimplementing the entire build.)

Based on comments and commits these calls exist because the osimActuators shared library "is not automatically loaded on anything other than clang". The reason for this is that the tests in question do not actually reference anything in osimActuators directly (e.g., call any of its functions) so the linker sees this and decides there's no need to record the dependency in the executable. And thus osimActuators is not loaded when the executable is run.

If we instead just call one of its functions the linker will record the dependency in the test executable and the osimActuators library will get loaded automatically.

Given that the only reason we need osimActuators is because the data files these tests load contain objects defined in and registered by that library, perhaps the most appropriate function to call would be RegisterTypes_osimActuators(). That works but then we end up registering the osimActuators types twice (first time being when the library is loaded). So I would say just default-instantiating one of the classes the test is going to be loading from its data files is probably the best choice:

#include <OpenSim/Actuators/Thelen2003Muscle.h>
...
int main () {
    // Explanation goes here
    { Thelen2003Muscle t; }
    ...
}

I think there are probably linker-specific methods to make this work but it seems like the above is probably going to be simpler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions