Page 1 of 1

OpenSim 4.2 Build Info for creating Plugins

Posted: Thu Jun 17, 2021 9:02 am
by st115990
Hello,

I'm trying to create a User plugin for OpenSim 4.2 for a new muscle model following this guideline: https://simtk-confluence.stanford.edu/d ... ng+Plugins
When I'm using Visual Studio 15 2017 with cmake to generate the project, the All Build stage stops in the Linker phase with the error:

Error LNK2038 mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Haeufle2014Muscle.obj Libraries - HaeufleMusclePlugin C:\opensim-core\OpenSim\Plugins\HaeufleMusclePlugin\build\spdlog.lib(fmt.obj) 1

Currently I'm struggeling to find out which version I should use to generate plugins for OpenSim 4.2. As suggested by the guideline I looked up my version under Help>About OpenSim>Details in OpenSim 4.2.
There the Build Info tells me OpenSim 4.2 was build with Microsoft Visual C++ 14.1 (MSC_VER 1928). This is a bit confusing for me since I looked the MSC_VER up here https://docs.microsoft.com/en-us/cpp/pr ... w=msvc-160 and found out that MSC_VER 1928 corresponds to Visual Studio 2019 version 16.8, 16.9.

Can somebody help me and tell me which Visual Studio Version I need to generate plugins for OpenSim 4.2?

Best,
Mike

Re: OpenSim 4.2 Build Info for creating Plugins

Posted: Thu Jun 17, 2021 11:03 am
by ongcf
I don't think the error refers to a mismatch in OpenSim version, but rather a mismatch in the build settings between your project and OpenSim. I'd guess that since the error includes "_ITERATOR_DEBUG_LEVEL", that between OpenSim and your plugin, one is built in Release and one is built in Debug mode.

Re: OpenSim 4.2 Build Info for creating Plugins

Posted: Fri Jun 18, 2021 7:24 am
by st115990
Thanks a lot for the answer. You are right, I selected the wrong mode. After building my plugin in Release mode I reduced the linker errors by half.
Still I have another linker error telling me I have unresolved external symbols:

Severity Code Description Project File Line Suppression State
Error LNK2001 unresolved external symbol __CxxFrameHandler4 Libraries - HaeufleMusclePlugin C:\opensim-core\OpenSim\Plugins\HaeufleMusclePlugin\build\spdlog.lib(fmt.obj) 1
Error LNK2001 unresolved external symbol __CxxFrameHandler4 Libraries - HaeufleMusclePlugin C:\opensim-core\OpenSim\Plugins\HaeufleMusclePlugin\build\spdlog.lib(spdlog.obj) 1
Severity Code Description Project File Line Suppression State
Error LNK2001 unresolved external symbol __CxxFrameHandler4 Libraries - HaeufleMusclePlugin C:\opensim-core\OpenSim\Plugins\HaeufleMusclePlugin\build\spdlog.lib(async.obj) 1
Error LNK2001 unresolved external symbol __CxxFrameHandler4 Libraries - HaeufleMusclePlugin C:\opensim-core\OpenSim\Plugins\HaeufleMusclePlugin\build\spdlog.lib(color_sinks.obj) 1
Error LNK2001 unresolved external symbol __GSHandlerCheck_EH4 Libraries - HaeufleMusclePlugin C:\opensim-core\OpenSim\Plugins\HaeufleMusclePlugin\build\spdlog.lib(fmt.obj) 1
Error LNK2001 unresolved external symbol __GSHandlerCheck_EH4 Libraries - HaeufleMusclePlugin C:\opensim-core\OpenSim\Plugins\HaeufleMusclePlugin\build\spdlog.lib(spdlog.obj) 1
Error LNK2001 unresolved external symbol __GSHandlerCheck_EH4 Libraries - HaeufleMusclePlugin C:\opensim-core\OpenSim\Plugins\HaeufleMusclePlugin\build\spdlog.lib(async.obj) 1
Error LNK2001 unresolved external symbol __GSHandlerCheck_EH4 Libraries - HaeufleMusclePlugin C:\opensim-core\OpenSim\Plugins\HaeufleMusclePlugin\build\spdlog.lib(color_sinks.obj) 1

Do you know how I could fix them? Is there a problem in my code or did I miss some steps from the guideline?

Thanks in advance.

Best
Mike

Re: OpenSim 4.2 Build Info for creating Plugins

Posted: Fri Jun 18, 2021 2:36 pm
by aymanh
Hi Mike,

This looks like an issue with your build of spdlog, something wrong with the configuration of the build. Did you use the superbuild process? Did you happen to have another incarnation of spdlog on your machine? Are you linking spdlog separately? If so try not linking with it.

Hope this helps,
-Ayman

Re: OpenSim 4.2 Build Info for creating Plugins

Posted: Sun Jun 20, 2021 2:32 am
by st115990
Hi Ayman,

thank you for your reply. Currently I'm trying to generate the plugin for the official released OpenSim 4.2 version.

In the cmake gui I specify the spdlog_DIR variable to C:/OpenSim 4.2/sdk/spdlog/lib/spdlog/cmake .
I still have several version of OpenSim (4.1 and self-build ones on my machine). On the path variable I only put in the OpenSim 4.2 installation folder.

I tried a workaround with building OpenSim from source ( tag 4.2) and generating the plugin for this version and then applying the plugin to OpenSim 4.2. With this, I succeeded to successfully load the plugin into the official released OpenSim 4.2.

Still I wonder why I get the linker error for when I try to generate the plugin directly for the official released version. Any ideas?

Best,
Mike

Re: OpenSim 4.2 Build Info for creating Plugins

Posted: Tue Jun 22, 2021 12:10 pm
by aymanh
Hi Mike,

This appears to be an issue with using different version of visual studio to build the library than your project/plugin. The solution suggested below is to modify the toolset used inside VS, and so it makes sense that it goes away if you build all libraries from source, though I'm not sure how common is your setup.

https://stackoverflow.com/questions/656 ... rnal-symbo

Thanks for reporting,
-Ayman

Re: OpenSim 4.2 Build Info for creating Plugins

Posted: Tue Jun 29, 2021 12:00 am
by st115990
Hello Ayman,

thanks a lot for clarifiying this to me. I will try your suggested solution.

Best,
Mike