= Common Porting Problems = This page serves to collect information about common problems encountered when porting applications/libraries to the Haiku/BeOS platform. The problems should be identified by the (compiler) errors that typify them. Information about BeOS's POSIX compatibility, see [wiki:BeOSPosix]. == Main UNIX differences == * No {{{/usr}}}: Just like BeOS, Haiku does not have /usr. Attempts to install things to {{{/usr}}} will usually fail and leave empty folders, because rootfs only allows creating directories, not regular files. The proper fix is to use {{{--prefix=/boot/common}}} in {{{./configure}}} command for libraries and {{{--prefix=/boot/apps/yourapphere}}} for applications. * No {{{-lm}}} was encountered: The {{{-lm}}} refers to libm which isn't needed for Haiku or BeOS. As the math library is part of libroot, is linked by default, implicitly. If the port is using the autotools chances are this can be fixed by doing an {{{AC_CHECK_LIB}}} for {{{cos}}} in {{{m}}} and then setting a variable such as {{{LIBM}}} or {{{MLIB}}} to by {{{="-lm"}}} if true or {{{=""}}} if not. Here is some explanation: [http://www.freelists.org/archives/haiku-development/04-2008/msg00904.html] * No {{{-lc}}} was encountered: This sometimes turns up, and I think it is due to the port using an older libtool. Try running {{{libtoolize --force --copy --install}}}, {{{aclocal}}}, {{{autoconf}}} and {{{automake}}} before {{{./configure}}} to see if that clears it up. * No {{{glXGetProcAddressARB}}}: use {{{glutGetProcAddress(const char* procName)}}} instead. See Haiku r38579. * No {{{socket}}} or {{{connection}}} function was encountered: The socket and connection functionalities are provided in Haiku's {{{libnetwork}}}. The proper fix for this is to patch the {{{configure}}} file to check that library as well. This is an example patch of libevent: {{{ diff -Naur libevent-1.4.13-stable/configure.in libevent-1.4.13-stable-haiku/configure.in --- libevent-1.4.13-stable/configure.in 2009-05-24 13:37:49.000000000 +0000 +++ libevent-1.4.13-stable-haiku/configure.in 2009-05-28 16:55:17.000000000 +0000 @@ -33,7 +33,7 @@ AC_SUBST(LIBTOOL_DEPS) dnl Checks for libraries. -AC_CHECK_LIB(socket, socket) +AC_SEARCH_LIBS(socket, socket network) AC_CHECK_LIB(resolv, inet_aton) AC_CHECK_LIB(rt, clock_gettime) AC_CHECK_LIB(nsl, inet_ntoa) }}} * Also note BeOS (BONE) needs {{{libsocket}}} and {{{libbind}}} instead. * Also, both {{{libbind}}} (on BeOS) and {{{libnetwork}}} (on Haiku) have some usual symbols mangled with a prepended underscore (or 2), so typically a test for {{{inet_aton}}} like above changed to {{{AC_SEARCH_LIBS(inet_aton, resolv bind)}}} will fail to find {{{libbind}}} (which exports it as {{{__inet_aton}}}). * This is because headers use preprocessor defines to make {{{inet_aton()}}} available, and the linking checks done by {{{autoconf}}} does not include the proper headers. This can be fixed by checking for another (unmangled) symbol like {{{gethostbyname2}}}. The cleanest checks for the above patch would then be: {{{ diff -Naur libevent-1.4.13-stable/configure.in libevent-1.4.13-stable-haiku/configure.in --- libevent-1.4.13-stable/configure.in 2009-05-24 13:37:49.000000000 +0000 +++ libevent-1.4.13-stable-haiku/configure.in 2009-05-28 16:55:17.000000000 +0000 @@ -33,7 +33,6 @@ AC_SUBST(LIBTOOL_DEPS) dnl Checks for libraries. -AC_CHECK_LIB(socket, socket) +AC_SEARCH_LIBS(socket, socket network) -AC_CHECK_LIB(resolv, inet_aton) +AC_SEARCH_LIBS(gethostbyname2, bind nsl resolv) AC_CHECK_LIB(rt, clock_gettime) -AC_CHECK_LIB(nsl, inet_ntoa) }}} * You will want to contact the project to ask for guidance here though, as it might impact other platforms. Also don't forget to fix the use of the {{{HAVE_FOO}}} macros in the code. * Actually, it seems Haiku provides {{{inet_ntoa()}}} as a weak alias for {{{__inet_ntoa}}}, (plus libnetwork is also checked for for {{{socket()}}}, though some applications won't use the tested symbols if the tested libraries are not there... which is why {{{AC_SEARCH_LIBS}}} is better than {{{AC_CHECK_LIBS}}}, as it first checks if the symbol is available already). == Missing functions == * {{{MSG_NOSIGNAL}}} undeclared: Add the following code into header/source file. {{{ #ifndef MSG_NOSIGNAL #define MSG_NOSIGNAL 0 #endif }}} * {{{FNDELAY}}} undeclared: Add the following code into header/source file. {{{ #ifndef FNDELAY #define FNDELAY O_NONBLOCK #endif }}} * {{{O_NOATIME}}} undeclared: Add the following code into header/source file. {{{ #include #ifndef _GNU_SOURCE #define _GNU_SOURCE // for O_NOATIME #define O_NOATIME 01000000 #endif }}} * {{{DT_DIR}}} undeclared: The use of {{{DT_DIR}}} doesn't work on non-ext* filesystems. So replace for {{{ #ifndef DT_DIR /* dirent.d_type is a BSD extension, not part of POSIX */ #include #include static int is_dir (const char *path, const char *name) { int len1 = strlen(path); int len2 = strlen(name); char pathname[len1 + 1 + len2 + 1 + 13]; strcpy (pathname, path); /* Avoid UNC-path "//name" on Cygwin. */ if (len1 > 0 && pathname[len1 - 1] != '/') strcat (pathname, "/"); strcat (pathname, name); struct stat st; if (stat (pathname, &st)) return 0; return S_ISDIR (st.st_mode); } #endif //And after, add a check function info.dir = !! is_dir (path, de->d_name); }}} == Compile time problems == * No {{{undefined references}}} allowed in i586-pc-beos shared libraries: found in [wiki:dev-util/subversion] and [wiki:dev-libs/apr] ports. You need to pass the {{{-no-undefined}}} option to {{{libtool}}}. Alternatively, {{{libtool}}} can be patched to always exhibit this behavior, '''"at the risk of breaking static compilation when dynamic linking fails".'''''''''' -- andreasf''' == GCC 2 build problems == * {{{output_operand_lossage `invalid expression as operand'}}}: This can be avoided by not passing the {{{-g}}} option to gcc for this test. == GCC 4 build problems == * Typical errors look like these: {{{ error: 'find' is not a member of 'std' error: 'exit' was not declared in this scope }}} * Please take a look at: [http://www.cyrius.com/journal/2007/05/10#gcc-4.3-include] and [http://www.comp.leeds.ac.uk/hannah/cpp/errors.html] == Haiku fixed problems == * (stat) structure has no member {{{'st_blocks'}}}: found in [wiki:app-arch/tar] (make check), [wiki:net-fs/samba] and [wiki:dev-util/cvs] ports. The stat struct in {{{sys/stat.h}}} in BeOS '''''and Haiku''''' ([http://dev.haiku-os.org/ticket/2261] Haiku now has it, [http://dev.haiku-os.org/changeset/27791] as seen here) doesn't have an {{{st_blocks}}} member. In projects with {{{autoconf}}}, you can check for {{{HAVE_STAT_ST_BLOCKS}}}. Please check [http://lists.samba.org/archive/samba-technical/2005-January/039275.html] for more information. * {{{stdbool.in.h}}}: [http://ports.haiku-files.org/wiki/dev-libs/gnulib]. So any releases posted '''AFTER''' May 25, 2008 'should' include an updated {{{stdbool.in.h}}} * iconv: Iconv is included in Haiku, but many times {{{./configure}}} does not detect and use it. This is because it is in {{{libtextencoding.so}}} ([http://dev.haiku-os.org/ticket/2294 should be fixed now]). So try adding a check for iconv in {{{-ltextextencoding}}} and see if that works. * Conflicting types for {{{'restrict'}}}: {{{ /boot/develop/headers/posix/search.h:35: conflicting types for `restrict' /boot/develop/headers/posix/search.h:35: previous declaration of `restrict' }}} * This seems to be an issue with Haiku and has been reported [http://dev.haiku-os.org/ticket/2262 Haiku-2262]. This has been fixed in Haiku. If using a version prior to the fix you can copy the {{{search.h}}} file over the one in your headers/posix folder. * Missing {{{syslog()}}}: On BeOS, {{{syslog()}}} is in libbe, so one must {{{AC_SEARCH_LIBS(syslog, be)}}}. It's in {{{libroot}}} on Haiku so it shouldn't need any check.