cloudwu/ltask

WSL Ubuntu 18.04 gcc 7.5 build failed

sniper00 opened this issue · 5 comments

cc -g -Wall --shared -I/mnt/d/GitProjects/ltask/3rd/lua -Isrc -o ltask.dll src/ltask.c src/queue.c src/sysinfo.c src/service.c src/config.c src/lua-seri.c src/message.c src/systime.c src/timer.c src/sysapi.c -L/usr/local/bin -llua54
In file included from src/ltask.c:16:0:
src/timer.h:11:16: error: conflicting types for ‘timer_create’
 struct timer * timer_create();
                ^~~~~~~~~~~~
In file included from /usr/include/pthread.h:24:0,
                 from src/thread.h:75,
                 from src/ltask.c:10:
/usr/include/time.h:240:12: note: previous declaration of ‘timer_create’ was here
 extern int timer_create (clockid_t __clock_id,
            ^~~~~~~~~~~~
src/ltask.c: In function ‘luaseri_remove’:
src/ltask.c:895:2: warning: implicit declaration of function ‘free’ [-Wimplicit-function-declaration]
  free(data);
  ^~~~
src/ltask.c:895:2: warning: incompatible implicit declaration of built-in function ‘free’
src/ltask.c:895:2: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
src/ltask.c: In function ‘lunpack_remove’:
src/ltask.c:914:2: warning: incompatible implicit declaration of built-in function ‘free’
  free(msg);
  ^~~~
src/ltask.c:914:2: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
In file included from src/atomic.h:76:0,
                 from src/queue.h:4,
                 from src/queue.c:1:
src/atomic.h: In function ‘atomic_ptr_init’:
src/atomic.h:113:21: error: ‘uintptr_t’ undeclared (first use in this function); did you mean ‘__uint128_t’?
  atomic_init(aptr, (uintptr_t)v);
                     ^
src/atomic.h:113:21: note: each undeclared identifier is reported only once for each function it appears in
src/atomic.h:113:31: error: expected ‘)’ before ‘v’
  atomic_init(aptr, (uintptr_t)v);
                               ^
src/atomic.h: In function ‘atomic_ptr_store’:
src/atomic.h:123:22: error: ‘uintptr_t’ undeclared (first use in this function); did you mean ‘__uint128_t’?
  atomic_store(aptr, (uintptr_t)v);
                      ^
src/atomic.h:123:32: error: expected ‘)’ before ‘v’
  atomic_store(aptr, (uintptr_t)v);
                                ^
In file included from src/queue.h:4:0,
                 from src/queue.c:1:
src/atomic.h: In function ‘atomic_ptr_cas’:
src/atomic.h:128:2: error: unknown type name ‘uintptr_t’; did you mean ‘__uint128_t’?
  uintptr_t temp = (uintptr_t)oval;
  ^~~~~~~~~
  __uint128_t
src/atomic.h:128:20: error: ‘uintptr_t’ undeclared (first use in this function); did you mean ‘__uint128_t’?
  uintptr_t temp = (uintptr_t)oval;
                    ^~~~~~~~~
                    __uint128_t
src/atomic.h:128:30: error: expected ‘,’ or ‘;’ before ‘oval’
  uintptr_t temp = (uintptr_t)oval;
                              ^~~~
In file included from src/atomic.h:76:0,
                 from src/queue.h:4,
                 from src/queue.c:1:
src/atomic.h:129:62: error: expected ‘)’ before ‘nval’
  return atomic_compare_exchange_weak(aptr, &temp, (uintptr_t)nval);
                                                              ^
src/atomic.h:129:9: error: size mismatch in argument 2 of ‘__atomic_compare_exchange’
  return atomic_compare_exchange_weak(aptr, &temp, (uintptr_t)nval);
         ^
In file included from src/atomic.h:76:0,
                 from src/queue.h:4,
                 from src/service.c:2:
