gcc built by crosstool-ng gives undefined reference
- by netvope
I've successfully built a toolchain using crosstool-ng with the default configuration named x86_64-unknown-linux-gnu.
The documentation says:
Using the toolchain is as simple as adding the toolchain's bin directory in
your PATH, such as:
export PATH="${PATH}:/your/toolchain/path/bin"
and then using the target tuple to tell the build systems to use your
toolchain:
./configure --target=your-target-tuple
or
make CC=your-target-tuple-gcc
or
make CROSS_COMPILE=your-target-tuple-
and so on...
I followed the instructions and attempted to build GNU tar (tar-1.25.tar.bz2) with the toolchain. The commands ./configure --target=x86_64-unknown-linux-gnu and make CROSS_COMPILE=x86_64-unknown-linux-gnu- do not work (the build will succeed, but it uses the host system's gcc). The command make CC=x86_64-unknown-linux-gnu-gcc works, but in the very last step when it tries to link, it returns errors like this:
compare.o: In function `openat':
/dev/shm/x-tools/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/sys-root/usr/include/bits/fcntl2.h:134: undefined reference to `__openat_2'
What could be the problem? Was the toolchain not properly setup? Perhaps x86_64-unknown-linux-gnu-gcc is using the header files from the host system but could not find the libraries in the target's sys-root?