Quantcast

Problems in linking ikfast shared library against other file

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Problems in linking ikfast shared library against other file

andrestoga
Hi,

After generating the IKFast Solution CPP file following this tutorial:

http://docs.ros.org/hydro/api/moveit_ikfast/html/doc/ikfast_tutorial.html

, I created a shared library with that file but I'm having linking problems when I want to use it in other file. I followed the instructions to create the shared library in the cpp file using this command:

g++ -fPIC -lstdc++ -DIKFAST_NO_MAIN -DIKFAST_CLIBRARY -shared -Wl,-soname,libik.so -o libik.so lwr_arm_ikfast_solver.cpp

Everything works ok, then, I tried to link it with another file that contains a main function, which basically is the same main function that is in the IKFast Solution CPP file, using this command:

g++ -L/home/andrestoga/ros_kuka_isir/src/lwr_ikfast/src -Wall -lik -o testing_iksolver testing_iksolver.cpp

but I'm getting a bunch of errors... I posted the errors at the end of this post. I don't know why is not linking correctly. I'm including in that file the "ikfast.h" and I followed this tutorial to link shared libraries:

http://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html

Any help would be appreciated.

Best,

andrestoga@andrestoga-RoboLab:~/ros_kuka_isir/src/lwr_ikfast/src$ g++ -L/home/andrestoga/ros_kuka_isir/src/lwr_ikfast/src -Wall -lik -o testing_iksolver testing_iksolver.cpp
testing_iksolver.cpp:5:17: error: ‘IKFAST_NAMESPACE’ is not a namespace-name
 using namespace IKFAST_NAMESPACE;
                 ^
testing_iksolver.cpp:5:33: error: expected namespace-name before ‘;’ token
 using namespace IKFAST_NAMESPACE;
                                 ^
testing_iksolver.cpp: In function ‘int main(int, char**)’:
testing_iksolver.cpp:10:41: error: ‘GetNumFreeParameters’ was not declared in this scope
     if( argc != 12+GetNumFreeParameters()+1 )
                                         ^
testing_iksolver.cpp:19:5: error: ‘IkSolutionList’ was not declared in this scope
     IkSolutionList<IkReal> solutions;
     ^
testing_iksolver.cpp:19:5: note: suggested alternative:
In file included from testing_iksolver.cpp:3:0:
ikfast.h:229:7: note:   ‘ikfast::IkSolutionList’
 class IkSolutionList : public IkSolutionListBase<T>
       ^
testing_iksolver.cpp:19:20: error: ‘IkReal’ was not declared in this scope
     IkSolutionList<IkReal> solutions;
                    ^
testing_iksolver.cpp:19:28: error: ‘solutions’ was not declared in this scope
     IkSolutionList<IkReal> solutions;
                            ^
testing_iksolver.cpp:21:23: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp, class _Alloc> class std::vector’
     std::vector<IkReal> vfree(GetNumFreeParameters());
                       ^
