Hello,
I am trying to compile a c++ program for optimizing muscles on Mac. I use the function computeStateVariableDerivatives within the file. Unfortunately I am receiving an error that says I cannot override the function from a void to a vector. Here is the source code that is getting a compilation error:
SimTK::Vector computeStateVariableDerivatives(const SimTK::State& s) const;
and here is the error I am recieving:
Virtual function 'computeStateVariableDerivatives' has a different return type ('SimTK::Vector' (aka 'Vector_<double>')) than the function it overrides (which has return type 'void')
The documentation shows that this function should be returning a vector, so why am I getting an error that it was originally returning void? This error did not come up when the file was run in visual studio, but now that it is being adapted for Mac there seems to be an issue. Could this possibly be a problem with the Xcode compiler?
Thank you
Error with computeStateVariableDerivatives
- Akhil Bheemreddy
- Posts: 14
- Joined: Wed Jul 26, 2017 9:41 am
- Christopher Dembia
- Posts: 506
- Joined: Fri Oct 12, 2012 4:09 pm
Re: Error with computeStateVariableDerivatives
The signature of this function changed between 3.3 and 4.0 (GitHub).
- Akhil Bheemreddy
- Posts: 14
- Joined: Wed Jul 26, 2017 9:41 am
Re: Error with computeStateVariableDerivatives
Hi,
I believe that both the Mac and Windows versions that we are using are 3.3. I do not think that this is what is causing the issue. Do you have any other ideas on wha the problem may be?
Thanks
I believe that both the Mac and Windows versions that we are using are 3.3. I do not think that this is what is causing the issue. Do you have any other ideas on wha the problem may be?
Thanks
- Christopher Dembia
- Posts: 506
- Joined: Fri Oct 12, 2012 4:09 pm
Re: Error with computeStateVariableDerivatives
In that case, to help, we need to see the code your code.
- Akhil Bheemreddy
- Posts: 14
- Joined: Wed Jul 26, 2017 9:41 am
Re: Error with computeStateVariableDerivatives
I think it will be difficult for me to post all the code, but I can try to help narrow down what the problem is. The error is occurring with the function
SimTK::Vector computeStateVariableDerivatives(const SimTK::State& s) const,
where Xcode says that
Virtual function 'computeStateVariableDerivatives' has a different return type ('SimTK::Vector' (aka 'Vector_<double>')) than the function it overrides (which has return type 'void').
This issue appears to be due to because the function computeStateVariableDerivatives is defined within the file component.h as
virtual void computeStateVariableDerivatives(const SimTK::State& s) const;
I believe that Xcode is attempting to override this virtual void output, and failing to do so, but instead we would like to override a virtual SimTK vector from the same function. As I mentioned before, on Microsoft, while using visual studio, this error does not occur. Has this issue come up before? Are you aware of any possible solution to this problem?
Thanks
SimTK::Vector computeStateVariableDerivatives(const SimTK::State& s) const,
where Xcode says that
Virtual function 'computeStateVariableDerivatives' has a different return type ('SimTK::Vector' (aka 'Vector_<double>')) than the function it overrides (which has return type 'void').
This issue appears to be due to because the function computeStateVariableDerivatives is defined within the file component.h as
virtual void computeStateVariableDerivatives(const SimTK::State& s) const;
I believe that Xcode is attempting to override this virtual void output, and failing to do so, but instead we would like to override a virtual SimTK vector from the same function. As I mentioned before, on Microsoft, while using visual studio, this error does not occur. Has this issue come up before? Are you aware of any possible solution to this problem?
Thanks
- Christopher Dembia
- Posts: 506
- Joined: Fri Oct 12, 2012 4:09 pm
Re: Error with computeStateVariableDerivatives
Akhil:
How did you obtain the copy of OpenSim you are using on Mac? The signature for `computeStateVariableDerivatives()` in Component.h is for OpenSim 4.0.
How did you obtain the copy of OpenSim you are using on Mac? The signature for `computeStateVariableDerivatives()` in Component.h is for OpenSim 4.0.
- Akhil Bheemreddy
- Posts: 14
- Joined: Wed Jul 26, 2017 9:41 am
Re: Error with computeStateVariableDerivatives
I followed the steps from the README.md file that is within the OpenSim source download for OpenSim 3.3. The read me is located in the simbody-Simbody-3.5.3 zip. Although earlier I had downloaded the OpenSim 4.0 GUI beta for Mac.
Does this mean that the component.h virtual void should not be a part of OpenSim 3.3? What do you suggest that I do?
Thanks,
Akhil Bheemreddy
Does this mean that the component.h virtual void should not be a part of OpenSim 3.3? What do you suggest that I do?
Thanks,
Akhil Bheemreddy
- Christopher Dembia
- Posts: 506
- Joined: Fri Oct 12, 2012 4:09 pm
Re: Error with computeStateVariableDerivatives
Akhil:
There is no README.md in the OpenSim 3.3 source code. There *is* a README.md in the Simbody 3.5.3 source code, but this file does not explain how to build OpenSim.
The OpenSim 4.0 GUI beta comes with the OpenSim 4.0 API. You can check which copy of OpenSim is being used by your project by inspecting the value of the OpenSim_DIR CMake variable in your project (open the CMake GUI or open the CMakeCache.txt file in your build directory).
There is no README.md in the OpenSim 3.3 source code. There *is* a README.md in the Simbody 3.5.3 source code, but this file does not explain how to build OpenSim.
The OpenSim 4.0 GUI beta comes with the OpenSim 4.0 API. You can check which copy of OpenSim is being used by your project by inspecting the value of the OpenSim_DIR CMake variable in your project (open the CMake GUI or open the CMakeCache.txt file in your build directory).
It *is not* part of OpenSim 3.3.Does this mean that the component.h virtual void should not be a part of OpenSim 3.3?
Both the OpenSim 3.3 and 4.0 source code can be used on Mac. I suggest you use whichever version your own code was written for. The instructions for building OpenSim 3.3 from source are here: https://simtk-confluence.stanford.edu/d ... rom+SourceWhat do you suggest that I do?