You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为armv7l架构交叉编译tsocks失败求助

交叉编译tsocks到armv7l架构失败问题求助

我正尝试为armv7l架构交叉编译tsocks,已安装arm-linux-gnueabi包,且编译简单的hello world程序可正常运行。但tsocks的./configure无法使用arm-linux-gnueabi-*系列交叉编译器,最终编译产物仍为原生x86_64架构。

执行configure命令的输出

@ubuntu:~/tmp/tsocks-1.8$ ./configure --build x86_64-pc-linux-gnu --host=arm-linux-gnueabi
loading cache ./config.cache
checking host system type... arm-unknown-linux-gnueabi
checking for gcc... (cached) gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for a BSD compatible install... (cached) /usr/bin/install -c
checking whether ln -s works... (cached) yes
checking if the C compiler accepts -Wall... yes
checking how to run the C preprocessor... (cached) gcc -E
checking for ANSI C header files... (cached) yes
checking for dlfcn.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for arpa/inet.h... (cached) yes
checking for fcntl.h... (cached) yes
checking for sys/poll.h... (cached) yes
checking for unistd.h... (cached) yes
checking for strcspn... (cached) yes
checking for strdup... (cached) yes
checking for strerror... (cached) yes
checking for strspn... (cached) yes
checking for strtol... (cached) yes
checking for connect in -lc... (cached) yes
checking for socket... (cached) yes
checking for inet_aton... (cached) yes
checking for gethostbyname... (cached) yes
checking for dlsym in -ldl... (cached) yes
checking for RTLD_NEXT from dlfcn.h... no
checking for RTLD_NEXT from dlfcn.h with _GNU_SOURCE... yes
checking for correct select prototype... select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
checking for correct connect prototype... connect(int __fd, const struct sockaddr * __addr, socklen_t __len)
checking for correct close prototype... close(int fd)
checking for correct poll prototype... poll(struct pollfd *ufds, unsigned long nfds, int timeout)
creating ./config.status
creating Makefile
creating config.h
config.h is unchanged

执行make命令的输出

@ubuntu:~/tmp/tsocks-1.8$ make
gcc -fPIC  -g -O2 -Wall -I. -c  tsocks.c -o tsocks.o
tsocks.c: In function ‘connect’:
tsocks.c:215:41: warning: pointer targets in passing argument 5 of ‘getsockopt’ differ in signedness [-Wpointer-sign]
  215 |                    (void *) &sock_type, &sock_type_len);
      |                                         ^~~~~~~~~~~~~~
      |                                         |
      |                                         int *
In file included from tsocks.c:39:
/usr/include/x86_64-linux-gnu/sys/socket.h:257:46: note: expected ‘socklen_t * restrict’ {aka ‘unsigned int * restrict’} but argument is of type ‘int *’
  257 |                        socklen_t *__restrict __optlen) __THROW;
      |                        ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
tsocks.c:271:62: warning: pointer targets in passing argument 3 of ‘getpeername’ differ in signedness [-Wpointer-sign]
  271 |    if (!getpeername(__fd, (struct sockaddr *) &peer_address, &namelen)) {
      |                                                              ^~~~~~~~
      |                                                              |
      |                                                              int *
In file included from tsocks.c:39:
/usr/include/x86_64-linux-gnu/sys/socket.h:131:47: note: expected ‘socklen_t * restrict’ {aka ‘unsigned int * restrict’} but argument is of type ‘int *’
  131 |                         socklen_t *__restrict __len) __THROW;
      |                         ~~~~~~~~~~~~~~~~~~~~~~^~~~~
tsocks.c: In function ‘select’:
tsocks.c:343:8: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
  343 |    int rc = 0;
      |        ^~
tsocks.c: In function ‘poll’:
tsocks.c:526:8: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
  526 |    int rc = 0, i;
      |        ^~
gcc -fPIC  -g -O2 -Wall -I. -c  common.c -o common.o
gcc -fPIC  -g -O2 -Wall -I. -c  parser.c -o parser.o
parser.c: In function ‘handle_path’:
parser.c:210:22: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  210 |                 if (((int) (newserver = (struct serverent *) malloc(sizeof(struct serverent)))) == -1)
      |                      ^
gcc -fPIC  -g -O2 -Wall -I. -nostdlib -shared -o libtsocks.so.1.8 tsocks.o common.o parser.o  -ldl  -lc
ln -sf libtsocks.so.1.8 libtsocks.so
gcc -fPIC  -g -O2 -Wall -I. -static -o saveme saveme.c
gcc -fPIC  -g -O2 -Wall -I. -o inspectsocks inspectsocks.c common.o -lc 
gcc -fPIC  -g -O2 -Wall -I. -o validateconf validateconf.c common.o parser.o -lc

检查编译产物架构的输出

@ubuntu:~/tmp/tsocks-1.8$ file libtsocks.so.1.8
libtsocks.so.1.8: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=e1928585546b975b439d280bba97f0c85ed2d89c, with debug_info, not stripped

现求助如何让tsocks的configure正确使用arm-linux-gnueabi交叉编译器,生成armv7l架构的编译产物。


内容的提问来源于stack exchange,提问作者Adrian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 17:14:55