[help] Porting libmodbus

Hi all ,

i’m very interesting in PLC (programmable logic control) and i’m interesting on how this device can be run via our beloved os…

PLC application that i want to port need libmodbus that not yet available on haiku…
so i have to port it first…

so this is my attempt to port it but… stuck on error

/sources/libmodbus-3.0.8/tests/bandwidth-server-many-up.c:104: undefined reference to accept' /boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/8.3.0/../../../../x86_64-unknown-haiku/bin/ld: /sources/libmodbus-3.0.8/tests/bandwidth-server-many-up.c:114: undefined reference to inet_ntoa’

this is the content of recipe file: libmodbus-3.0.8.recipe

SUMMARY="A groovy modbus library"
DESCRIPTION="
libmodbus is a free software library to send or receive data with a device which respects  \
the Modbus protocol. This library can use a serial port or an Ethernet connection.

The functions included in the library have been derived from the Modicon Modbus Protocol  \
Reference Guide which can be obtained from www.modbus.org.
"
HOMEPAGE="https://github.com/stephane/libmodbus"
COPYRIGHT="
	Stéphane Raimbault
	Tobias Doerffel
	Florian Forster
	oldfaber
	Hannu Vuolasaho
	Michael Heimpold
	Jimmy Bergström
	Jakob Bysewski
	"
LICENSE="GNU LGPL v2.1"
REVISION="1"
SOURCE_URI="https://github.com/stephane/libmodbus/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="0e236c3d4fe0a7a3f7c6292a3d1183c584b03bb06154e0b95e71bc763559ac5d"

ARCHITECTURES="!x86_gcc2 x86 x86_64"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	libmodbus$secondaryArchSuffix = $portVersion

	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	libmodbus${secondaryArchSuffix}_devel = $portVersion

	"
REQUIRES_devel="
	libmodbus$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	autogen.sh 
	runConfigure ./configure
	make
}

INSTALL()
{
	make install

	rm $libDir/lib*.la

	# prepare development lib links
	prepareInstalledDevelLibs libmodbus
	fixPkgconfig

	# devel package
	packageEntries devel $developDir
}

TEST()
{
	make check
}

thanks All

AFAIK accept is in libnetwork, so you can:

export LDFLAGS="-lnetwork"

then reconfigure and rebuild.

thanks for your pointer… i make modification at makefile on the test subfolder that cause error…
i successfully run make…
but i confuse when haikuporter executed… it will wipe the change… and error show again.
sorry i’m still not yet understand about this makefile… it seem it is generating when run autogen or configure…
… i’m still check further…

Please read the haikuporter wiki.
To change the makefile you should create a patch with haikuporter, it is explained in the wiki step for step.

i think problem not from that… i know how to make patch… but the Makefile itself generated… so makefile itself not exist yet before configure… thereis Makefile.in and Makefile.am that the source of Makefile generated from… but…
i still dont have idea where to start…
thinking…

Autogen will regenerate your makefiles from makefile.in, makefile.am, configure.ac, and from m4 files.
You should patch one of this.

If there is a “configure.in” file it might be worth patching it to find the “inet_ntoa” function in -lnetwork as @extrowerk already mentioned, see an example here: https://github.com/haikuports/haikuports/pull/470

But one can spare in this case the patching with the export command i wrote before. One canput it before the configure invocation.

…thanks for the hint @begasus… i’ll look at it

thanks for direction @extrowerk … i will check it too

LIBS=-lnetwork help in this case…
i choose this because more simple…

@extrowerk solution maybe better… but seem take longer path because my understanding build tool is very small… and need more time to learn
… right now i tested forward and try to compile other apps that use libmodbus to check it compileable or not…