Stupid error building binutils

So I’m starting a new VM, and after installing Debian, and the important packages, build-essential and the Linux headers…

#  apt-get install build-essential linux-headers-$(uname -r)

I got this fine error trying to build binutils:

gcc -g -O2 -o sysinfo sysinfo.o syslex.o
syslex.o: In function `main’:
/usr/src/binutils-build/syslex.c:1: multiple definition of `main’
sysinfo.o:/usr/src/binutils-2.22-human68k/sysinfo.c:1: first defined here
collect2: ld returned 1 exit status

Turns out I didn’t have bison/flex installed.  Oops!

Oh well easy enough to solve.

#apt-get install bison flex

Otherwise, remember to build binutils/gcc in it’s own directory or that’ll cause other fun down the line.

Don’t forget you need GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+ to build GCC…

#  apt-get install libgmp-dev libmpfr-dev libmpc-dev

4 thoughts on “Stupid error building binutils

      • Well, I brainfarted when I wrote the post and wrote gcc instead of binutils, but I had this same exact issue when compiling a toolchain. By using apt-get build-dep binutils I have the following output:

        The following NEW packages will be installed:
        autoconf bison dejagnu diffstat expect flex libbison-dev quilt tcl8.5 texinfo zlib1g-dev

        I had to include “deb-src wheezy main contrib non-free” in my sources.list before, though.

Leave a Reply