/usr/bin/ld: /usr/include/c++/8/bits/stl_construct.h:107: undefined reference to *** - linux

Running into errors when compiling Google's BoringSSL for NGINX QUIC on my Raspberry Pi 4B, with Raspberry Pi OS, aka Raspbian buster running on it.
The commands I used to compile
As what Google's document says, I used these commands:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
I've also tried to run cmake without passing -DCMAKE_BUILD_TYPE=Release.
Error output
Here's part of the error message. I'm not showing the entire output since it's too long (there are 352 lines). Tell me if the entire output is needed to solve this issue.
[ 75%] Linking CXX executable crypto_test
/usr/bin/ld: CMakeFiles/crypto_test.dir/abi_self_test.cc.o: in function `ABITest_SanityCheck_Test::TestBody()':
/usr/include/c++/8/bits/unique_ptr.h:81: undefined reference to `abi_test_trampoline'
/usr/bin/ld: CMakeFiles/crypto_test.dir/abi_self_test.cc.o: in function `ABITest_ARM_Test::TestBody()':
/usr/include/c++/8/bits/stl_construct.h:107: undefined reference to `abi_test_clobber_r4'
/usr/bin/ld: /usr/include/c++/8/bits/stl_construct.h:107: undefined reference to `abi_test_trampoline'
/usr/bin/ld: /usr/include/c++/8/bits/stl_construct.h:107: undefined reference to `abi_test_clobber_r0'
/usr/bin/ld: /usr/include/c++/8/bits/stl_construct.h:107: undefined reference to `abi_test_clobber_r1'
/usr/bin/ld: /usr/include/c++/8/bits/stl_construct.h:107: undefined reference to `abi_test_clobber_r2'
......
Additional information
cmake version 3.16.3
GNU Make 4.2.1
$ uname -a
Linux Kaibins-RPi 5.10.52-v8+ #1439 SMP PREEMPT Thu Jul 22 15:43:49 BST 2021 aarch64 GNU/Linux
Searched Google but I can't find any similar cases. I need help. Thanks so much.
This issue can also be found in Chromium bug tracker:https://crbug.com/boringssl/422. You can find full error output in the attachment there.

There is a boringssl package for OpenWrt which supports BCM2711 boards (the one the Raspberry Pi 4B is using). There is even a draft PR to package nginx with QUIC support. So, in principal, BoringSSL and nginx-quic work on this architecture. The BoringSSL version used in OpenWrt is from June 2021.
I have also compiled BoringSSL on Raspberry Pi OS without issues. These are the steps I documented for compiling on Debian and, from my memory, the same worked on Raspberry Pi OS:
sudo apt install cmake libpcre3-dev golang mercurial
git clone https://boringssl.googlesource.com/boringssl && cd boringssl
mkdir build && cd build
cmake ..
make -j16
cd ../..
hg clone -b quic https://hg.nginx.org/nginx-quic && cd nginx-quic
./auto/configure --with-debug --with-http_v3_module --with-cc-opt="-I../boringssl/include" --with-ld-opt="-L../boringssl/build/ssl -L../boringssl/build/crypto"
make -j16
sudo cp objs/nginx /usr/bin/nginx-quic
I can try to verify this again with a newer version if I find some time.

Related

Linker error when cross compiling for raspberry pi

