-1

I'm trying to compile the binutils for the i686-elf target according to this tutorial:

I just added the --enable-tui option, so that I have the support in the gdb.

I did the following:

# get sources
git clone git://sourceware.org/git/binutils-gdb.git

# store settings
export PREFIX="`pwd`/opt/cross"
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"

# create build folder
mkdir build-binutils
cd build-binutils

# run configure
../binutils-gdb/configure -target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror --enable-tui

# make
make

This runs for some time and terminates with the following error:

checking for library containing socketpair... (cached) none required
checking for ld used by GCC... (cached) ld
checking if the linker (ld) is GNU ld... (cached) yes
checking for shared library run path origin... (cached) done
checking for iconv... (cached) yes
checking for iconv declaration... (cached) 
         extern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
checking for library containing waddstr... (cached) no
configure: error: no enhanced curses library found; disable TUI
make[1]: *** [Makefile:11329: configure-gdb] Error 1
make[1]: Leaving directory '/home/noexpandtab/dev/build-binutils'
make: *** [Makefile:853: all] Error 2

For me it seems, that the ncurses library cannot be found.

I have a Debian 10 running and installed the following additional packages:

  • libncurses-dev
  • ncurses-base
  • ncurses-doc
  • libncurses5-dev

Do I have to install additional packages? Or am I missing some options for the configure script?

  • if you're cross-compiling, you'll have to compile your own cross-compiled ncurses libraries. – Thomas Dickey Jan 02 '21 at 16:03
  • 1
    @Thomas In my understanding, the `--target` option defines the architecture/binary type of the binaries that the binutils-gdb toolchain will handle. Not the architecture under which these binaries will be executed. -- So the binutils defined with `--target=i686_elf` can be used to create binaries of the type `i686_elf`. The binutils itself cannot be executed under `i686_elf`, but under the host architecture that they were compiled. Therefor the ncurses library for the host architecture should be sufficient. Please correct me if I'm getting this wrong. – noexpandtab Jan 02 '21 at 19:45
  • 1
    Can you show us the last few lines of `gdb/config.log` ? Look starting at `checking for library containing waddstr`. There can be a number of failures as it looks for several curses variants but on Debian 10 there should ultimately be a line `gcc -o conftest -g -O2 conftest.c -lncurses -lm -ldl >&5` followed by `$? = 0` and `result: -lncurses` – Mark Plotnick Jan 02 '21 at 22:21
  • @MarkPlotnick I checked gdb/config.log but couldn't find any further hints after the line `checking for library containing waddstr` than the once already posted as the make output. There were no such lines containing `contftest` and `ncurses`. – noexpandtab Jan 04 '21 at 14:03

2 Answers2

-1

You're cross-compiling to a different architecture (i686-elf) than whatever you're running on—the $TARGET mentioned in the question. gdb will have to be linked with libraries which are built for that architecture.

Debian provides ncurses packages which run on the current architecture, but does not provide a suitable package for the cross-compiled application. So you get to do this for yourself.

When cross-compiling ncurses, you'll have to keep in mind that part of it builds/runs on the current architecture (to generate source-files for compiling by the cross-compiler). That's defined in the environment as $BUILD_CC (rather than $CC), as you might see when reading the script for the mingw cross-compiling. There's a section in the INSTALL file (in the ncurses sources) which outlines the process.

There's no tutorial (that would be off-topic here anyway), but others have read the instructions and cross-compiled ncurses as evidenced by a recent bug report.

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
-1

I retried the whole compilation, and suddenly it works! I tested a bit and I assume I found my fault: I executed configure without --enable-tui, where make worked. Then I executed configure with --enable-tui in the same folder without cleaning it. After cleaning or running in a new folder it compiled.

Thanks to the one user who posted to delete the contents of opt/cross. (The comment itself was already somehow deleted in between.) This wasn't the solution, but leaded me in the right direction.

TL;DR: Clean the build folder before running configure with different parameters again.