0

In my Makefile I have this to crosscompile for my rpi0w, rpi02w and rpi4:

release_files: clean
    @mkdir build
    @echo building for linux/amd64 ...
    @CGO_ENABLED=1 GOARCH=amd64 GOOS=linux $(MAKE) build
    @openssl dgst -sha256 "build/bettercap" > "build/bettercap-amd64.sha256"
    @zip -j "build/bettercap-$(VERSION)-amd64.zip" build/bettercap build/bettercap-amd64.sha256 > /dev/null
    @rm -rf build/bettercap build/bettercap-amd64.sha256
    @echo building for linux/armhf ...
    @CGO_ENABLED=1 CC=arm-linux-gnueabihf-gcc GOARM=6 GOARCH=arm GOOS=linux $(MAKE) build
    @openssl dgst -sha256 "build/bettercap" > "build/bettercap-armhf.sha256"
    @zip -j "build/bettercap-$(VERSION)-armhf.zip" build/bettercap build/bettercap-armhf.sha256 > /dev/null
    @rm -rf build/pwngrid build/bettercap-armhf.sha256
    @echo building for linux/aarch64 ...
    @CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc GOARCH=arm64 GOOS=linux $(MAKE) build
    @openssl dgst -sha256 "build/bettercap" > "build/bettercap-aarch64.sha256"
    @zip -j "build/bettercap-$(VERSION)-aarch64.zip" build/bettercap build/bettercap-aarch64.sha256 > /dev/null
    @rm -rf build/pwngrid build/bettercap-aarch64.sha256
    @ls -la build

The amd64 building part works, as I'm on an AMD64 laptop. But the armhf and aarch64 parts fail. I have the cross-compilers (arm-linux-gnueabihf and aarch64-linux-gnu) installed. But I get the following errors. But I cannot find any way to compiling them or installing them accordingly.

/usr/lib/gcc-cross/arm-linux-gnueabihf/11/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lnetfilter_queue: No such file or directory
/usr/lib/gcc-cross/arm-linux-gnueabihf/11/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lnfnetlink: No such file or directory

Any help would be greatly appreciated. I'm most likely to be searching for the wrong keywords on Google.

1 Answer 1

0

The errors you're facing with -lnetfilter_queue and -lnfnetlink suggest missing libraries for your cross-compilation targets. Here are some potential solutions:

1. Installing the libraries:

  • Make sure the libraries libnetfilter_queue and libnfnetlink are installed for your target architecture, likely in a package named libnfnetlink-dev or similar. On Debian-based systems, you can use sudo apt install libnfnetlink-dev.
  • Check the output of pkg-config --list-all | grep netfilter to see available libraries and their paths.
  • Verify the library search path used by your cross-compiler. The error message seems to suggest a mismatch between the compiler and linker paths. Look for options like -I and -L passed to the compiler and linker in your Makefile or cross-compilation toolchain configuration.

2. Specifying library paths:

  • Explicitly tell the linker where to find the libraries. Use the -L flag with the directory containing the libnetfilter_queue.so and libnfnetlink.so files for your target architecture.
  • Modify your Makefile to pass the correct library paths using LDFLAGS for the armhf and aarch64 builds.

3. Alternative libraries:

  • Consider using alternatives like libnetfilter_conntrack which might be available on your target system and achieve similar functionality.

4. Troubleshooting and searching:

  • Double-check the spelling of the library names in your Makefile.
  • Search for the specific error messages you're getting online, focusing on your cross-compilation setup and target architecture.
  • Use tools like nm to analyze the compiled binary and identify missing symbols to pinpoint the specific library dependencies.

Remember to adjust the commands and package names based on your specific Linux distribution and cross-compilation environment. For better search results, include details like your Linux distro, cross-compiler versions, and exact error messages when searching online.

I hope this helps! Feel free to share any additional information or specific error messages you encounter for further assistance.

3
  • Thank you for this thorough answer. I have been trying to add armhf and arm64 architecture to my AMD64 laptop. sudo dpkg --add-architecture armhf But for some reason the apt sources keep getting ignored. So I cannot install the packages that way.I'll try some more, perhaps. And now I know why, there are no armhf/arm64 jammy packages. Dec 18, 2023 at 6:49
  • sudo apt-get install libnetfilter-queue-dev:armhf libnetfilter-queue-dev:armhf Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: libnfnetlink-dev:armhf Suggested packages: libnetfilter-queue-doc:armhf The following packages will be REMOVED: libnetfilter-queue-dev libnfnetlink-dev The following NEW packages will be installed: libnetfilter-queue-dev:armhf libnfnetlink-dev:armhf Dec 18, 2023 at 11:36
  • It seems libnfnetlink-dev and libnetfilter-queue-dev are not quite cross compatible. Dec 18, 2023 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.