Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build for mips64 #78

Open
soxrok2212 opened this issue Aug 25, 2023 · 2 comments
Open

Build for mips64 #78

soxrok2212 opened this issue Aug 25, 2023 · 2 comments

Comments

@soxrok2212
Copy link

soxrok2212 commented Aug 25, 2023

Hi!

I'm trying make a statically linked mips64 binary. I've built libpcap and libnet with mips64-linux-gnuabi64- cross compiler just fine and specified the paths, as well as added the -static flag. 2 problems arise.

  1. If I don't specify the includes path, the pcap version check fails:
$ CFLAGS="-static -I../libpcap/include" CC=mips64-linux-gnuabi64-gcc CXX=mips64-linux-gnuabi64-g++ ./configure --host=mips64-linux-gnuabi64 --with-pcap-includes=../libpcap --with-libnet-includes=../libnet
checking build system type... aarch64-unknown-linux-gnu
checking host system type... mips64-unknown-linux-gnuabi64
checking target system type... mips64-unknown-linux-gnuabi64
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for mips64-linux-gnuabi64-strip... mips64-linux-gnuabi64-strip
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for mips64-linux-gnuabi64-gcc... mips64-linux-gnuabi64-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether mips64-linux-gnuabi64-gcc accepts -g... yes
checking for mips64-linux-gnuabi64-gcc option to enable C11 features... none needed
checking whether mips64-linux-gnuabi64-gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of mips64-linux-gnuabi64-gcc... none
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for sys/time.h... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for makedepend... no
checking if unaligned accesses fail... yes
checking for main in -lsocket... no
checking for main in -lresolv... yes
checking for main in -lnsl... no
checking for main in -lrt... yes
checking for a complete set of pcap headers... found ../libpcap
checking for pcap_lib_version in -lpcap... no
checking for pcap_dump_flush in -lpcap... no
checking for BPF device sending support... configure: error: in `/home/soxrok2212/mips64/yersinia':
configure: error: cannot run test program while cross compiling
See `config.log' for more details
  1. If I specify it the includes, it seems to fail during testing? or something with Berkeley Packet Filters, understandable since its being building on an arm64 system.
$ LDFLAGS=-L../libpcap  CFLAGS="-static -I../libpcap/include" CC=mips64-linux-gnuabi64-gcc CXX=mips64-linux-gnuabi64-g++ ./configure --host=mips64-linux-gnuabi64 --with-pcap-includes=../libpcap --with-libnet-includes=../libnet
checking build system type... aarch64-unknown-linux-gnu
checking host system type... mips64-unknown-linux-gnuabi64
checking target system type... mips64-unknown-linux-gnuabi64
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for mips64-linux-gnuabi64-strip... mips64-linux-gnuabi64-strip
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for mips64-linux-gnuabi64-gcc... mips64-linux-gnuabi64-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether mips64-linux-gnuabi64-gcc accepts -g... yes
checking for mips64-linux-gnuabi64-gcc option to enable C11 features... none needed
checking whether mips64-linux-gnuabi64-gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of mips64-linux-gnuabi64-gcc... none
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for sys/time.h... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for makedepend... no
checking if unaligned accesses fail... yes
checking for main in -lsocket... no
checking for main in -lresolv... yes
checking for main in -lnsl... no
checking for main in -lrt... yes
checking for a complete set of pcap headers... found ../libpcap
checking for pcap_lib_version in -lpcap... yes
checking for pcap_dump_flush in -lpcap... yes
checking for BPF device sending support... configure: error: in `/home/soxrok2212/mips64/yersinia':
configure: error: cannot run test program while cross compiling
See `config.log' for more details

Any ideas?

@soxrok2212
Copy link
Author

soxrok2212 commented Aug 28, 2023

I did get this to work, though it was a bit convoluted. In the end, my build command was:
CC=mips64-linux-gnuabi64-gcc ./configure --host=mips64-linux-gnuabi64 --with-pcap-includes=/path/to/compiled/libpcap --with-libnet-includes=/path/to/compiled/libnet/include --disable-gtk --disable-admin --with-ncurses=/path/to/compiled/ncurses

Some caveats:

  • libpcap does not have a proper include directory when built from source, so the --with-pcap-includes points to the libpcap root directory.
  • libnet puts the compiled shared objects in src/.libs/, the contents of that directory should be copied into the libnet root directory
  • libnet version >= 1.1.2 check always seems to fail. In configure, I changed the have_libnet=no to have_libnet=yes line below checking if libnet is at least version 1.1.2, my exact line number may be off as I put some extra debug prints but for me, its around line 5482.
  • setting the environment var CFLAGS=-static seemed to be ignored; I had to add it to the Makefile in src after configure completed

And then, it successfully built a statically linked binary that worked. So if there are any authors still working on this lovely project, there's a little bit of work needed to make cross compiling work effectively. I'm not very familiar with autoconf, else I'd make a PR of my own. Perhaps I'll try when I get some more time.

@aoshiken
Copy link
Collaborator

Good work @soxrok2212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants