Skip to content

Fix build with libupnp 1.18#432

Open
puleglot wants to merge 1 commit intoamule-project:masterfrom
puleglot:libupnp-1.18
Open

Fix build with libupnp 1.18#432
puleglot wants to merge 1 commit intoamule-project:masterfrom
puleglot:libupnp-1.18

Conversation

@puleglot
Copy link
Copy Markdown
Contributor

@puleglot puleglot commented Mar 28, 2026

Fixes #431

@sc0w
Copy link
Copy Markdown
Member

sc0w commented Mar 29, 2026

the ci says the build fails with libupnp 1.14.18

UPnPBase.cpp: In constructor ‘CUPnPControlPoint::CUPnPControlPoint(short unsigned int)’:
UPnPBase.cpp:845:17: error: invalid ‘static_cast’ from type ‘int (*)(Upnp_EventType_e, void*, void*)’ to type ‘Upnp_FunPtr’ {aka ‘int (*)(Upnp_EventType_e, const void*, void*)’}
  845 |                 static_cast<Upnp_FunPtr>(&CUPnPControlPoint::Callback),
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@puleglot
Copy link
Copy Markdown
Contributor Author

Interesting.. Debian/Ubuntu are using a different version scheme for libupnp based on library soname.

@puleglot
Copy link
Copy Markdown
Contributor Author

For example:

  • libupnp 1.14.18 from Ubuntu 24.04:
#define UPNP_VERSION_STRING "17.1.9"

which results in UPNP_VERSION=170109

  • libupnp 1.14.30 from Getnoo:
#define UPNP_VERSION_STRING "1.14.30"

which results in UPNP_VERSION=11430

@puleglot
Copy link
Copy Markdown
Contributor Author

puleglot commented Mar 29, 2026

Interesting.. Debian/Ubuntu are using a different version scheme for libupnp based on library soname.

And this is actually a difference between autotools and cmake builds of libupnp. What a mess. =(
pupnp/pupnp#277

@Vollstrecker
Copy link
Copy Markdown
Collaborator

So this one is not fixed?

@puleglot
Copy link
Copy Markdown
Contributor Author

puleglot commented Mar 29, 2026

I don't know how to properly fix this for certain libupnp versions built with cmake (including those currently shipped by Debian and Ubuntu). libupnp upstream fixed this at some point, so both cmake and autotools builds now generate consistent version info. E.g. latest 1.18.4 built via cmake has this in the upnp/upnpconfig.h header:

/** The library version (string) e.g. "1.3.0" */
#undef UPNP_VERSION_STRING
#define UPNP_VERSION_STRING "1.18.4"

/** Major version of the library */
#undef UPNP_VERSION_MAJOR
#define UPNP_VERSION_MAJOR 1

/** Minor version of the library */
#undef UPNP_VERSION_MINOR
#define UPNP_VERSION_MINOR 18
#ifndef UPNP_VERSION_MINOR
#   define UPNP_VERSION_MINOR 0
#endif

/** Patch version of the library */
#undef UPNP_VERSION_PATCH
#define UPNP_VERSION_PATCH 4
#ifndef UPNP_VERSION_PATCH
#   define UPNP_VERSION_PATCH 0
#endif

/** The library version (numeric) e.g. 10300 means version 1.3.0 */
#define UPNP_VERSION \
    ((UPNP_VERSION_MAJOR * 100 + UPNP_VERSION_MINOR) * 100 + \
        UPNP_VERSION_PATCH)

which results in UPNP_VERSION=11804

@Vollstrecker
Copy link
Copy Markdown
Collaborator

So we could check and require just a recent enough version. If someone compiles amule, getting a recent libupnp shouldn't be asked too much.

@mrjimenez
Copy link
Copy Markdown
Contributor

mrjimenez commented Mar 29, 2026

@puleglot

Interesting.. Debian/Ubuntu are using a different version scheme for libupnp based on library soname.

And this is actually a difference between autotools and cmake builds of libupnp. What a mess. =( pupnp/pupnp#277

@Vollstrecker

So this one is not fixed?

This has been fixed. The const event thing was my mistake. As a result, some 1.14.x releases have a broken API.

My suggestion is to use only the last 1.14.x or 1.18.x. Otherwise you will have to figure out at what point I broke 1.14.x API and ifdef it. Not hard too, but ugly since it is not amule's fault.

@Vollstrecker

So we could check and require just a recent enough version. If someone compiles amule, getting a recent libupnp shouldn't be asked too much.

Exactly.

@puleglot
Copy link
Copy Markdown
Contributor Author

I've added a workaround for Debian/Ubuntu and co. Not an elegant solution, but should work.

@puleglot
Copy link
Copy Markdown
Contributor Author

puleglot commented Mar 29, 2026

So we could check and require just a recent enough version. If someone compiles amule, getting a recent libupnp shouldn't be asked too much.

Not everyone will like it. And this will break current CI builds.

@mrjimenez
Copy link
Copy Markdown
Contributor

mrjimenez commented Mar 29, 2026

I broke the const in the API in 1.14.26, so anything before should compile.

1.14.30 should also compile.

@Vollstrecker
Copy link
Copy Markdown
Collaborator

I guess @mrjimenez is the expert here. My solution would be to require 1.18.x on don't work around stuff. Thanks to Christian Marrilat this should be available.

@puleglot
Copy link
Copy Markdown
Contributor Author

puleglot commented Mar 29, 2026

OK. I reverted my patch to the previous version. CI build failure is expected.

@puleglot
Copy link
Copy Markdown
Contributor Author

puleglot commented Mar 29, 2026

I broke the const in the API in 1.14.26, so anything before should compile.

Yes I know this. But this is not the issue. Most distros are likely skipped this release. The issue is that Debian and Ubuntu (at least LTS) are still shipping even older libupnp where pupnp/pupnp#277 is not fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build failure with pupnp 1.18.x (API change)

4 participants