xhawk18 / s_task

awaitable coroutine library for C
Other
595 stars 87 forks source link

编译运行example1错误 #2

Closed chinant closed 4 years ago

chinant commented 4 years ago

gcc -I s_task/include/ -I s_task/libuv/include/ main.c -o main libs_task.a -lpthread -ldl -lrt

直接链接libs_task.a文件, 运行main出错: Segmentation fault (core dumped)

gdb main, 提示: Program received signal SIGSEGV, Segmentation fault. 0x00000000004069a1 in uv_timer_init ()

用linux下的build.sh文件编译运行没有问题...

xhawk18 commented 4 years ago

hi, 使用 libs_task.a 需要加上 gcc -DUSE_LIBUV -I s_task/include/ -I s_task/libuv/include/ main.c -o main libs_task.a -lpthread -ldl -lrt

chinant commented 4 years ago

error

xhawk18 commented 4 years ago

使用USE_LIBUV的版本,可以参考 examples/ex2_libuv.c 的写法,将 uv_loop 作为参数传入

int main(int argc, char *argv[]) {
    uv_loop_t *loop = uv_default_loop();
    s_task_init_system(loop);

    s_task_create(g_stack_main, sizeof(g_stack_main), main_task, (void *)(size_t)argc);

    uv_run(loop, UV_RUN_DEFAULT);
    printf("all task is over\n");
    return 0;
}