Skip to content

Fix build with libupnp 1.18 - #432

Closed
puleglot wants to merge 1 commit into
amule-project:masterfrom
puleglot:libupnp-1.18
Closed

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

Conversation

@puleglot

@puleglot puleglot commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #431

@sc0w

sc0w commented Mar 29, 2026

Copy link
Copy Markdown
Member

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

puleglot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor Author

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

puleglot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor Author

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

mrjimenez commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

@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

puleglot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor Author

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

mrjimenez commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

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

puleglot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor Author

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

@puleglot

puleglot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor Author

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.

got3nks added a commit to got3nks/amule that referenced this pull request Apr 9, 2026
Some distro packages (observed on Ubuntu 25.10 with libupnp-dev 1.14.24)
ship a UPNP.cmake that lists non-existent paths (/usr/COMPONENT,
/usr/UPNP_Development) in INTERFACE_INCLUDE_DIRECTORIES, causing CMake
to abort at generation time:

  CMake Error: Imported target "UPNP::Shared" includes non-existent
  path "/usr/COMPONENT" in its INTERFACE_INCLUDE_DIRECTORIES.

This is a packaging bug unrelated to the callback signature issue
discussed in amule-project#432. Work around it by inspecting the UPNP targets file
before loading it, and falling back to pkg-config if the broken path
pattern is detected. pkg-config correctly finds libupnp on all affected
systems.
@got3nks

got3nks commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Ran into a separate but related issue on Ubuntu 25.10 with libupnp 1.14.24: the distro's UPNP.cmake config file includes non-existent paths (/usr/COMPONENT, /usr/UPNP_Development) in INTERFACE_INCLUDE_DIRECTORIES, causing CMake to abort at generation time with:

CMake Error: Imported target "UPNP::Shared" includes non-existent path "/usr/COMPONENT"

This is a packaging bug independent of the callback signature issue being fixed here. Just opened #439 with a workaround that detects the broken config before loading it and falls back to pkg-config, which works correctly on all affected systems.

mrjimenez pushed a commit that referenced this pull request Apr 9, 2026
Some distro packages (observed on Ubuntu 25.10 with libupnp-dev 1.14.24)
ship a UPNP.cmake that lists non-existent paths (/usr/COMPONENT,
/usr/UPNP_Development) in INTERFACE_INCLUDE_DIRECTORIES, causing CMake
to abort at generation time:

  CMake Error: Imported target "UPNP::Shared" includes non-existent
  path "/usr/COMPONENT" in its INTERFACE_INCLUDE_DIRECTORIES.

This is a packaging bug unrelated to the callback signature issue
discussed in #432. Work around it by inspecting the UPNP targets file
before loading it, and falling back to pkg-config if the broken path
pattern is detected. pkg-config correctly finds libupnp on all affected
systems.
@mrjimenez

Copy link
Copy Markdown
Contributor

@got3nks , try to push a trivial change to the PR, to trigger a new CI test. When I do it locally, it compiles, but when GitHub does it, it seems like it does on a previous version.

@got3nks

got3nks commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

@mrjimenez did you mean to tag the PR author @puleglot ?

@mrjimenez

Copy link
Copy Markdown
Contributor

@mrjimenez did you mean to tag the PR author @puleglot ?

Sorry, I meant @puleglot :D

@puleglot

puleglot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

@got3nks , try to push a trivial change to the PR, to trigger a new CI test. When I do it locally, it compiles, but when GitHub does it, it seems like it does on a previous version.

CI is using ubuntu-latest image, which is 24.04
https://github.com/actions/runner-images

@mrjimenez

Copy link
Copy Markdown
Contributor
config.status: executing denoiser commands
  Configure script has finished system check.
  Configured aMule SVN (rev. g8e9c518) for 'x86_64-pc-linux-gnu'.
  aMule enabled options:
  **** aMule Core ****
  Prefix where aMule should be installed?                    /usr/local
  Should aMule be compiled with i18n support?                yes
  Should aMule be compiled in debug mode?                    yes
  Should aMule be compiled with profiling?                   no
  Should aMule be compiled with optimizations?               no
  Should aMule be compiled with UPnP support?                yes
  Should aMule be compiled with IP2country support?          yes
  Should aMule monolithic application be built?              yes
  Should aMule daemon version be built?                      yes
  Should aMule remote gui be built?                          yes
  **** aMule TextClient ****
  Should aMule Command Line Client be built?                 yes
  **** aMule WebServer ****
  Should aMule WebServer be built?                           yes
  **** aMule ED2K Links Handler ****
  Should aMule ED2K Links Handler be built?                  yes
  **** aMuleLinkCreator ****
  Should aMuleLinkCreator GUI version (alc) be built?        yes
  Should aMuleLinkCreator for console (alcc) be built?       yes
  **** aMule Statistics ****
  Should C aMule Statistics (CAS) be built?                  yes
  Should aMule GUI Statistics (wxCas) be built?              yes
  Should xas XChat2 plugin be installed?                     no
  Should plasmaMule plasma-applet be built?                  no
  **** General Libraries and Tools ****
  Should ccache support be enabled?                          no
  Should aMule file viewer for console be built?             no
  Libraries aMule will use to build:
                             wxWidgets             3.2.4 (gtk3,shared)
                             boost                 Not detected
                             crypto++              8.9 (in /usr)
                             libupnp               1.14.18
                             libintl               system
                             libGeoIP              system
                             libpng                1.6.43
                             libgd                 2.3.3
                             zlib                  1.3
 *** Warnings during configuration ***
* Boost support has been disabled because of insufficient Boost version.

libupnp is 1.14.18

Somehow the test is faling.

g++  -I. -I..  -D__DEBUG__ -DUSE_WX_EXTENSIONS -I/usr/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-3.2 -I/usr/include/wx-3.2 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -DwxUSE_GUI=0 -I./libs -I./include  -I/usr/include/upnp  -DENABLE_UPNP=1  -g -W -Wall -Wshadow -Wundef -ggdb -fno-inline -fmessage-length=0  -MT libmuleappcore_a-UPnPBase.o -MD -MP -MF .deps/libmuleappcore_a-UPnPBase.Tpo -c -o libmuleappcore_a-UPnPBase.o `test -f 'UPnPBase.cpp' || echo './'`UPnPBase.cpp
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),
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[3]: *** [Makefile:1824: libmuleappcore_a-UPnPBase.o] Error 1
make[3]: Leaving directory '/home/runner/work/amule/amule/src'
make[2]: *** [Makefile:3102: all-recursive] Error 1
make[2]: Leaving directory '/home/runner/work/amule/amule/src'
make[1]: *** [Makefile:613: all-recursive] Error 1
make[1]: Leaving directory '/home/runner/work/amule/amule'
make: *** [Makefile:502: all] Error 2
Error: Process completed with exit code 2.```

@mrjimenez

Copy link
Copy Markdown
Contributor

There should be a test for versions between 1.14.26 until 1.14.30, and a test for versions 1.14.25 and before.

release characteristic
before and equal to 1.14.25 has const
from 1.14.26 to 1.14.29 no const
from 1.14.30 on has const
branch 1.18.x no const

In other words, 1.14.26 to 1.14.29 are API broken.

@mrjimenez

Copy link
Copy Markdown
Contributor

@puleglot , change your patch to the one I have attached here and force push. I am not a maintainer, so I cannot push to the PR.
0001-Fix-build-with-libupnp-1.18.patch

@mrjimenez

Copy link
Copy Markdown
Contributor

Nevermind, it did not work on Ubuntu. A reinterpret_cast may put an end to this madness.

@mrjimenez

Copy link
Copy Markdown
Contributor
g++  -I. -I..  -D__DEBUG__ -DUSE_WX_EXTENSIONS -I/usr/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-3.2 -I/usr/include/wx-3.2 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -DwxUSE_GUI=0 -I./libs -I./include  -I/usr/include/upnp  -DENABLE_UPNP=1  -g -W -Wall -Wshadow -Wundef -ggdb -fno-inline -fmessage-length=0  -MT libmuleappcore_a-UPnPBase.o -MD -MP -MF .deps/libmuleappcore_a-UPnPBase.Tpo -c -o libmuleappcore_a-UPnPBase.o `test -f 'UPnPBase.cpp' || echo './'`UPnPBase.cpp
UPnPBase.cpp:48:2: error: #error UPNP_VERSION is set to: STR(UPNP_VERSION)
   48 | #error UPNP_VERSION is set to: STR(UPNP_VERSION)
      |  ^~~~~
UPnPBase.cpp:47:53: note: ‘#pragma message: UPNP_VERSION is: ( (17 * 10000) + (1 * 100) + (9))’

Cmake version numbers are broken for this version of PUPnP.

@puleglot

Copy link
Copy Markdown
Contributor Author

mrjimenez thank you. I've already mentioned an issue with PUPnP version in Ubuntu/Debian and got mixed signals about whether or not it should be worked around. :) Glad it's finally resolved.

@puleglot
puleglot deleted the libupnp-1.18 branch June 16, 2026 14:54
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)

5 participants