wangyu- / udp2raw-multiplatform

multi-platform(cross-platform) version of udp2raw-tunnel, which supports Windows/Mac/BSD natively. Client-Only at the moment.
MIT License
638 stars 145 forks source link

FreeBSD 12 下无法编译,collect2: error: ld returned 1 exit status #24

Open bao3 opened 5 years ago

bao3 commented 5 years ago

我按照说明,安装了 libnet/libpcap ,以下是我安装的包:

tinyvpn /root/tmp/udp2raw-multiplatform-20190407.0 >pkg info
binutils-2.32,1                GNU binary tools
gcc-8_3                        Meta-port for the default version of the GNU Compiler Collection
gcc8-8.3.0_1                   GNU Compiler Collection 8
gettext-runtime-0.19.8.1_2     GNU gettext runtime libraries and programs
gmp-6.1.2_1                    Free library for arbitrary precision arithmetic
indexinfo-0.3.1                Utility to regenerate the GNU info page index
libedit-3.1.20181209_2,1       Command line editor library
libffi-3.2.1_3                 Foreign Function Interface
libnet-1.1.6_5,1               C library for creating IP packets
libpcap-1.9.0                  Ubiquitous network traffic capture library
libxml2-2.9.8                  XML parser library for GNOME
llvm-80                        Meta-port for the default version of the LLVM Toolchain
llvm80-8.0.0                   LLVM and Clang
mpc-1.1.0_2                    Library of complex numbers with arbitrarily high precision
mpfr-4.0.2                     Library for multiple-precision floating-point computations
perl5-5.28.1_1                 Practical Extraction and Report Language
pkg-1.10.5_5                   Package manager
python27-2.7.16                Interpreted object-oriented programming language
readline-7.0.5                 Library for editing command lines as they are typed

使用的是 20190407.0 的版本 ,make freebsd后得到如下错误信息:


/usr/local/bin/ld: /usr/local/lib/libpcap.a(pcap-rdmasniff.o): in function `rdmasniff_create':
pcap-rdmasniff.c:(.text+0x27): undefined reference to `ibv_get_device_list'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0xe8): undefined reference to `ibv_free_device_list'
/usr/local/bin/ld: /usr/local/lib/libpcap.a(pcap-rdmasniff.o): in function `rdmasniff_activate':
pcap-rdmasniff.c:(.text+0x170): undefined reference to `ibv_open_device'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x185): undefined reference to `ibv_alloc_pd'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x19b): undefined reference to `ibv_create_comp_channel'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x1be): undefined reference to `ibv_create_cq'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x235): undefined reference to `ibv_create_qp'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x2ac): undefined reference to `ibv_modify_qp'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x3b7): undefined reference to `ibv_modify_qp'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x48a): undefined reference to `ibv_reg_mr'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x520): undefined reference to `ibv_query_port'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x629): undefined reference to `ibv_dereg_mr'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x663): undefined reference to `ibv_destroy_qp'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x671): undefined reference to `ibv_destroy_cq'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x67f): undefined reference to `ibv_destroy_comp_channel'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x68d): undefined reference to `ibv_dealloc_pd'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x69b): undefined reference to `ibv_close_device'
/usr/local/bin/ld: /usr/local/lib/libpcap.a(pcap-rdmasniff.o): in function `rdmasniff_findalldevs':
pcap-rdmasniff.c:(.text+0x739): undefined reference to `ibv_get_device_list'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x79a): undefined reference to `ibv_free_device_list'
/usr/local/bin/ld: /usr/local/lib/libpcap.a(pcap-rdmasniff.o): in function `rdmasniff_read':
pcap-rdmasniff.c:(.text+0x7eb): undefined reference to `ibv_get_cq_event'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x801): undefined reference to `ibv_ack_cq_events'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x844): undefined reference to `ibv_wc_status_str'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0x9e0): undefined reference to `ibv_get_cq_event'
/usr/local/bin/ld: /usr/local/lib/libpcap.a(pcap-rdmasniff.o): in function `rdmasniff_cleanup':
pcap-rdmasniff.c:(.text+0xa43): undefined reference to `ibv_dereg_mr'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0xa73): undefined reference to `ibv_destroy_qp'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0xa7c): undefined reference to `ibv_destroy_cq'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0xa85): undefined reference to `ibv_dealloc_pd'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0xa8e): undefined reference to `ibv_destroy_comp_channel'
/usr/local/bin/ld: pcap-rdmasniff.c:(.text+0xa97): undefined reference to `ibv_close_device'
collect2: error: ld returned 1 exit status
*** Error code 1

Stop.
make: stopped in /root/tmp/udp2raw-multiplatform-20190407.0
`
ghost commented 5 years ago

缺静态库,编辑makefile

我魔改成这样了

-I. ${SOURCES} -lpcap -lrdmacm -libverbs -lvgl -lvmmapi ${LIBNET} $(FLAGS) -lrt -ggdb -static -O2 -L/usr/lib

Mixcro commented 5 years ago

一样的问题,感谢BillPose的解决方案,成了。