Compiling libimobiledevice

I am trying to compile libimobiledevice on Haiku but bumping a wall all the time because probably I am missing something all the time. This is what happens if I fetch the source and try to compile without any modifications:

> sh autogen.sh

libtoolize: putting auxiliary files in '.'.
libtoolize: linking file './ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: linking file 'm4/libtool.m4'
libtoolize: linking file 'm4/ltoptions.m4'
libtoolize: linking file 'm4/ltsugar.m4'
libtoolize: linking file 'm4/ltversion.m4'
libtoolize: linking file 'm4/lt~obsolete.m4'
configure.ac:29: installing './compile'
configure.ac:6: installing './missing'
common/Makefile.am: installing './depcomp'
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking build system type... x86_64-unknown-haiku
checking host system type... x86_64-unknown-haiku
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /boot/system/develop/tools/x86_64-unknown-haiku/bin/ld
checking if the linker (/boot/system/develop/tools/x86_64-unknown-haiku/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /bin/nm -B
checking the name lister (/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 32768
checking how to convert x86_64-unknown-haiku file names to x86_64-unknown-haiku format... func_convert_file_noop
checking how to convert x86_64-unknown-haiku file names to toolchain format... func_convert_file_noop
checking for /boot/system/develop/tools/x86_64-unknown-haiku/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC...  -DPIC
checking if gcc PIC flag  -DPIC works... yes
checking if gcc static flag  works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/boot/system/develop/tools/x86_64-unknown-haiku/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... yes
checking dynamic linker characteristics... haiku runtime_loader
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /boot/system/develop/tools/x86_64-unknown-haiku/bin/ld
checking if the linker (/boot/system/develop/tools/x86_64-unknown-haiku/bin/ld) is GNU ld... yes
checking whether the g++ linker (/boot/system/develop/tools/x86_64-unknown-haiku/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC...  -DPIC
checking if g++ PIC flag  -DPIC works... yes
checking if g++ static flag  works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/boot/system/develop/tools/x86_64-unknown-haiku/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... haiku runtime_loader
checking how to hardcode library paths into programs... immediate
checking for pkg-config... /bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for libusbmuxd-2.0 >= 2.0.2... yes
checking for libplist-2.0 >= 2.2.0... yes
checking for stdint.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking gcrypt.h usability... no
checking gcrypt.h presence... no
checking for gcrypt.h... no
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking for ssize_t... yes
checking for uint16_t... yes
checking for uint32_t... yes
checking for uint8_t... yes
checking for asprintf... yes
checking for strcasecmp... yes
checking for strdup... yes
checking for strerror... yes
checking for strndup... yes
checking for stpcpy... yes
checking for vasprintf... yes
checking for getifaddrs... no
checking endian.h usability... yes
checking endian.h presence... yes
checking for endian.h... yes
checking for platform-specific build settings... haiku
checking whether gcc is Clang... no
checking whether pthreads work with "-pthread" and "-lpthread"... no
checking whether pthreads work with -pthread... no
checking whether pthreads work with -pthreads... no
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking whether more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... yes
checking for pthread_once in -lpthread... yes
checking for struct dirent.d_type... no
checking for cython... no
checking for cython3... no
configure: WARNING: Unable to find 'cython' or 'cython3' program. You should look at https://cython.org or install your distribution specific cython package.
configure: WARNING: Use the "--without-cython" option to avoid this warning.
checking for openssl >= 0.9.8... yes
checking for supported compiler flags...  -Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -fsigned-char -fvisibility=hidden
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking whether make supports nested variables... (cached) yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating common/Makefile
config.status: creating src/Makefile
config.status: creating src/libimobiledevice-1.0.pc
config.status: creating include/Makefile
config.status: creating tools/Makefile
config.status: creating cython/Makefile
config.status: creating docs/Makefile
config.status: creating doxygen.cfg
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands

Configuration for libimobiledevice 1.3.1:
-------------------------------------------

  Install prefix: .........: /usr/local
  Debug code ..............: no
  Python bindings .........: no
  SSL support backend .....: OpenSSL

  Now type 'make' to build libimobiledevice 1.3.1,
  and then 'make install' for installation.

> make

make  all-recursive
make[1]: Entering directory '/boot/home/Desktop/libimobiledevice'
Making all in common
make[2]: Entering directory '/boot/home/Desktop/libimobiledevice/common'
  CC       socket.lo
socket.c:683:2: error: #error No reference implementation for getifaddrs available for this platform.
 #error No reference implementation for getifaddrs available for this platform.
  ^~~~~
socket.c: In function '_sockaddr_in6_scope_id':
socket.c:724:25: error: 'IFF_RUNNING' undeclared (first use in this function); did you mean 'IFF_LINK'?
   if ((ifa->ifa_flags & IFF_RUNNING) == 0) {
                         ^~~~~~~~~~~
                         IFF_LINK
socket.c:724:25: note: each undeclared identifier is reported only once for each function it appears in
Makefile:469: recipe for target 'socket.lo' failed
make[2]: *** [socket.lo] Error 1
make[2]: Leaving directory '/boot/home/Desktop/libimobiledevice/common'
Makefile:459: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/boot/home/Desktop/libimobiledevice'
Makefile:389: recipe for target 'all' failed
make: *** [all] Error 2

Here is what happens if I am correct:
socket.c file includes ifaddrs.h
ifaddrs.h available in haiku is from BSD, not GNU C library, it does not have the getifadddrs function needed. Pay attention to checking for getifaddrs... no
I tried things like copying ifaddrs.h and inet/ifaddrs.h from glibc source to /libimobiledevice/include, the whole glibc source to that folder and even the whole /usr/include folder on my Arch Linux installation. These just introduced more errors. The conlcusion I reached is that I should create a linux environment (not the kernel :slight_smile: but headers and other files compiler looks for) and I cannot do it.

Correct me if necessary, I am not familiar with compiling or C.

How can I provide the compiler required header files? Or, is this what should I do?

One more thing, I have seen other threads about porting software and answer is usually “read the haikuporter wiki”. It is for automating while I cannot do it manually.

Then maybe you should spend more time with it. There is sections about porting too.
But I fear the answer would be “linuxism” (eg. not portable code), probably you will have to rewrite/reimplement that code section with the functions available on Haiku. And please do not mix headers from other OS into this, that won’t help.

If you enable inpatch (and inrecipe) alias you can find more info about these errors by running:

inpatch IFF_RUNNING
inpatch getifaddrs
1 Like

The getifaddrs function is there, but it is in libnetwork. You need to link that library for things to work.

2 Likes

You’ll want to try something like AC_SEARCH_LIBS (which searches for the function first as-is, then in any lib listed) instead of having it in AC_CHECK_FUNCS:

AC_SEARCH_LIBS([getifaddrs],[network])
1 Like