joerg-krause writes
Building upmpdcli aborts because of an unsafe header inclusion of /usr/include/libupnpp
. Using {prefix}
to get the header path is wrong for cross-compilation.
Instead of hard-coding the flags for libupnpp use pkg-config to get the correct ones.
Closes #45
medoc92 writes
Hi, I want to think a bit more about the pkg-config question, but I’m not sure I’ll be able to do it in the next few days.
Shouldn’t this be upnpp_CPPFLAGS here by the way ?
I wished I could just not specify the libupnpp include path and let the c files specify upnpp when including (like the the other pull request). The problem here is that there are a number of shared files, which I use with different software packages (recoll, libupnpp, upmpdcli..), but which I never made into a proper lib, I just copy them to the target project. The problem here is that one of them is expecting to include log.hxx without the libupnpp path, and I can’t change it because it can be used in other contexts where libupnpp is not there at all. I wonder if the best approach would not be to stop importing these from libupnpp and use local copies instead (not quite sure of this either, this is a vexing issue). Or move all these shared files to libupnpp. aargh.
joerg-krause writes
> I want to think a bit more about the pkg-config question, but I'm not sure I'll be able to do it in the next few days.
No problem!
> Shouldn't this be upnpp_CPPFLAGS here by the way ?
No, the PKG_CHECK_MODULES macro creates two variables <pkg >_LIBS and <pkg >_CFLAGS. I have found a short [tutorial](https://developer.gnome.org/anjuta-build-tutorial/stable/library-autotools.html.en) about this.
> The problem here is that one of them is expecting to include log.hxx without the libupnpp path, and I can't change it because it can be used in other contexts where libupnpp is not there at all.
Why not add the /usr/include/libupnpp/`path to `-I
for this specific project?
> Or move all these shared files to libupnpp.
Or move all shared parts into a separate library?
joerg-krause writes
After getting feedback on the Buildroot mailing list, I updated the commit to expand LIBS
to take upnpp_LIBS
into account to fix the static build issue.
medoc92 writes
Hi Joerg,
I’m back and trying to find a convenient fix for the include issue. One thing I’m wondering about: currently:
pkg-config --cflags libupnpp
does not add -I${includedir}/libupnpp
, and I don’t think it should. I think that pupnp/libupnp is wrong to add -I${includedir}/upnp/
, it’s better to force users to use a qualified path like #include "upnp/upnp.h"
to avoid conflicts.
So how did you solve the #include "log.h"
issue ?
joerg-krause writes
> [...] does not add `-I${includedir}/libupnpp`, and I don't think it should.
Me, too :smile:
> I think that pupnp/libupnp is wrong to add `-I${includedir}/upnp/`, it's better to force users to use a qualified path like `#include "upnp/upnp.h"` to avoid conflicts.
Me, too :smile:
> So how did you solve the #include "log.h" issue ?
By not adding -I${includedir}/libupnpp
to the include pathes and using #include "libupnpp/log.h"
all over the place.
Lets make an exception for use one project needing log.hxx without the libupnpp path and add -I${includedir}/libupnpp
to the CFLAGS for this project only.
medoc92 writes
I’ve looked into solutions using the preprocessor, but macros and includes don’t mix.
I am just going to write a small script for importing the common files into the project, and edit the include paths while doing it (resulting in #include "libupnpp/log.h" in our case). This is slightly ridiculous, but quite simple in fact, and will solve the problem effectively if not elegantly…
medoc92 writes
Finally used automake/make rules to fix the files before building. Please tell me how this works for you when you have a moment (absolutely nothing urgent).
joerg-krause writes
I’ve tested your change and it works well! Although, I would have done it the other way around: Use libupnpp/log.h
by default and adjust it, when necessary, in your other projects. Nevertheless, it works…
medoc92 writes
libupnpp/log.h by default makes no sense as log.h is imported from elsewhere. I hope that this hack does not come back to bite me from behind :)