List Archive
Thread
-
UWP builds,
Michał Janiszewski
(2017/11/19 09:38:46)
-
Re: UWP builds,
Thomas Klausner
(2017/11/19 09:55:28)
- Re: UWP builds, Michał Janiszewski (2017/11/20 16:21:33)
- <Possible follow-ups>
-
UWP builds,
Michał Janiszewski
(2017/11/24 11:30:25)
-
Re: UWP builds,
Thomas Klausner
(2017/11/28 16:19:02)
- Message not available
- Re: UWP builds, Michał Janiszewski (2017/11/30 22:49:14)
-
Re: UWP builds,
Thomas Klausner
(2017/11/28 16:19:02)
-
Re: UWP builds,
Thomas Klausner
(2017/11/19 09:55:28)
Message
Hi,
Sorry, I'm no Windows expert either, I barely use this system.However, I was still able to progress this a bit and identify the common causes of issues I see.
The only real error reported (so far) by compiler is clash of POSIX names (strdup should be _strdup, umask should be _umask, chmod -> _chmod, fdopen -> _fdopen). Sometimes it is a bit confusing, because MSVC reports "_strdup should be _strdup" (same name), but it turns out you include your own headers before the system ones and end up modifying their definitions.
To address some of these I modified the verbatim function names and in other parts I modified order of includes. This is a bit hacky and I have not achieved full UWP build yet, but I would like to ask you to revise your use of headers: you should not overwrite system declarations, so all the definitions in compat.h should be included after *all* the system headers. That means also transient includes.
On top of that, I've left a note about resolving static builds with vcpkg here: https://libzip.org/libzip-discuss/msg00771.html it would most kind, if you could also incorporate those suggestions.
The patch below should apply on top of 1.2.0 release, the current version in vcpkg. You can also find it on https://hastebin.com/idobicowad.patch
I'm sorry, but I can't verify the sanity of these changes at other platforms right now.
diff --git a/lib/zip_fdopen.c b/lib/zip_fdopen.c index a058f81..4871c4d 100644 --- a/lib/zip_fdopen.c +++ b/lib/zip_fdopen.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include "zipint.h" #ifdef HAVE_UNISTD_H #include <unistd.h> #endif +#include "zipint.h" + ZIP_EXTERN zip_t * zip_fdopen(int fd_orig, int _flags, int *zep) { diff --git a/lib/zip_file_set_encryption.c b/lib/zip_file_set_encryption.c index a7ed748..2513197 100644 --- a/lib/zip_file_set_encryption.c +++ b/lib/zip_file_set_encryption.c @@ -31,12 +31,12 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include "zipint.h" - #include <stdlib.h> #include <string.h> + +#include "zipint.h" + ZIP_EXTERN int zip_file_set_encryption(zip_t *za, zip_uint64_t idx, zip_uint16_t method, const char *password) { @@ -80,7 +80,7 @@ zip_file_set_encryption(zip_t *za, zip_uint64_t idx, zip_uint16_t method, const char *our_password = NULL; if (password) { - if ((our_password = strdup(password)) == NULL) { + if ((our_password = _strdup(password)) == NULL) { zip_error_set(&za->error, ZIP_ER_MEMORY, 0); return -1; } diff --git a/lib/zip_source_filep.c b/lib/zip_source_filep.c index a8a271a..fb36187 100644 --- a/lib/zip_source_filep.c +++ b/lib/zip_source_filep.c @@ -231,14 +231,14 @@ create_temp_output(struct read_file *ctx) } sprintf(temp, "%s.XXXXXX", ctx->fname); - mask = umask(_SAFE_MASK); + mask = _umask(_SAFE_MASK); if ((tfd=mkstemp(temp)) == -1) { zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); - umask(mask); + _umask(mask); free(temp); return -1; } - umask(mask); + _umask(mask); if ((tfp=fdopen(tfd, "r+b")) == NULL) { zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); @@ -294,10 +294,10 @@ read_file(void *state, void *data, zip_uint64_t len, zip_source_cmd_t cmd) zip_error_set(&ctx->error, ZIP_ER_RENAME, errno); return -1; } - mask = umask(022); - umask(mask); + mask = _umask(022); + _umask(mask); /* not much we can do if chmod fails except make the whole commit fail */ - (void)chmod(ctx->fname, 0666&~mask); + (void)_chmod(ctx->fname, 0666&~mask); free(ctx->tmpname); ctx->tmpname = NULL; return 0; diff --git a/lib/zip_source_win32a.c b/lib/zip_source_win32a.c index 85493b6..74cb3b7 100644 --- a/lib/zip_source_win32a.c +++ b/lib/zip_source_win32a.c @@ -34,8 +34,8 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <stdio.h> -#include "zipint.h" #include "zipwin32.h" +#include "zipint.h" static void * _win32_strdup_a(const void *str); static HANDLE _win32_open_a(_zip_source_win32_read_file_t *ctx); @@ -76,7 +76,7 @@ zip_source_win32a_create(const char *fname, zip_uint64_t start, zip_int64_t leng static void * _win32_strdup_a(const void *str) { - return strdup((const char *)str); + return _strdup((const char *)str); } diff --git a/lib/zipint.h b/lib/zipint.h index 2c5c6b9..b97cce2 100644 --- a/lib/zipint.h +++ b/lib/zipint.h @@ -34,14 +34,14 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <zlib.h> + #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "compat.h" -#include <zlib.h> - #ifndef _ZIP_COMPILING_DEPRECATED #define ZIP_DISABLE_DEPRECATED #endif -- 2.14.1
Best regards,
Michał.
On Sun, Nov 19, 2017 at 10:55 AM, Thomas Klausner <tk%giga.or.at@localhost> wrote:
On Sun, Nov 19, 2017 at 10:38:23AM +0100, Michał Janiszewski wrote:
> I have tried building libzip with vcpkg for Microsoft's UWP (`vcpkg install
> libzip:x86-uwp`), but it fails due to trying to use functions disabled for
> this platform: umask, _fdopen, _strdup.
> Seems to be related directly to
> https://github.com/nih-at/libzip/commit/ 315a481015df18506ba86ee74cfc55 d81b8fef0c#diff- af3b638bc2a3e6c650974192a53c72 91
> ,
We are not Windows experts.
What is your suggestion for a solution?
Thomas
--
Michal Janiszewski
Made by MHonArc.