2011/5/4 Rafael Sadowski <raf...@sizeofvoid.org>:
> Hello @tech and all honorable OpenBSD Developer,
>
> first of all, I happy about any help or helpful advice!
>
> Based on Edd Barrett (edd@) idea[1] to develop a Network Interface
> Daemon for OpenBSD, I'm currently hack on it.
>
> My first really huge problem is similar to Edd thoughts:
>
> "I guess this would mean moving all of the functions apart from main()
> from ifconfig.c into another file (complete with header), so that we can
> call them from the new ifconfigd? I'm no expert"
>
> My first initial solution was similar. I created ifconfig.h. This diff
> is just for example. It works fine with ifconfig but how can I use it
> from another directory like src/usr.sbin/ifconfigd.
>
> My first try with modify[2] PATH and -L and -I CFLAGS doesn't work. It
> break with suff like this (I understand the error but I not know any
> solution):
>
>
> cc B  -o ifconfigd parse.o log.o control.o ifconfigd.o ifconfigde.o
ifconfig.o bioctl.o pbkdf2.o -levent -lutil
> ifconfig.o(.text+0x2220): In function `usage':
> : multiple definition of `usage'[1;3B
> ifconfigd.o(.text+0x400): first defined here
> /usr/bin/ld: Warning: size of symbol `usage' changed from 38 in ifconfigd.o
to 35 in ifconfig.o

This

> ifconfig.o(.text+0xa440): In function `main':
> : multiple definition of `main'
> ifconfigd.o(.text+0x430): first defined here
> /usr/bin/ld: Warning: size of symbol `main' changed from 883 in ifconfigd.o
to 1790 in ifconfig.o

and this tells me you just copied all the function declarations in a
header and tried to compile ifconfig.c in your program.  This will
obviously not work since ifconfig.c defines a main() function (in
addition to a usage()) and you want to use your own.

You have to make a separate file in the ifconfig directory that holds
the main() and usage() functions (or a separate file for all the other
functions as edd suggests) and includes the ifconfig.h header and
change the accompanying build instructions.

> bioctl.o(.text+0x1fa0): In function `usage':
> : multiple definition of `usage'
> ifconfigd.o(.text+0x400): first defined here
> /usr/bin/ld: Warning: size of symbol `usage' changed from 35 in ifconfigd.o
to 41 in bioctl.o
> bioctl.o(.text+0x1fd0): In function `main':
> : multiple definition of `main'
> ifconfigd.o(.text+0x430): first defined here
> /usr/bin/ld: Warning: size of symbol `main' changed from 1790 in ifconfigd.o
to 1151 in bioctl.o

Same thing here, with bioctl

> ifconfig.o(.text+0x6c7b): In function `getinfo':
> : undefined reference to `is_bridge'
> ifconfig.o(.text+0x968b): In function `status':
> : undefined reference to `is_bridge'
> ifconfig.o(.text+0x990a): In function `status':
> : undefined reference to `bridge_status'
> ifconfig.o(.text+0xaa20): In function `main':
> : undefined reference to `bridge_rule'
> ifconfig.o(.rodata+0x12d0): undefined reference to `bridge_add'
>
> ... (and more undefined reference to ...)
>
> collect2: ld returned 1 exit status
> *** Error code 1
>
> [1]
http://www.theunixzoo.co.uk/wiki/doku.php?id=edd:openbsd#network_interface_da
emon_ifconfigd
> [2 Makefile Section:
>
> .PATH: ${.CURDIR} ${.CURDIR}/../../sbin/ifconfig
${.CURDIR}/../../sbin/bioctl
>
> PROG= ifconfigd SRCS= parse.y log.c control.c ifconfigd.c ifconfigde.c
> SRCS+= ifconfig.c bioctl.c pbkdf2.c
>
> LDADD+= B  B  B  B  -levent -lutil
>
> MAN= B  B  B  B  B  B ifconfigd.8 ifconfigd.conf.5
>
> CFLAGS+= -DINET6 -I${.CURDIR}/../bioctl -I${.CURDIR}/../../sbin/ifconfig
> CFLAGS+= -L${.CURDIR}/../bioctl -L${.CURDIR}/../../sbin/ifconfig

Reply via email to