Page 1 of 2
Opensim - Linux
Posted: Wed Oct 19, 2016 10:48 pm
by gautamr1858
I am trying to compile a .cpp file in ubuntu but I am having some problems with the compilation as to linking the libraries of opensim, following is the run command
Code: Select all
g++ -lm tugofwar.cpp -o tugofwarmodel -std=c++11 -I ../../../open/include/SimTK/ -I ../../include -L/open/lib -L/open/bin -losimSimulation -losimActuators -losimCommon -losimAnalyses -losimTools -lSimTKcommon -lSimTKmath -lSimTKsimbody
The error is tugofwar.cpp:2:29: fatal error: OpenSim/OpenSim.h: No such file or directory
#include <OpenSim/OpenSim.h>
My opensim installation is in home directory in Ubuntu
Please help me with this.
Re: Opensim - Linux
Posted: Wed Oct 19, 2016 11:03 pm
by mitkof6
You need to provide the OpenSim include directory.
Re: Opensim - Linux
Posted: Fri Oct 21, 2016 2:23 am
by gautamr1858
Hi, I have provided the include library but somehow it is saying no such file or directory, in my run command here I have included that
Code: Select all
g++ -lm tugofwar.cpp -o tugofwarmodel -std=c++11 -I ../../../open/include/SimTK/ -I ../../include -L/open/lib -L/open/bin -losimSimulation -losimActuators -losimCommon -losimAnalyses -losimTools -lSimTKcommon -lSimTKmath -lSimTKsimbody
I am not getting the point because include library folder is not there in the installation folder of opensim when i instlall in linux
Re: Opensim - Linux
Posted: Fri Oct 21, 2016 3:54 am
by mitkof6
I think you have to define the absolute path and also you don't add a space after -I. Why don't you try using the CMake module to take care of all the dependencies?
Re: Opensim - Linux
Posted: Fri Oct 21, 2016 10:54 pm
by gautamr1858
Absolute path meaning ? And I did use CMAKE for the installation but here what I am trying to do is I have a .cpp file with some control codes and I am compiling my tug of war model again so when it gets compiled it will be converted to .exe file with the control algorithm in it. So how can I do this in cmake ?
Re: Opensim - Linux
Posted: Fri Oct 21, 2016 11:11 pm
by mitkof6
Absolute path is the whole path while relative is with respect to your current dir, but I think gcc does not know your current dir. If you look at the OpenSim installation folder, there should be an example folder with projects using CMake, use these files as a starting point.
Re: Opensim - Linux
Posted: Mon Oct 24, 2016 1:21 am
by gautamr1858
Yeah I got the include directory correct, I am sorry I thought include folder in the opensim, I did not know that you were referring to "-I" command in C++, yeah its working fine but now i am getting this error
Code: Select all
gautam@ubuntu:~/b/tow$ g++ -lm tugofwar.cpp -o tugofwarmodel -std=c++11 -I/home/gautam/opensim/sdk/include/SimTK/simbody -I/home/gautam/opensim/sdk/include -L/home/gautam/opensim/lib -L/home/gautam/opensim/bin -losimSimulation -losimActuators -losimCommon -losimAnalyses -losimTools -lSimTKcommon -lSimTKmath -lSimTKsimbody
tugofwar.cpp: In function ‘int main(int, char**)’:
tugofwar.cpp:560:30: error: call of overloaded ‘isnan(double&)’ is ambiguous
if (isnan(err))
^
tugofwar.cpp:560:30: note: candidates are:
In file included from /usr/include/features.h:374:0,
from /usr/include/x86_64-linux-gnu/c++/4.8/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/4.8/bits/c++config.h:426,
from /usr/include/c++/4.8/iostream:38,
from /home/gautam/opensim/sdk/include/OpenSim/Common/XMLDocument.h:32,
from /home/gautam/opensim/sdk/include/OpenSim/Common/Object.h:39,
from /home/gautam/opensim/sdk/include/OpenSim/Common/osimCommon.h:26,
from /home/gautam/opensim/sdk/include/OpenSim/OpenSim.h:26,
from tugofwar.cpp:2:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:234:1: note: int isnan(double)
__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
^
In file included from /home/gautam/opensim/sdk/include/SimTK/simbody/SimTKcommon/internal/common.h:249:0,
from /home/gautam/opensim/sdk/include/SimTK/simbody/SimTKcommon/basics.h:38,
from /home/gautam/opensim/sdk/include/SimTK/simbody/SimTKcommon.h:32,
from /home/gautam/opensim/sdk/include/OpenSim/Common/XMLDocument.h:34,
from /home/gautam/opensim/sdk/include/OpenSim/Common/Object.h:39,
from /home/gautam/opensim/sdk/include/OpenSim/Common/osimCommon.h:26,
from /home/gautam/opensim/sdk/include/OpenSim/OpenSim.h:26,
from tugofwar.cpp:2:
/usr/include/c++/4.8/cmath:626:3: note: constexpr bool std::isnan(long double)
isnan(long double __x)
^
/usr/include/c++/4.8/cmath:622:3: note: constexpr bool std::isnan(double)
isnan(double __x)
^
/usr/include/c++/4.8/cmath:618:3: note: constexpr bool std::isnan(float)
isnan(float __x)
Please help me with this error
Re: Opensim - Linux
Posted: Mon Oct 24, 2016 4:18 am
by mitkof6
You are compiling with an older version of g++. You need g++ > v4.9. Read the requirements:
https://github.com/opensim-org/opensim-core
Again I will pursuit you to use CMake for many many reasons.
Best
Re: Opensim - Linux
Posted: Mon Oct 24, 2016 10:50 pm
by gautamr1858
It is showing the same error as follows with g++ version of 5.0 and regarding the cmake its kind of complicated to do it in linux. But please help me to debug this error .
Code: Select all
gautam@ubuntu:~/b/tow$ g++ -lm tugofwar.cpp -o tugofwarmodel -std=c++11 -I/home/gautam/opensim/sdk/include/SimTK/simbody -I/home/gautam/opensim/sdk/include -L/home/gautam/opensim/lib -L/home/gautam/opensim/bin -losimSimulation -losimActuators -losimCommon -losimAnalyses -losimTools -lSimTKcommon -lSimTKmath -lSimTKsimbody
tugofwar.cpp: In function ‘int main(int, char**)’:
tugofwar.cpp:560:30: error: call of overloaded ‘isnan(double&)’ is ambiguous
if (isnan(err))
^
In file included from /usr/include/features.h:374:0,
from /usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h:482,
from /usr/include/c++/5/iostream:38,
from /home/gautam/opensim/sdk/include/OpenSim/Common/XMLDocument.h:32,
from /home/gautam/opensim/sdk/include/OpenSim/Common/Object.h:39,
from /home/gautam/opensim/sdk/include/OpenSim/Common/osimCommon.h:26,
from /home/gautam/opensim/sdk/include/OpenSim/OpenSim.h:26,
from tugofwar.cpp:2:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:234:1: note: candidate: int isnan(double)
__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
^
In file included from /home/gautam/opensim/sdk/include/SimTK/simbody/SimTKcommon/internal/common.h:249:0,
from /home/gautam/opensim/sdk/include/SimTK/simbody/SimTKcommon/basics.h:38,
from /home/gautam/opensim/sdk/include/SimTK/simbody/SimTKcommon.h:32,
from /home/gautam/opensim/sdk/include/OpenSim/Common/XMLDocument.h:34,
from /home/gautam/opensim/sdk/include/OpenSim/Common/Object.h:39,
from /home/gautam/opensim/sdk/include/OpenSim/Common/osimCommon.h:26,
from /home/gautam/opensim/sdk/include/OpenSim/OpenSim.h:26,
from tugofwar.cpp:2:
/usr/include/c++/5/cmath:634:3: note: candidate: constexpr bool std::isnan(long double)
isnan(long double __x)
^
/usr/include/c++/5/cmath:630:3: note: candidate: constexpr bool std::isnan(double)
isnan(double __x)
^
/usr/include/c++/5/cmath:626:3: note: candidate: constexpr bool std::isnan(float)
isnan(float __x)
^
Re: Opensim - Linux
Posted: Mon Oct 24, 2016 11:12 pm
by mitkof6
You could avoid these kind of problems through CMake, and the tool will inform you if you have misconfigured the installation. Please post your tugofwar.cpp, maybe the problem is there.