testing_iksolver.cpp:21:23: error:   expected a type, got ‘IkReal’
testing_iksolver.cpp:21:23: error: template argument 2 is invalid
testing_iksolver.cpp:21:30: error: invalid type in declaration before ‘(’ token
     std::vector<IkReal> vfree(GetNumFreeParameters());
                              ^
testing_iksolver.cpp:21:52: error: ‘GetNumFreeParameters’ was not declared in this scope
     std::vector<IkReal> vfree(GetNumFreeParameters());
                                                    ^
testing_iksolver.cpp:23:12: error: expected ‘;’ before ‘eerot’
     IkReal eerot[9],eetrans[3];
            ^
testing_iksolver.cpp:25:5: error: ‘eerot’ was not declared in this scope
     eerot[0] = atof(argv[1]);
     ^
testing_iksolver.cpp:28:5: error: ‘eetrans’ was not declared in this scope
     eetrans[0] = atof(argv[4]);
     ^
testing_iksolver.cpp:38:38: error: request for member ‘size’ in ‘vfree’, which is of non-class type ‘int’
     for(std::size_t i = 0; i < vfree.size(); ++i)
                                      ^
testing_iksolver.cpp:39:16: error: invalid types ‘int[std::size_t {aka long unsigned int}]’ for array subscript
         vfree[i] = atof(argv[13+i]);
                ^
testing_iksolver.cpp:41:53: error: request for member ‘size’ in ‘vfree’, which is of non-class type ‘int’
     bool bSuccess = ComputeIk(eetrans, eerot, vfree.size() > 0 ? &vfree[0] : NULL, solutions);
                                                     ^
testing_iksolver.cpp:41:74: error: invalid types ‘int[int]’ for array subscript
     bool bSuccess = ComputeIk(eetrans, eerot, vfree.size() > 0 ? &vfree[0] : NULL, solutions);
                                                                          ^
testing_iksolver.cpp:41:93: error: ‘ComputeIk’ was not declared in this scope
     bool bSuccess = ComputeIk(eetrans, eerot, vfree.size() > 0 ? &vfree[0] : NULL, solutions);
                                                                                             ^
testing_iksolver.cpp:50:23: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp, class _Alloc> class std::vector’
     std::vector<IkReal> solvalues(GetNumJoints());
                       ^
testing_iksolver.cpp:50:23: error:   expected a type, got ‘IkReal’
testing_iksolver.cpp:50:23: error: template argument 2 is invalid
testing_iksolver.cpp:50:34: error: invalid type in declaration before ‘(’ token
     std::vector<IkReal> solvalues(GetNumJoints());
                                  ^
testing_iksolver.cpp:50:48: error: ‘GetNumJoints’ was not declared in this scope
     std::vector<IkReal> solvalues(GetNumJoints());
                                                ^
testing_iksolver.cpp:54:15: error: ‘IkSolutionBase’ does not name a type
         const IkSolutionBase<IkReal>& sol = solutions.GetSolution(i);
               ^
testing_iksolver.cpp:55:50: error: ‘sol’ was not declared in this scope
         printf("sol%d (free=%d): ", (int)i, (int)sol.GetFree().size());
                                                  ^
testing_iksolver.cpp:56:27: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp, class _Alloc> class std::vector’
         std::vector<IkReal> vsolfree(sol.GetFree().size());
                           ^
testing_iksolver.cpp:56:27: error:   expected a type, got ‘IkReal’
testing_iksolver.cpp:56:27: error: template argument 2 is invalid
testing_iksolver.cpp:56:37: error: invalid type in declaration before ‘(’ token
         std::vector<IkReal> vsolfree(sol.GetFree().size());
                                     ^
testing_iksolver.cpp:57:37: error: invalid types ‘int[int]’ for array subscript
         sol.GetSolution(&solvalues[0],vsolfree.size()>0?&vsolfree[0]:NULL);
                                     ^
testing_iksolver.cpp:57:48: error: request for member ‘size’ in ‘vsolfree’, which is of non-class type ‘int’
         sol.GetSolution(&solvalues[0],vsolfree.size()>0?&vsolfree[0]:NULL);
                                                ^
testing_iksolver.cpp:57:68: error: invalid types ‘int[int]’ for array subscript
         sol.GetSolution(&solvalues[0],vsolfree.size()>0?&vsolfree[0]:NULL);
                                                                    ^
testing_iksolver.cpp:58:47: error: request for member ‘size’ in ‘solvalues’, which is of non-class type ‘int’
         for( std::size_t j = 0; j < solvalues.size(); ++j)
                                               ^
testing_iksolver.cpp:59:42: error: invalid types ‘int[std::size_t {aka long unsigned int}]’ for array subscript
             printf("%.15f, ", solvalues[j]);
                                          ^
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problems in linking ikfast shared library against other file

andrestoga
I tried to include the .h file with this command:

g++ -I. -fPIC -Wall -O2 -c testing_iksolver.cpp

and then:

g++ -o testing_iksolver testing_iksolver.cpp -L. -Wall -lik

but I'm getting the same errors. What I'm missing?

Best,
Loading...