Port build error related to ASIO and netdb.h

I’m new to Haiku so I thought I would learn a bit by testing haikuporter on an existing port, widelands-1.1. However, I first had to add gettext to the build depends before I ran into the real issue that has me stumped. Widelands makes use of asio and asio needs some definitions from netdb.h which it is not seeing:

/boot/system/develop/headers/asio/error.hpp:186:20: error: ‘HOST_NOT_FOUND’ was not declared in this scope; did you mean ‘B_STREAM_NOT_FOUND’?
186 | host_not_found = ASIO_NETDB_ERROR(HOST_NOT_FOUND),

These missing definitions are within a #if defined(_DEFAULT_SOURCE) #endif block in netdb.h and _DEFAULT_SOURCE gets defined in headers/bsd/features.h when _BSD_SOURCE is defined and the widelands recipe passes -D_BSD_SOURCE to the compiler. My assumption is that _DEFAULT_SOURCE is not getting defined properly, but even when I add it to the C and CXX flags the error still persists. Any help would be appreciated.

Did you try adding -D_GNU_SOURCE in the recipe next to –D_BSD_SOURCE?

EDIT: strike that, didn’t solve anything.

Given the age of the recipe, the gettext package has been worked over and split into seperate parts, it’s probably missing cmd’s for msgfmt/msgmerge …

EDIT: you know how to pick them :slight_smile: pretty large download to check now :rofl:

Related: Porting issues R1B4 vs nightly - #12 by madmax

This worked, but then there is another error still around, maybe asio is too new for this?

diff --git a/src/network/network.h b/src/network/network.h
index 3d540d6..fc01b90 100644
--- a/src/network/network.h
+++ b/src/network/network.h
@@ -16,22 +16,18 @@
  *
  */
 
+#ifdef __HAIKU__
+#define _DEFAULT_SOURCE
+#define _BSD_SOURCE
+#endif
+
 #ifndef WL_NETWORK_NETWORK_H
 #define WL_NETWORK_NETWORK_H
 
 
 
 #include <functional>
-
-#ifdef __HAIKU__
-#undef _BSD_SOURCE
-#undef _DEFAULT_SOURCE
-#endif
 #include <asio.hpp>
-#ifdef __HAIKU__
-#define _DEFAULT_SOURCE
-#define _BSD_SOURCE
-#endif
 
 #include "base/string.h"
 #include "base/wexception.h"

...
Error now:

/sources/widelands-1.1/src/network/bufferedconnection.h:316:15: error: 'io_service' in namespace 'asio' does not name a type; did you mean 'use_service'?
  316 |         asio::io_service io_service_;
      |               ^~~~~~~~~~
      |               use_service
/sources/widelands-1.1/src/network/bufferedconnection.h:316:15: error: 'io_service' in namespace 'asio' does not name a type; did you mean 'use_service'?
  316 |         asio::io_service io_service_;
      |               ^~~~~~~~~~
      |               use_service
make[2]: *** [src/ui_fsmenu/CMakeFiles/ui_fsmenu.dir/build.make:359: src/ui_fsmenu/CMakeFiles/ui_fsmenu.dir/login_box.cc.o] Error 1
make[2]: *** [src/ui_fsmenu/CMakeFiles/ui_fsmenu.dir/build.make:317: src/ui_fsmenu/CMakeFiles/ui_fsmenu.dir/launch_mpg.cc.o] Error 1
/sources/widelands-1.1/src/network/bufferedconnection.h:316:15: error: 'io_service' in namespace 'asio' does not name a type; did you mean 'use_service'?
  316 |         asio::io_service io_service_;
      |               ^~~~~~~~~~
      |               use_service
In file included from /sources/widelands-1.1/src/ui_fsmenu/netsetup_lan.h:25,
                 from /sources/widelands-1.1/src/ui_fsmenu/main.cc:49:
/sources/widelands-1.1/src/network/network_lan_promotion.h:136:15: error: 'io_service' in namespace 'asio' does not name a type; did you mean 'use_service'?
  136 |         asio::io_service io_service;
      |               ^~~~~~~~~~
      |               use_service
```

Stupid markdown :confused:

EDIT2: replacing use_service with io_context works (this has been replaced in asio for quite some time, however there are again new errors popping up …. not sure how uptoday the version of widelands is, maybe a newer version has less issues?

I use boost::asio a lot in i2pd.

Build with DEFINES = -D_DEFAULT_SOURCE -D_GNU_SOURCE works fine.

1 Like

I’ve been using boost asio on Haiku for over 10 years, did nothing special to get it compiling.

As far as I can look it up boost::asio isn’t the same as our asio package in the depot?

EDIT: maybe switch to latest 1.3.1 release, asio issue resolved there, and with the above patch for “_GNU_SOURCE” it builds OK (should be fine with boost190 also, didn’t check there yet. Looking forward on a PR to update this. :slight_smile: (maybe asio could be bumped here too).

EDIT2: asio has been updated to 1.38.0 just now.

I’m pleased that you like my choice of package to start on. :slight_smile:

When I had trouble building I did switch to version 1.3.1 which did not resolve that issue, but it is good to know that it is needed for compatibility with asio. It turns out that the problematic code that your patch addresses was added by the port’s patch so the fix is as simple as just not messing with network.h.

Now to do a little testing…

1 Like

Thanks for the PR! As mentioned there I “think” you are running Haiku nightly, and it’s possible (didn’t check there yet), it builds without pathcing network.h, but I still needed it for R1B5.

So counting that the buildmasters still run on that it should be checked for that before merging.

I also did a PR for latest glew, maybe you could try to build that to be used for Widelands, it worked here.

One anoying thing is the cursor rendering, but don’t know how to solve that, been out of the loop for SDL for quite some time. :slight_smile:

Patchset should check for B_HAIKU_VERSIONsome examples from haikuports.

Basically:

#include <BeBuild.h>

#if (B_HAIKU_VERSION <= B_HAIKU_VERSION_1_BETA_5)
   [... add here missing defines not needed anymore in nightlies...]
#endif
1 Like

Should check this with my local builds in nightly vs beta5

I installed from the ISO of r1beta5 and don’t recall doing anything that would have switched me to nightly. I’ll have to dig in and verify that just to be sure.

1 Like

To be fair, I haven’t tried building it without the mentioned patch, if that works your PR is good to go. :slight_smile:

PS glew’s PR got merged (you probably read that in the PR), so you could use: devel:libGLEW$secondaryArchSuffix >= 2.3 in the recipe also.

EDIT: resolved, looks like it’s not required at all, PR is merged, crossing fingers on the builds on buildmasters. Thanks for the contribution @SteveM ! :+1:

1 Like

Thanks for the help! Is R1/beta5 the correct version to be using when working on a port?

To be sure the builds will pass on buildmasters yes, but as @BiPolar mentioned above, you can do a nightly build and pass the version requirement to make sure they build on beta5 and nightly (should only be used in rare conditions though, not always needed).

To switch from beta5 to nightly and back I’m using Repositories to switch the url’s for this, some information/tips at:

https://github.com/Begasus/haikuports/wiki/Updating-Haiku-or-switch-from-nightly-to-beta-or-visa-versa#switch-with-the-application-repositories-in-preferences-menu

1 Like