udp2raw icon indicating copy to clipboard operation
udp2raw copied to clipboard

build on FreeBSD 12

Open amrahmades opened this issue 4 years ago • 6 comments

English Only (except for bug reporting).

Hello, i am trying to build it on FreeBSD 12.2, i had the following error

gmake freebsd echo "const char *gitversion = "b8e9095135ec898cc5826f0c216dd3c120b5cafc";" > git_version.h g++ -o udp2raw_freebsd -I. main.cpp lib/md5.cpp lib/pbkdf2-sha1.cpp lib/pbkdf2-sha256.cpp encrypt.cpp log.cpp network.cpp common.cpp connection.cpp misc.cpp fd_manager.cpp client.cpp server.cpp -lpthread lib/aes_faster_c/aes.cpp lib/aes_faster_c/wrapper.cpp my_ev.cpp -isystem libev "-lpcap" -std=c++11 -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers -lrt -ggdb -static -O2 In file included from main.cpp:1: common.h:52:10: fatal error: linux/filter.h: No such file or directory 52 | #include <linux/filter.h> | ^~~~~~~~~~~~~~~~ compilation terminated. In file included from encrypt.h:8, from encrypt.cpp:9: common.h:52:10: fatal error: linux/filter.h: No such file or directory 52 | #include <linux/filter.h> | ^~~~~~~~~~~~~~~~ compilation terminated. In file included from log.h:6, from log.cpp:1: common.h:52:10: fatal error: linux/filter.h: No such file or directory 52 | #include <linux/filter.h> | ^~~~~~~~~~~~~~~~ compilation terminated. In file included from network.cpp:7: common.h:52:10: fatal error: linux/filter.h: No such file or directory 52 | #include <linux/filter.h> | ^~~~~~~~~~~~~~~~ compilation terminated. In file included from common.cpp:8: common.h:52:10: fatal error: linux/filter.h: No such file or directory 52 | #include <linux/filter.h> | ^~~~~~~~~~~~~~~~ compilation terminated. In file included from connection.h:14, from connection.cpp:8: common.h:52:10: fatal error: linux/filter.h: No such file or directory 52 | #include <linux/filter.h> | ^~~~~~~~~~~~~~~~ compilation terminated. In file included from misc.cpp:8: common.h:52:10: fatal error: linux/filter.h: No such file or directory 52 | #include <linux/filter.h> | ^~~~~~~~~~~~~~~~ compilation terminated. In file included from fd_manager.h:11, from fd_manager.cpp:9: common.h:52:10: fatal error: linux/filter.h: No such file or directory 52 | #include <linux/filter.h> | ^~~~~~~~~~~~~~~~ compilation terminated. In file included from client.cpp:1: common.h:52:10: fatal error: linux/filter.h: No such file or directory 52 | #include <linux/filter.h> | ^~~~~~~~~~~~~~~~ compilation terminated. In file included from server.cpp:10: common.h:52:10: fatal error: linux/filter.h: No such file or directory 52 | #include <linux/filter.h> | ^~~~~~~~~~~~~~~~ compilation terminated. gmake: *** [makefile:106: freebsd] Error 1

i spent too much time looking for linux/filter with no luck .

amrahmades avatar Feb 16 '21 09:02 amrahmades

Looks like it's my bad, I broke the BSD compile in some commit. It might solves the problem, if you change this line in makefile:

freebsd:git_version
	${cc_local}   -o ${NAME}_$@        -I. ${SOURCES} ${PCAP} ${FLAGS} -lrt -ggdb -static -O2

to

freebsd:git_version
	${cc_local}   -o ${NAME}_$@        -I. ${SOURCES} ${PCAP} ${FLAGS} -lrt -ggdb -static -O2 ${MP}

At the moment I do not have a BSD machine in hand to test the change. Could you plz try if it works?

wangyu- avatar Feb 17 '21 08:02 wangyu-

thanks ,

the previous error gone , but it's seems we have a link or reference issue

