为 Windows 64 位编译一致
Compiling unison for Windows 64 bit
我按照说明使用 MSYS2 工具链编译 64 位 Unison HERE。
简单地说,步骤如下:
pacman -Sy --noconfirm base-devel git mingw-w64-x86_64-{glib2,gtk2,ocaml,toolchain}
sed -i "s/#include <gdk\/win32\/gdkwin32keys.h>/\/\/#include <gdk\/win32\/gdkwin32keys.h>/" /mingw64/include/gtk-2.0/gdk/gdkwin32.h
VERSION=2.18.5 && pushd /tmp && wget -c https://forge.ocamlcore.org/frs/download.php/1627/$VERSION.tar.gz
tar -xzvf $VERSION.tar.gz && cd lablgtk-$VERSION && ./configure --prefix=/mingw64 --disable-gtktest && make ; strip src/dlllablgtk2.dll && make opt && make old-install INSTALLDIR=/mingw64/lib/ocaml/lablgtk2/ BINDIR=/mingw64/bin/ DLLDIR=/mingw64/lib/ocaml/stublibs/
pushd /tmp && git clone --depth=1 https://github.com/bcpierce00/unison && cd unison
make windres && make src OSARCH=win32gnuc
编译过早结束,出现错误:
ocamlopt: lwt/lwt_unix_stubs.c ---> lwt/lwt_unix_stubs.o
ocamlopt -g -I lwt -I ubase -I system -I fsmonitor -I fsmonitor/linux -I fsmonitor/windows -I system/win -I lwt/win -ccopt "-o "./lwt/lwt_unix_stubs.o -c ./lwt/lwt_unix_stubs.c
In file included from ./lwt/lwt_unix_stubs.c:8:0:
./lwt/lwt_unix_stubs.c: In function 'invoke_completion_callback':
C:\MSYS64\mingw64\lib\ocaml/caml/memory.h:236:12: error: 'caml__frame' undeclared (first use in this function)
(void) caml__frame, \
^
C:\MSYS64\mingw64\lib\ocaml/caml/memory.h:236:12: note: in definition of macro 'CAMLxparam2'
(void) caml__frame, \
^~~~~~~~~~~
./lwt/lwt_unix_stubs.c:82:3: note: in expansion of macro 'CAMLlocal2'
CAMLlocal2 (err, name);
^
C:\MSYS64\mingw64\lib\ocaml/caml/memory.h:236:12: note: each undeclared identifier is reported only once for each function it appears in
(void) caml__frame, \
^
C:\MSYS64\mingw64\lib\ocaml/caml/memory.h:236:12: note: in definition of macro 'CAMLxparam2'
(void) caml__frame, \
^~~~~~~~~~~
./lwt/lwt_unix_stubs.c:82:3: note: in expansion of macro 'CAMLlocal2'
CAMLlocal2 (err, name);
^
make[1]: *** [Makefile.OCaml:434: lwt/lwt_unix_stubs.o] Error 2
make[1]: Leaving directory '/tmp/unison/src'
make: *** [Makefile:14: src] Error 2
不太确定哪里出了问题,有什么帮助吗?
这里是文章的原始海报...
我终于成功地用 OCaml 重现了这个问题 - 当前版本的 Unison 没有严格遵循 OCaml 接口指南,可以在 http://caml.inria.fr/pub/docs/manual-ocaml-4.04/intfc.html
找到
相关文字:"In particular, CAMLlocal and CAMLxparam can only be called after CAMLparam"。因此,只需调用 CAMLparam(0)
即可解决问题:
--- a/src/lwt/lwt_unix_stubs.c
+++ b/src/lwt/lwt_unix_stubs.c
@@ -79,6 +79,7 @@
static void invoke_completion_callback
(long id, long len, long errCode, long action) {
+ CAMLparam0();
CAMLlocal2 (err, name);
value args[4];
err = Val_long(0);
我更新了 https://www.onwebsecurity.com/configuration/its-about-the-journey-compiling-64-bit-unison-gtk2-on-windows.html 上的文章以包含此补丁,并将其向上游发送给 Unison 维护者。
我按照说明使用 MSYS2 工具链编译 64 位 Unison HERE。
简单地说,步骤如下:
pacman -Sy --noconfirm base-devel git mingw-w64-x86_64-{glib2,gtk2,ocaml,toolchain}
sed -i "s/#include <gdk\/win32\/gdkwin32keys.h>/\/\/#include <gdk\/win32\/gdkwin32keys.h>/" /mingw64/include/gtk-2.0/gdk/gdkwin32.h
VERSION=2.18.5 && pushd /tmp && wget -c https://forge.ocamlcore.org/frs/download.php/1627/$VERSION.tar.gz
tar -xzvf $VERSION.tar.gz && cd lablgtk-$VERSION && ./configure --prefix=/mingw64 --disable-gtktest && make ; strip src/dlllablgtk2.dll && make opt && make old-install INSTALLDIR=/mingw64/lib/ocaml/lablgtk2/ BINDIR=/mingw64/bin/ DLLDIR=/mingw64/lib/ocaml/stublibs/
pushd /tmp && git clone --depth=1 https://github.com/bcpierce00/unison && cd unison
make windres && make src OSARCH=win32gnuc
编译过早结束,出现错误:
ocamlopt: lwt/lwt_unix_stubs.c ---> lwt/lwt_unix_stubs.o
ocamlopt -g -I lwt -I ubase -I system -I fsmonitor -I fsmonitor/linux -I fsmonitor/windows -I system/win -I lwt/win -ccopt "-o "./lwt/lwt_unix_stubs.o -c ./lwt/lwt_unix_stubs.c
In file included from ./lwt/lwt_unix_stubs.c:8:0:
./lwt/lwt_unix_stubs.c: In function 'invoke_completion_callback':
C:\MSYS64\mingw64\lib\ocaml/caml/memory.h:236:12: error: 'caml__frame' undeclared (first use in this function)
(void) caml__frame, \
^
C:\MSYS64\mingw64\lib\ocaml/caml/memory.h:236:12: note: in definition of macro 'CAMLxparam2'
(void) caml__frame, \
^~~~~~~~~~~
./lwt/lwt_unix_stubs.c:82:3: note: in expansion of macro 'CAMLlocal2'
CAMLlocal2 (err, name);
^
C:\MSYS64\mingw64\lib\ocaml/caml/memory.h:236:12: note: each undeclared identifier is reported only once for each function it appears in
(void) caml__frame, \
^
C:\MSYS64\mingw64\lib\ocaml/caml/memory.h:236:12: note: in definition of macro 'CAMLxparam2'
(void) caml__frame, \
^~~~~~~~~~~
./lwt/lwt_unix_stubs.c:82:3: note: in expansion of macro 'CAMLlocal2'
CAMLlocal2 (err, name);
^
make[1]: *** [Makefile.OCaml:434: lwt/lwt_unix_stubs.o] Error 2
make[1]: Leaving directory '/tmp/unison/src'
make: *** [Makefile:14: src] Error 2
不太确定哪里出了问题,有什么帮助吗?
这里是文章的原始海报...
我终于成功地用 OCaml 重现了这个问题 - 当前版本的 Unison 没有严格遵循 OCaml 接口指南,可以在 http://caml.inria.fr/pub/docs/manual-ocaml-4.04/intfc.html
找到相关文字:"In particular, CAMLlocal and CAMLxparam can only be called after CAMLparam"。因此,只需调用 CAMLparam(0)
即可解决问题:
--- a/src/lwt/lwt_unix_stubs.c
+++ b/src/lwt/lwt_unix_stubs.c
@@ -79,6 +79,7 @@
static void invoke_completion_callback
(long id, long len, long errCode, long action) {
+ CAMLparam0();
CAMLlocal2 (err, name);
value args[4];
err = Val_long(0);
我更新了 https://www.onwebsecurity.com/configuration/its-about-the-journey-compiling-64-bit-unison-gtk2-on-windows.html 上的文章以包含此补丁,并将其向上游发送给 Unison 维护者。