TheComet / ik

Minimal Inverse Kinematics library
MIT License
496 stars 71 forks source link

how to use the interface #3

Closed 76328 closed 4 years ago

76328 commented 5 years ago

and when i use "ik" it showed undefined

TheComet commented 5 years ago

Can you show the code you're trying to compile that causes this error?

Please also say which OS you're on and which branch you checked out.

76328 commented 5 years ago

#include <ik/ik.h> int main() { struct ik_solver_t* solver = ik.solver.create(IK_FABRIK); return 0; }

VSCode on ubuntu16.04

76328 commented 5 years ago

and i use terminal to build g++ ik-master-test.c -L /usr/local/lib -I /usr/local/include/ik /tmp/ccf6dLel.o:在函数‘main’中: ik-master-test.c:(.text+0xb):对‘ik’未定义的引用 (Undefined reference) collect2: error: ld returned 1 exit status

76328 commented 5 years ago

OK I have solved this problem

76328 commented 5 years ago

when I run the example code in Readme A new problem has occured :Exception has occurred. Segmentation fault

TheComet commented 5 years ago

You need to call ik.init(); first before using any other functions:

#include <ik/ik.h>

int main() {
    if (ik.init() != IK_OK)
        perror("ik.init failed");

    struct ik_solver_t* solver = ik.solver.create(IK_FABRIK);
    /* main loop here */

    ik.deinit();
    return 0;
}
TheComet commented 4 years ago

I'm going to assume it worked for you, so I'll close this issue now :)