Plugin build error - DeMers Reflex Controller [SOLVED]

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Adam Yoder
Posts: 16
Joined: Thu Jul 19, 2012 4:24 pm

Plugin build error - DeMers Reflex Controller [SOLVED]

Post by Adam Yoder » Fri Dec 27, 2019 4:01 pm

I am hitting an error when trying to build Matt DeMer's reflex muscle controller plugin from C++ source
I'm curious if anyone's ever built this successfully on Windows? Since Matt's GitHub instructions seem to suggest he did originally in Linux

https://github.com/msdemers/opensim-reflex-controllers

https://doi.org/10.1016/j.jbiomech.2016.11.002

Found a related forum post but doesnt look like they arrived at a solution either:
viewtopicPhpbb.php?f=91&t=7192&p=0&star ... 5f46d030b4

My current setup:
OpenSim 3.3 (although originally built for 3.2, Matt's last 2015 GitHub commit was supposed to be a patch for 3.3)
Windows 10.0.18362
Visual Studio 2015 v14.0.25431.01 Update 3
CMake 3.16.0

CMake Configure + Generate steps complete fine, but I get a Visual Studio LNK2001 "linker tool error" when executing ALL_BUILD in Release config, specifically 5 errors, 1 for each of the 5 .obj's

Example Error Code LNK2001

Code: Select all

unresolved external symbol "__declspec(dllimport) public: __cdecl OpenSim::Controller::Controller(class OpenSim::Controller &&)" (__imp_??0Controller@OpenSim@@QEAA@$$QEAV01@@Z)
Arising from (I think) this declaration at start of each header file:

Code: Select all

class OSIMREFLEXES_API ReflexController : public Controller {OpenSim_DECLARE_CONCRETE_OBJECT(ReflexController, Controller);
My debug steps so far (I am no C++ expert...):

1) google suggests this is caused by a missing or incorrect external function definition, the Controller class? But #include <OpenSim/Simulation/Control/Controller.h> is at start of each header, and I can see Controller.h listed in VS External Dependencies

2) Tried building and loading example plugins \OpenSim 3.3\sdk\APIExamples\Plugins\. All build and install without error

3) From the error syntax, it appears OSIMREFLEXES_API macro is being set to "__declspec(dllimport)" ?
But the logic in osimReflexesDLL.h Line 41 suggests it should be dllexport since OSIMREFLEXES_EXPORTS is defined on Line 22 of CMakeLists
Last edited by Adam Yoder on Mon Dec 30, 2019 12:10 pm, edited 1 time in total.

User avatar
Adam Yoder
Posts: 16
Joined: Thu Jul 19, 2012 4:24 pm

Re: Plugin build error - DeMers Reflex Controller

Post by Adam Yoder » Mon Dec 30, 2019 11:50 am

I think i fixed it! It was a Visual Studio versioning error

Per the wiki I was aware it's crucial to use the exact same Visual Studio version for plugin build as was used to build the target OpenSim distribution

i.e. because the needed Controller() definition to be extended is actually contained in /sdk/lib/osimSimulation.lib compiled by VS... not the .h/.cpp source code like i thought above

https://simtk-confluence.stanford.edu/d ... ng+Plugins

I had been using VS2015 for v3.3 per this page:

https://simtk-confluence.stanford.edu:8 ... rom+Source

But I checked under GUI->Help->About->Details:Build Info for my v3.3 (which i installed from a pre-built exe), and it listed VS2013

So I installed VS2013 and plugin built successfully with no errors.
Interesting.
I may try building with VS2017 to see if I can get working with OpenSim 4.0... pending any needed source code updates to handle 3.0->4.0 API changes

POST REPLY