gmake freebsd echo "const char gitversion = "b8e9095135ec898cc5826f0c216dd3c120b5cafc";" > git_version.h g++ -o udp2raw_freebsd -I. main.cpp lib/md5.cpp lib/pbkdf2-sha1.cpp lib/pbkdf2-sha256.cpp encrypt.cpp log.cpp network.cpp common.cpp connection.cpp misc.cpp fd_manager.cpp client.cpp server.cpp -lpthread lib/aes_faster_c/aes.cpp lib/aes_faster_c/wrapper.cpp my_ev.cpp -isystem libev "-lpcap" -std=c++11 -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers -lrt -ggdb -static -O2 "-DUDP2RAW_MP" In file included from /usr/include/machine/endian.h:6, from /usr/include/sys/types.h:46, from /usr/include/unistd.h:39, from common.h:18, from network.cpp:7: network.cpp: In function 'int send_raw_ip(raw_info_t&, const char, int)': network.cpp:1357:36: warning: operation on 'g_ip_id_counter' may be undefined [-Wsequence-point] 1357 | iph->id = htons (g_ip_id_counter++); //Id of this packet | ^ network.cpp:1357:36: warning: operation on 'g_ip_id_counter' may be undefined [-Wsequence-point] network.cpp:1361:36: warning: operation on 'g_ip_id_counter' may be undefined [-Wsequence-point] 1361 | iph->id = htons (g_ip_id_counter++); //Id of this packet | ^ network.cpp:1361:36: warning: operation on 'g_ip_id_counter' may be undefined [-Wsequence-point] common.cpp: In function 'std::vector<std::__cxx11::basic_string > parse_conf_line(const string&)': common.cpp:1183:8: warning: 'char* strcpy(char*, const char*)' source argument is the same as destination [-Wrestrict] 1183 | strcpy(buf,(char *)s.c_str()); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/local/bin/ld: /usr/lib/libpcap.a(pcap-rdmasniff.o): in function rdmasniff_create': /usr/src/contrib/libpcap/pcap-rdmasniff.c:370: undefined reference to ibv_get_device_list' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:405: undefined reference to ibv_free_device_list' /usr/local/bin/ld: /usr/lib/libpcap.a(pcap-rdmasniff.o): in function rdmasniff_activate': /usr/src/contrib/libpcap/pcap-rdmasniff.c:198: undefined reference to ibv_open_device' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:205: undefined reference to ibv_alloc_pd' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:212: undefined reference to ibv_create_comp_channel' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:219: undefined reference to ibv_create_cq' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:234: undefined reference to ibv_create_qp' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:244: undefined reference to ibv_modify_qp' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:252: undefined reference to ibv_modify_qp' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:284: undefined reference to ibv_reg_mr' /usr/local/bin/ld: /usr/lib/libpcap.a(pcap-rdmasniff.o): in function ___ibv_query_port': /usr/obj/usr/src/amd64.amd64/tmp/usr/include/infiniband/verbs.h:1662: undefined reference to ibv_query_port' /usr/local/bin/ld: /usr/lib/libpcap.a(pcap-rdmasniff.o): in function rdmasniff_activate': /usr/src/contrib/libpcap/pcap-rdmasniff.c:322: undefined reference to ibv_dereg_mr' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:330: undefined reference to ibv_destroy_qp' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:334: undefined reference to ibv_destroy_cq' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:338: undefined reference to ibv_destroy_comp_channel' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:342: undefined reference to ibv_dealloc_pd' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:346: undefined reference to ibv_close_device' /usr/local/bin/ld: /usr/lib/libpcap.a(pcap-rdmasniff.o): in function rdmasniff_findalldevs': /usr/src/contrib/libpcap/pcap-rdmasniff.c:417: undefined reference to ibv_get_device_list' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:434: undefined reference to ibv_free_device_list' /usr/local/bin/ld: /usr/lib/libpcap.a(pcap-rdmasniff.o): in function rdmasniff_read': /usr/src/contrib/libpcap/pcap-rdmasniff.c:148: undefined reference to ibv_wc_status_str' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:125: undefined reference to ibv_get_cq_event' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:134: undefined reference to ibv_ack_cq_events' /usr/local/bin/ld: /usr/lib/libpcap.a(pcap-rdmasniff.o): in function rdmasniff_cleanup': /usr/src/contrib/libpcap/pcap-rdmasniff.c:82: undefined reference to ibv_dereg_mr' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:84: undefined reference to ibv_destroy_qp' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:85: undefined reference to ibv_destroy_cq' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:86: undefined reference to ibv_dealloc_pd' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:87: undefined reference to ibv_destroy_comp_channel' /usr/local/bin/ld: /usr/src/contrib/libpcap/pcap-rdmasniff.c:88: undefined reference to `ibv_close_device' collect2: error: ld returned 1 exit status gmake: *** [makefile:109: freebsd] Error 1

amrahmades avatar Feb 17 '21 11:02 amrahmades

try to remove -static:

freebsd:git_version
	${cc_local}   -o ${NAME}_$@        -I. ${SOURCES} ${PCAP} ${FLAGS} -lrt -ggdb -O2 ${MP}

wangyu- avatar Feb 17 '21 19:02 wangyu-

Thanks, I have an executable file now !!

I'm going to test and give you feedback.

amrahmades avatar Feb 17 '21 19:02 amrahmades

Do not remove -static, without it you won't have a static binary. Add -libverbs and then it will compile ok. Then you could use static binary on older systems without libraries (sometimes it's very important with older pfsense installs).

${cc_local}   -o ${NAME}_$@        -I. ${SOURCES} ${PCAP} ${FLAGS} -lrt -ggdb -static -libverbs -O2 ${MP}

burbilog avatar Apr 13 '21 15:04 burbilog

Do not remove -static, without it you won't have a static binary. Add -libverbs and then it will compile ok. Then you could use static binary on older systems without libraries (sometimes it's very important with older pfsense installs).

${cc_local}   -o ${NAME}_$@        -I. ${SOURCES} ${PCAP} ${FLAGS} -lrt -ggdb -static -libverbs -O2 ${MP}

Thank you very much for this. Can somebod please modify the makefile for freebsd to include this? I was searching a lot to find this very useful post.

I can confirm that the compile works OK with this modification on 13.2-RELEASE-p1 FreeBSD 64bit.

mdasyg avatar Sep 04 '23 13:09 mdasyg