src/atomic.h: In function ‘atomic_ptr_init’:
src/atomic.h:113:21: error: ‘uintptr_t’ undeclared (first use in this function); did you mean ‘__uint128_t’?
  atomic_init(aptr, (uintptr_t)v);
                     ^
src/atomic.h:113:21: note: each undeclared identifier is reported only once for each function it appears in
src/atomic.h:113:31: error: expected ‘)’ before ‘v’
  atomic_init(aptr, (uintptr_t)v);
                               ^
src/atomic.h: In function ‘atomic_ptr_store’:
src/atomic.h:123:22: error: ‘uintptr_t’ undeclared (first use in this function); did you mean ‘__uint128_t’?
  atomic_store(aptr, (uintptr_t)v);
                      ^
src/atomic.h:123:32: error: expected ‘)’ before ‘v’
  atomic_store(aptr, (uintptr_t)v);
                                ^
In file included from src/queue.h:4:0,
                 from src/service.c:2:
src/atomic.h: In function ‘atomic_ptr_cas’:
src/atomic.h:128:2: error: unknown type name ‘uintptr_t’; did you mean ‘__uint128_t’?
  uintptr_t temp = (uintptr_t)oval;
  ^~~~~~~~~
  __uint128_t
src/atomic.h:128:20: error: ‘uintptr_t’ undeclared (first use in this function); did you mean ‘__uint128_t’?
  uintptr_t temp = (uintptr_t)oval;
                    ^~~~~~~~~
                    __uint128_t
src/atomic.h:128:30: error: expected ‘,’ or ‘;’ before ‘oval’
  uintptr_t temp = (uintptr_t)oval;
                              ^~~~
In file included from src/atomic.h:76:0,
                 from src/queue.h:4,
                 from src/service.c:2:
src/atomic.h:129:62: error: expected ‘)’ before ‘nval’
  return atomic_compare_exchange_weak(aptr, &temp, (uintptr_t)nval);
                                                              ^
src/atomic.h:129:9: error: size mismatch in argument 2 of ‘__atomic_compare_exchange’
  return atomic_compare_exchange_weak(aptr, &temp, (uintptr_t)nval);
         ^
In file included from src/timer.c:3:0:
src/timer.h:11:16: error: conflicting types for ‘timer_create’
 struct timer * timer_create();
                ^~~~~~~~~~~~
In file included from /usr/include/pthread.h:24:0,
                 from src/spinlock.h:43,
                 from src/timer.c:1:
/usr/include/time.h:240:12: note: previous declaration of ‘timer_create’ was here
 extern int timer_create (clockid_t __clock_id,
            ^~~~~~~~~~~~
src/timer.c:162:1: error: conflicting types for ‘timer_create’
 timer_create() {
 ^~~~~~~~~~~~
In file included from /usr/include/pthread.h:24:0,
                 from src/spinlock.h:43,
                 from src/timer.c:1:
/usr/include/time.h:240:12: note: previous declaration of ‘timer_create’ was here
 extern int timer_create (clockid_t __clock_id,
            ^~~~~~~~~~~~
src/sysapi.c: In function ‘sys_sleep’:
src/sysapi.c:13:9: error: ‘usec’ undeclared (first use in this function); did you mean ‘csec’?
  usleep(usec * 1000);
         ^~~~
         csec
src/sysapi.c:13:9: note: each undeclared identifier is reported only once for each function it appears in
Makefile:26: recipe for target 'ltask.dll' failed
make: *** [ltask.dll] Error 1

I fixed it in Linux. You can try again in WSL.

mac 下 找不到 系统文件

../../../src/sysinfo.c:15:10: fatal error: 'sys/sysinfo.h' file not found
#include <sys/sysinfo.h>

暂没有 mac 开发环境,需要有环境的人来改。

#include "unistd.h"

int
sysinfo_ncores() {
return sysconf(_SC_NPROCESSORS_ONLN);
}