ubuntu18.04下编译失败
tzw0745 opened this issue · 3 comments
tzw0745 commented
系统为Ubuntu 18.04.3 LTS
,安装了libuv0.10-dev 0.10.36-4
(apt-get install libuv-dev
)后编译失败,错误信息的最后部分摘抄如下:
In file included from netutils.h:10:0,
from lrucache.h:6,
from ipt2socks.c:3:
/usr/include/uv.h:1242:15: note: expected ‘uv_timer_cb {aka void (*)(struct uv_timer_s *, int)}’ but argument is of type ‘void (*)(uv_timer_t *) {aka void (*)(struct uv_timer_s *)}’
UV_EXTERN int uv_timer_start(uv_timer_t* handle,
^~~~~~~~~~~~~~
In file included from lrucache.h:6:0,
from ipt2socks.c:3:
netutils.h:149:39: error: incompatible type for argument 1 of ‘uv_strerror’
#define errstring(errnum) uv_strerror(-(errnum))
^
logutils.h:24:19: note: in expansion of macro ‘errstring’
##__VA_ARGS__); \
^~~~~~~~~~~
ipt2socks.c:1243:9: note: in expansion of macro ‘LOGERR’
LOGERR("[udp_client_recv_cb] failed to send data to local client: (%d) %s", errno, errstring(errno));
^~~~~~
In file included from netutils.h:10:0,
from lrucache.h:6,
from ipt2socks.c:3:
/usr/include/uv.h:450:23: note: expected ‘uv_err_t {aka struct uv_err_s}’ but argument is of type ‘int’
UV_EXTERN const char* uv_strerror(uv_err_t err);
^~~~~~~~~~~
Makefile:26: recipe for target 'ipt2socks.o' failed
make: *** [ipt2socks.o] Error 1
重新安装了libuv1-dev 1.18.0-3
(apt-get install libuv1-dev
)后再次编译失败,错误信息如下:
gcc -std=c99 -Wall -Wextra -O3 -pthread -c ipt2socks.c -o ipt2socks.o
ipt2socks.c: In function ‘udp_socks5_resp_read_cb’:
ipt2socks.c:1061:13: warning: implicit declaration of function ‘uv_udp_connect’; did you mean ‘uv_tcp_connect’? [-Wimplicit-function-declaration]
nread = uv_udp_connect(udp_handle, (void *)&server_skaddr);
^~~~~~~~~~~~~~
uv_tcp_connect
gcc -std=c99 -Wall -Wextra -O3 -pthread -c lrucache.c -o lrucache.o
gcc -std=c99 -Wall -Wextra -O3 -pthread -c netutils.c -o netutils.o
gcc -std=c99 -Wall -Wextra -O3 -pthread -s -o ipt2socks ipt2socks.o lrucache.o netutils.o -luv
ipt2socks.o: In function `udp_socks5_resp_read_cb':
ipt2socks.c:(.text+0x4be9): undefined reference to `uv_udp_connect'
ipt2socks.c:(.text+0x4e26): undefined reference to `uv_udp_connect'
collect2: error: ld returned 1 exit status
Makefile:23: recipe for target 'ipt2socks' failed
make: *** [ipt2socks] Error 1
zfl9 commented
# 进入某个目录
cd /opt
# 获取 libuv 源码包
libuv_version="1.32.0" # 定义 libuv 版本号
wget https://github.com/libuv/libuv/archive/v$libuv_version.tar.gz -Olibuv-$libuv_version.tar.gz
tar xvf libuv-$libuv_version.tar.gz
# 进入源码目录,编译
cd libuv-$libuv_version
./autogen.sh
./configure --prefix=/opt/libuv --enable-shared=no --enable-static=yes CC="gcc -O3"
make && sudo make install
cd ..
# 获取 ipt2socks 源码
git clone https://github.com/zfl9/ipt2socks
# 进入源码目录,编译
cd ipt2socks
make INCLUDES="-I/opt/libuv/include" LDFLAGS="-L/opt/libuv/lib" && sudo make install
zfl9 commented
ipt2socks.c:(.text+0x4e26): undefined reference to `uv_udp_connect'
版本过老,请参照readme,自己编译libuv。
tzw0745 commented
好的,非常感谢