I try to cross-compile a simple rust program with sqlite on Linux for raspberry pi:
Cargo.toml
...
[dependencies]
rusqlite = { version = "0.26.3", features = ["bundled"] }
.cargo/config
[target.arm-unknown-linux-gnueabihf]
linker = "/opt/crosspi/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc"
When trying to build with cargo build --release --target=arm-unknown-linux-gnueabihf rust bails out with a linker error which basically says:
error: linking with `/opt/crosspi/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc` failed: exit status: 1
...
= note: /home/hannenz/pidev/projects/kiddyblaster/webui-rust/target/arm-unknown-linux-gnueabihf/release/deps/liblibsqlite3_sys-950993cbbcc1e3eb.rlib(sqlite3.o):(.data.rel.aSyscall+0x58): undefined reference to `fcntl64'
collect2: error: ld returned 1 exit status
(The ... is the full gcc command line, i can post the whole output if relevant)
Without rusqlite cross-compiling works and compiling for the host target is working as well. I also tried the sqlite crate instead of rusqlite, but that produces the exact same linker error.
Would be glad if someone could point me in the right direction what's goiong wrong here.
Cross compiling can be a bit tricky, luckily the cross crate (https://github.com/cross-rs/cross) makes it simple. Follow these steps:
Install cargo cross: cargo install cross
Create a file called Cross.toml in the root directory (where Cargo.toml is) with this content
[target.aarch64-unknown-linux-gnu]
image = "my-custom-cross"
Create a Dockerfile with this content
FROM rustembedded/cross:aarch64-unknown-linux-gnu
RUN dpkg --add-architecture arm64 && \
apt-get update && \
apt-get install --assume-yes libsqlite3-dev:arm64
Build the docker container: docker buildx build --platform linux/arm64 -t my-custom-cross --load .
Build your program: cross build --target aarch64-unknown-linux-gnu --release
Now you have your binary compiled at target/aarch64-unknown-linux-gnu/release directory
A bit of explanation
The project cross-rs prepared all the environment and put it in a docker container. We created our own container based on this (FROM rustembedded/cross:aarch64-unknown-linux-gnu) and we added the extra libraries we need, in this case the dev sqlite3 (apt-get install --assume-yes libsqlite3-dev:arm64).
Once our docker container is ready, we configured cross to use this container by using the file Cross.toml.
Depending on your raspberry and the operating system you use in your raspberry, you may need to use other arquitecture. In this case just change aarch64 by yours. In my case I'm using rpi3 64 bit. In case you are using 32 bit or an older board, try something like arm-unknown-linux-gnueabihf or go to the "Supported targets" section in the cross documentation https://github.com/cross-rs/cross.
Dont forget to configure Cross.toml and the Dockerfile to use your target architecture!

Aseprite ninja build error "cannot find -lSKIA_OPENGL_LIBRARY-NOTFOUND"

While trying to build Aseprite on Debian 10 (amd64) virtualbox VM, after building Skia, the ninja aseprite command returns the error:
/usr/bin/ld: cannot find -lSKIA_OPENGL_LIBRARY-NOTFOUND
[1/1] Linking CXX executable bin/aseprite
FAILED: bin/aseprite
: && /usr/bin/c++ -Wall -Wno-switch -O2 -g -DNDEBUG src/CMakeFiles/aseprite.dir/main/main.cpp.o -o bin/aseprite lib/libapp-lib.a lib/libclip.a -lxcb -lpthread lib/libdio-lib.a lib/libfilters-lib.a lib/libflic-lib.a lib/libtga-lib.a lib/librender-lib.a lib/libdoc-lib.a lib/libfixmath-lib.a lib/libui-lib.a lib/liblaf-os.a lib/liblaf-gfx.a lib/liblaf-ft.a /root/deps/skia/out/Release-x64/libskia.a -lSKIA_OPENGL_LIBRARY-NOTFOUND /usr/lib/x86_64-linux-gnu/libfontconfig.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libXext.so /usr/lib/x86_64-linux-gnu/libXcursor.so /root/deps/skia/out/Release-x64/libskshaper.a lib/libobs.a lib/libundo.a lib/libcmark.a lib/libjpeg.a lib/libgiflib.a lib/libwebpdemux.a lib/libwebpmux.a lib/libwebp.a -lpthread -lm lib/libfreetype.a lib/libharfbuzz.a lib/libfreetype.a lib/libharfbuzz.a lib/libpng16.a -lm lib/libjson11.a lib/libarchive.a /usr/lib/x86_64-linux-gnu/libcrypto.so /usr/lib/x86_64-linux-gnu/libexpat.so /usr/lib/x86_64-linux-gnu/libssl.so lib/libfmt.a lib/libtinyexpr.a lib/liblauxlib.a lib/liblua.a lib/liblualib.a lib/libupdater-lib.a lib/libcfg-lib.a lib/libver-lib.a lib/libtinyxml.a lib/libnet-lib.a lib/liblaf-base.a lib/libmodpbase64.a /usr/lib/x86_64-linux-gnu/libdl.so lib/libcurl.a lib/libz.a -ldl && :
/usr/bin/ld: cannot find -lSKIA_OPENGL_LIBRARY-NOTFOUND
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
How may I solve this?
It appears that CMake is looking for OpenGL and failing... Aseprite doesn't seem to use OpenGL anyway, so disabling that altogether by clearing the cache variable SKIA_OPENGL_LIBRARY should work:
cd aseprite/build
cmake -DSKIA_OPENGL_LIBRARY="" ..
ninja aseprite
I have tested it on Windows, but I'm not entirely sure if it will work on Linux...
For anyone still looking for an answer to this. I got it to build on Ubuntu 20.04.
Follow the instructions to build skia over at the skia git repository. Make a note of which folder you cloned the repository into, you will need it later. I tried using the pre-built binaries but I must have been doing something wrong and could just never get it work.
When the build is complete you will see a note about 32-byte alignment, and if you check the out\Release-x64 folder you will see a libskia.a file. Now you know that skia was built succesfully.
Install the aseprite linux build dependencies with sudo apt-get install -y g++ cmake ninja-build libx11-dev libxcursor-dev libxi-dev libgl1-mesa-dev libfontconfig1-dev. You will find these instructions at the aseprite git repository.
Follow the instruction further down that page for the linux install but pay attention to the parameters you need to change regarding the location of that libskia.a file mentioned in point 2.
Before you start building (and why you're here) you need to enter #Ben_'s command given above to unlink the dependency to OPENGL (cmake -DSKIA_OPENGL_LIBRARY="" ..)
Now proceed to build aseprite with as the rest of the build instructions given on its repo page with ninja aseprite
Now go to aseprite/build/bin and find the aseprite executable.
You can copy this bin folder to another folder, and run aseprite from there. You can then delete all of the sources you downloaded.
There will be a bunch of errors during the python step, and you'll notice it complains about not being able to find some repositories, I think common.git is one of them. You may safely ignore this warning.
If you want to keep supporting development of the application I do recommend you spend whatever it costs for a license (but it's totally legal to build your own copy like this).

How to cross-compile Rust code for the Raspberry Pi Zero W

I am attempting to cross-compile Rust code on my 64-bit x86 laptop to run on the Raspberry Pi Zero W. I installed the arm-unknown-linux-gnueabihf toolchain using Rustup, but when I run cargo build --target arm-unknown-linux-gnueabihf, I get this error:
Internal error occurred: Failed to find tool. Is arm-linux-gnueabihf-gcc installed?
I tried to install the arm-linux-gnueabihf-gcc package from AUR, but that kept failing because of some sort of GPG key error, so I just decided to make my own cross-compiler using crosstool-ng.
I tried to point Cargo at my newly built cross-compiler using a ~/.cargo/config file:
[target.arm-unknown-linux-gnueabihf]
linker = "/home/ibi/x-tools/arm-unknown-linux-gnueabihf/bin/arm-unknown-linux-gnueabihf-gcc"
But Cargo seems to be ignoring this and giving me the same error. How do I fix this?
It worked when I set an environment variable:
$ export CC="/home/ibi/x-tools/arm-unknown-linux-gnueabihf/bin/arm-unknown-linux-gnueabihf-gcc"

ICU 58 undefined reference in MSYS2/MinGW64

Using instructions from
Compiling-ICU-with-MinGW
I got the following error
digitlst.o:digitlst.cpp:(.text+0x11): undefined reference to `_free_locale'
digitlst.o:digitlst.cpp:(.text+0x8fe): undefined reference to `_create_locale'
digitlst.o:digitlst.cpp:(.text+0xa20): undefined reference to `_create_locale'
collect2.exe: error: ld returned 1 exit status
My build environment:
MSYS2 with gcc version 6.3.0 (Rev1, Built by MSYS2 project)
64 Bit Toolchain: pacman -S mingw-w64-x86_64-toolchain
ICU 58.2 Sources ICU4C
I did
unzip icu4c-58_2-src.zip
cd icu/source
./runConfigureICU MinGW prefix=$PWD/../dist
make
Does anybody know how to solve this issue?
Edit: Same is with 58.1, but 57.1 works fine.
I was trying to build QT 5.8 with the latest version of ICU and this issue popped up...
I was able to build icu4c-58_2 by linking against libmsvcr100.a using x86_64-6.3.0-posix-seh-rt_v5-rev1
It appears that these functions are missing from the default libmsvcrt.a

Trying to compile linux build of project, cannot find library

I am trying to build a project written in c++ on Linux Mint 16, using...
make -f ./Makefile
and I keep getting this error
/usr/bin/ld: cannot find -ludev
collect2: error: ld returned 1 exit status
make: *** [BINARY] Error 1
I was getting a lot more of the /usr/bin/ld: cannot find -foo, but I checked in my Makefile and, using the synaptic package manager, installed all the other necessary libraries, eliminating all but this error. I cant seem to find it anywhere, although perhaps I am not looking in the right places.
Thanks.
I had the some problem, right after updating to Linux Mint 17.1. I was trying to build an application with Qt 5 serial port module. Solved by installing: libudev-dev .
try:
sudo apt-get install udev
I don't know how to do that in synaptic, but it should be easier, right?

Resources