[Spice-devel] Qemu with Spice support on Windows10 host: a report
Helge Konetzka
helge at konetzka.de
Thu Mar 25 18:26:32 UTC 2021
Am 24.03.21 um 14:05 schrieb Frediano Ziglio:
> Il giorno mar 23 mar 2021 alle ore 20:33 Helge Konetzka ha scritto:
>> I deployed spice-protocol and spice-server this way:
>>
>> spice-protocol-0.14.3$ meson setup builddir
>> spice-protocol-0.14.3$ meson configure --prefix
>> /usr/x86_64-w64-mingw32/sys-root/mingw builddir
>> spice-protocol-0.14.3$ meson install -C builddir
>>
>> # Add -fstack-protector to automatically added FLAGS
>> spice-0.14.91$ export CFLAGS="-g -O2 -fstack-protector"
>> spice-0.14.91$ export CXXFLAGS="-g -O2 -fno-exceptions -fno-check-new
>> -fstack-protector"
>> # Patch to include red-common.h before jpeglib.h
>> spice-0.14.91$ patch -p1 < ../spice-0.14.3-cygwin64.patch
>> spice-0.14.91$ ./configure --host=x86_64-w64-mingw32
>> --prefix=/usr/x86_64-w64-mingw32/sys-root/mingw \
>> --without-sasl --enable-extra-checks --disable-silent-rules
> Surely you don't want --enable-extra-checks for the final product, but
> good to test with.
I must admit that I wasn't aware of the impact on the resulting libraries.
>> spice-0.14.91$ make -j4
>> spice-0.14.91$ make install
>>
>> --------------------------
>>
>> Patch is necessary, because INT32 is defined twice - in
>> /usr/x86_64-w64-mingw32/sys-root/mingw/include/basetsd.h
>> and /usr/x86_64-w64-mingw32/sys-root/mingw/include/jmorecfg.h
>>
> We use CI to check that always compile for Windows using MingW, which
> distro are you using?
Cygwin64. I had no header problems compiling because of INT32 with
Msys2. Didn't know MingW-Distribution yet.
>> $ cat spice-0.14.3-cygwin64.patch
>> diff -Naur spice-0.14.91.orig/server/jpeg-encoder.c
>> spice-0.14.91.patched/server/jpeg-encoder.c
>> --- spice-0.14.91.orig/server/jpeg-encoder.c 2020-10-26
>> 13:18:53.000000000 +0100
>> +++ spice-0.14.91.patched/server/jpeg-encoder.c 2021-03-23
>> 12:27:18.696134500 +0100
>> @@ -17,9 +17,9 @@
>> #include <config.h>
>>
>> #include <stdio.h>
>> +#include "red-common.h"
>> #include <jpeglib.h>
>>
>> -#include "red-common.h"
>> #include "jpeg-encoder.h"
>>
>> struct JpegEncoderContext {
>> diff -Naur spice-0.14.91.orig/server/mjpeg-encoder.c
>> spice-0.14.91.patched/server/mjpeg-encoder.c
>> --- spice-0.14.91.orig/server/mjpeg-encoder.c 2020-10-26
>> 13:18:53.000000000 +0100
>> +++ spice-0.14.91.patched/server/mjpeg-encoder.c 2021-03-23
>> 12:27:22.501484000 +0100
>> @@ -20,9 +20,9 @@
>> #include <stdio.h>
>> #include <inttypes.h>
>> #include <jerror.h>
>> +#include "red-common.h"
>> #include <jpeglib.h>
>>
>> -#include "red-common.h"
>> #include "video-encoder.h"
>> #include "utils.h"
>>
>> ---------------------------
> I think it would be better to move Jpeg includes at the end and add a
> comment instead.
I just wanted to drop a helpful patch, in case anyone wants to build
spice-server in cygwin64 environment.
But because cygwin64's glib package is too old to support using qemu
with spice, I guess this patch is obsolete. With Msys2 I was able to
create a working integration.
>> Additional Compiler-Flag -fstack-protector is necessary in CFLAGS and
>> CXXFLAGS to get rid of linker errors
>> see
>> https://sourceforge.net/p/mingw-w64/mailman/message/36764708/
>> https://github.com/msys2/MINGW-packages/issues/5803
>>
>> /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld:
>> ./.libs/libserver.a(sys-socket.o): in function `socket_newpair':
>> /mnt/d/Qemu/src/spice-0.14.91/server/sys-socket.c:284: undefined
>> reference to `__stack_chk_fail'
>> /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld:
>> ./.libs/libserver.a(sys-socket.o): in function `socket_win32_init':
>> /mnt/d/Qemu/src/spice-0.14.91/server/sys-socket.c:209: undefined
>> reference to `__stack_chk_fail'
>> /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld:
>> ./.libs/libserver.a(sys-socket.o):sys-socket.c:(.rdata$.refptr.__stack_chk_guard[.refptr.__stack_chk_guard]+0x0):
>> undefined reference to `__stack_chk_guard'
>> /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld:
>> ./.libs/libserver.a(tree.o):/usr/x86_64-w64-mingw32/sys-root/mingw/include/string.h:208:
>> undefined reference to `__memset_chk'
>> /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld:
>> ./.libs/libserver.a(utils.o): in function `red_dump_openssl_errors':
>> /mnt/d/Qemu/src/spice-0.14.91/server/utils.c:128: undefined reference to
>> `__stack_chk_fail'
>> /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld:
>> ./.libs/libserver.a(websocket.o): in function `websocket_read':
>> /mnt/d/Qemu/src/spice-0.14.91/server/websocket.c:447: undefined
>> reference to `__stack_chk_fail'
>> /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld:
>> ./.libs/libserver.a(websocket.o): in function `memcpy':
>> /usr/x86_64-w64-mingw32/sys-root/mingw/include/string.h:202: undefined
>> reference to `__memcpy_chk'
>> /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld:
>> ./.libs/libserver.a(websocket.o): in function `sprintf':
>> /usr/x86_64-w64-mingw32/sys-root/mingw/include/stdio.h:372: undefined
>> reference to `__chk_fail'
>> /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld:
>> ./.libs/libserver.a(websocket.o): in function `websocket_new':
>> /mnt/d/Qemu/src/spice-0.14.91/server/websocket.c:792: undefined
>> reference to `__stack_chk_fail'
>> collect2: error: ld returned 1 exit status
>> make[4]: *** [Makefile:790: libspice-server.la] Error 1
>> make[4]: Leaving directory '/cygdrive/d/Qemu/src/spice-0.14.91/server'
>> make[3]: *** [Makefile:942: all-recursive] Error 1
>> make[3]: Leaving directory '/cygdrive/d/Qemu/src/spice-0.14.91/server'
>> make[2]: *** [Makefile:704: all] Error 2
>> make[2]: Leaving directory '/cygdrive/d/Qemu/src/spice-0.14.91/server'
>> make[1]: *** [Makefile:539: all-recursive] Error 1
>> make[1]: Leaving directory '/cygdrive/d/Qemu/src/spice
> I suppose the FORTIFY definition requires -fstack-protector ito get
> the right libraries.
It turned out mandatory for successful builds in both, Cygwin64 and Msys2.
Thanks for your remarks and hints.
Helge Konetzka.
More information about the Spice-devel
mailing list