Hi everyone,
I am trying to develop a OpenSim plugin for nonlinear characterstics study of ligaments. I have successfully compiled the code in cmd, however, I am having issue in adding the plugin into OpenSim. The error states as follows
Successfully loaded library C:\OpenSim 3.3\plugins\NonLinearLigament_Plugin.dll.
Object::newInstanceOfType(): object type 'NonLinearLigament' is not a registered Object!
Object type NonLinearLigament not recognized
The class of the plugin is inherited from the Force class. I have referred to the tutorial and discussion in the forum for plugin creation and similar errors but I am unable to detect source of the error.
Kindly help me in this regard.
Thanks and regards
Arnab
Error while registering user-defined plugin
- Arnab Sikidar
- Posts: 9
- Joined: Thu Sep 21, 2017 1:53 am
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Error while registering user-defined plugin
Hello,
Please make sure you have a line similar to
invoked upon loading your dll. This line is necessary to load/parse objects of type "NonLinearLigament" in XML and model files.
Hope this helps,
-Ayman
Please make sure you have a line similar to
Code: Select all
Object::RegisterType( NonLinearLigament() );
Hope this helps,
-Ayman
- Arnab Sikidar
- Posts: 9
- Joined: Thu Sep 21, 2017 1:53 am
Re: Error while registering user-defined plugin
Hello,
Thanks for the prompt reply. However, I already have this line in my RegisterTypes_osimPlugin.cpp. Here is the code
Thank you
Regards
Arnab Sikidar
Thanks for the prompt reply. However, I already have this line in my RegisterTypes_osimPlugin.cpp. Here is the code
Code: Select all
#include <string>
#include <iostream>
#include <OpenSim/Common/Object.h>
#include "RegisterTypes_osimPlugin.h"
#include "NonLinearLigament.h"
using namespace OpenSim;
using namespace std;
//static dllObjectInstantiator instantiator;
//_____________________________________________________________________________
/**
* The purpose of this routine is to register all class types exported by
* the Plugin library.
*/
OSIMPLUGIN_API void RegisterTypes_NLLigamentPlugin()
{
Object::RegisterType( NonLinearLigament() );
}
dllObjectInstantiator::dllObjectInstantiator()
{
registerDllClasses();
}
void dllObjectInstantiator::registerDllClasses()
{
RegisterTypes_NLLigamentPlugin();
}
Regards
Arnab Sikidar
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Error while registering user-defined plugin
Please uncomment the line
static dllObjectInstantiator instantiator;
and let me know how it goes.
-Ayman
static dllObjectInstantiator instantiator;
and let me know how it goes.
-Ayman
- Arnab Sikidar
- Posts: 9
- Joined: Thu Sep 21, 2017 1:53 am
Re: Error while registering user-defined plugin
Hi,
I have tried uncommenting the line but it is showing me an redefinition error. Here is the details of the error.
Error C2371 'instantiator': redefinition; different basic types Libraries - NLLigament_plugin
Thank you
Regards
Arnab
I have tried uncommenting the line
Code: Select all
static dllObjectInstantiator instantiator;
Error C2371 'instantiator': redefinition; different basic types Libraries - NLLigament_plugin
Thank you
Regards
Arnab
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Error while registering user-defined plugin
Hello,
Since I don't see all your code it's hard to tell where else this is defined, but you can try changing the name of the variable as in
since the whole purpose of instantiating the object is to cause the call to RegisterType, and the variable instantiator is never actually used.
Hope this helps,
-Ayman
Since I don't see all your code it's hard to tell where else this is defined, but you can try changing the name of the variable as in
Code: Select all
static dllObjectInstantiator my_instantiator;
Hope this helps,
-Ayman
- Arnab Sikidar
- Posts: 9
- Joined: Thu Sep 21, 2017 1:53 am
Re: Error while registering user-defined plugin
Hi
Thanks for the reply. It worked. The .lib and .dll files are getting generated and I am able to load them in OpenSim. However, I am still getting the error:
Object::newInstanceOfType(): object type 'NonLinearLigament' is not a registered Object!
Object type NonLinearLigament not recognized
whenever I am trying to load any object of the type 'NonLinearLigament' in my osim file.
I am attaching the code for registering my class('NonLinearLigament' ). Actually I have a number of user-defined headers in the .cpp file of NonLinearLigament. I have also simulated it in visual studio 17 with custom made tugofwar(of MuscleExample Tutorial) model and its working fine there.
Thank you
Regards
Arnab Sikidar
Thanks for the reply. It worked. The .lib and .dll files are getting generated and I am able to load them in OpenSim. However, I am still getting the error:
Object::newInstanceOfType(): object type 'NonLinearLigament' is not a registered Object!
Object type NonLinearLigament not recognized
whenever I am trying to load any object of the type 'NonLinearLigament' in my osim file.
I am attaching the code for registering my class('NonLinearLigament' ). Actually I have a number of user-defined headers in the .cpp file of NonLinearLigament. I have also simulated it in visual studio 17 with custom made tugofwar(of MuscleExample Tutorial) model and its working fine there.
Thank you
Regards
Arnab Sikidar
- Attachments
-
- RegisterTypes_NLLigamentPlugin.h
- (396 Bytes) Downloaded 27 times
-
- RegisterTypes_NLLigamentPlugin.cpp
- (836 Bytes) Downloaded 35 times
-
- NLLigamentPluginDLL.h
- (419 Bytes) Downloaded 30 times