Search code examples
ccompiler-errorsdebiandhcp

Compile isc-dhcp-server on linux


I want to compile and debug DHCP server from source code from this repository: https://github.com/isc-projects/dhcp

Everything that I done:

./configure

make

But I have a lot of errors in this few two commands.

/usr/bin/ld: dhcpd-mdb.o:/home/ali/programming/c/opensource/dhcp/server/mdb.c:70: multiple definition of `dhcp_type_host'; dhcpd-omapi.o:/home/ali/programming/c/opensource/dhcp/server/omapi.c:50: first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:529: dhcpd] Error 1
make[2]: Leaving directory '/home/ali/programming/c/opensource/dhcp/server'
make[1]: *** [Makefile:970: all-recursive] Error 1
make[1]: Leaving directory '/home/ali/programming/c/opensource/dhcp/server'
make: *** [Makefile:496: all-recursive] Error 1

But why ? How can I compile isc-dhcp-server ?

My linux distro is debian v11.

UPDATE:

Before compiling isc-dhcp I installed it's requirements.

# apt install bind9-dev

Then I ran this command instead of make :

make -C server install

But this errors occur :

make: Entering directory '/home/ali/programming/c/opensource/dhcp/server'
Making install in .
make[1]: Entering directory '/home/ali/programming/c/opensource/dhcp/server'
gcc -DHAVE_CONFIG_H -I. -I../includes  -I.. -DLOCALSTATEDIR='"/var"'   -g -O2  -Wall -Werror -fno-strict-aliasing -I../includes -I/home/ali/programming/c/opensource/dhcp/bind/include -MT dhcpd-mdb6.o -MD -MP -MF .deps/dhcpd-mdb6.Tpo -c -o dhcpd-mdb6.o `test -f 'mdb6.c' || echo './'`mdb6.c
mdb6.c: In function ‘create_prefix6’:
mdb6.c:1948:3: error: writing 16 bytes into a region of size 1 [-Werror=stringop-overflow=]
 1948 |   memcpy(new_ds.buffer->data + ds.len, &tmp, sizeof(tmp));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../includes/dhcpd.h:97,
                 from mdb6.c:175:
../includes/tree.h:62:16: note: at offset 0 to object ‘data’ with size 1 declared here
   62 |  unsigned char data [1];
      |                ^~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:738: dhcpd-mdb6.o] Error 1
make[1]: Leaving directory '/home/ali/programming/c/opensource/dhcp/server'
make: *** [Makefile:921: install-recursive] Error 1
make: Leaving directory '/home/ali/programming/c/opensource/dhcp/server'

This is my configure output result :

     ISC DHCP source configure results:
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Package:
  Name:          DHCP
  Version:       4.4.2b1

C Compiler:      gcc

Flags:
  DEFS:          -DHAVE_CONFIG_H
  CFLAGS:        -g -O2  -Wall -Werror -fno-strict-aliasing -I$(top_srcdir)/includes -I/home/ali/programming/c/opensource/dhcp/bind/include

DHCP versions:   DHCPv4 and DHCPv6

Features:
  debug:         no
  failover:      yes
  execute:       yes
  binary-leases: no
  dhcpv6:        yes
  delayed-ack:   yes
  dhcpv4o6:      no
  relay-port:    no

Developer:
  ATF unittests : no


Now you can type make to build ISC DHCP

SOLUTION

We should clone isc-dhcp service from here


Solution

  • It seems like you are compiling the last commit from an old repo. The github page points at a newer repo at a newer commit at isc's gitlab site.

    You can also switch to the latest stable tag git checkout v4_4_2_p1 for better stability.

    A note, i was able to get it to build using gcc-9, for me the latest stable tag would not build with gcc-10 which is the package version for debian 11. This is an open issue