wget2 icon indicating copy to clipboard operation
wget2 copied to clipboard

Add config.h/libgnu to all example compiles for gnulib

Open mitchcapper opened this issue 2 years ago • 6 comments

in #280 you mentioned these additions be gated to _WIN32 but I haven't quite done so. Mainly because if you include a gnulib header accidentally you can end up getting the config.h missing error and/or need the libgnu library itself to avoid symbol issues. I assume the issue isn't the minor overhead as much as having a clearer sample for others? With this the code on the primary case base and example code base should behave the same without one might notice differences.

If you want to confirm the preference for these additions to be WIN32 only I will get the conditionals added to the makefile.

mitchcapper avatar Jul 28 '23 22:07 mitchcapper

The examples should be absolutely independent of gnulib. They should only depend on libwget and libc (or maybe some other external libraries).

They serve as an example on how to use libwget in other projects. gnulib is internal to libwget, wget2 and the tests.

rockdaboot avatar Jul 29 '23 11:07 rockdaboot

no problem will update.

mitchcapper avatar Jul 29 '23 21:07 mitchcapper

Done. Conditioned on MSVC as that is when one would not have unistd.h without gnulib.

mitchcapper avatar Aug 14 '23 11:08 mitchcapper

IMO, this is the wrong approach. Now, building the examples do not only require libwget but also libgnu. And the latter is not available to tool developers outside the wget2 project.

On MinGW64 (and on Linux), the needed gnulib code is included in libwget, so no extra library is needed. Also, config.h is not needed.

To me it looks like the library builds are broken when using MSVC. Do you have any idea how to solve this?

rockdaboot avatar Aug 15 '23 20:08 rockdaboot

No problem, let me look at the examples. It immediately failed as https://github.com/rockdaboot/wget2/blob/14d0460597ab98a519af5396d91bb430256023e6/examples/print_css_urls.c#L31 and unistd doesn't exist in windows. My immediate approach to any compat is throw gnulib at it, but your point is right the examples we provide shouldn't require it. If I can just get the headers out of the way that are problematic I will do that, if the functions required are minor ill see about just adding windows shims for it, or if worse case can always disable the ones that wouldn't work on win32 without gnulib if another solution doesn't.

mitchcapper avatar Aug 15 '23 20:08 mitchcapper

:+1: Sounds good to me.

rockdaboot avatar Aug 15 '23 20:08 rockdaboot