Last active
January 9, 2016 16:06
-
-
Save Madsy/9578867 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to cross-compile guile guile-2.0.9.241-950a-dirty or later for Windows, from a GNU Linux-distro (without thread support for now) | |
0.) If you have Wine installed, make sure it is not associated with .exe files, as it messes up | |
./configure's cross-compiler detection. Run "sudo update-binfmts --disable wine" if this is the case. | |
1.) Compile guile locally | |
2.) Cross-compile all dependencies normally, except libgc which requires special treatment. The libraries you need are the | |
versions below, or later: | |
gettext-0.18.3.1 | |
gmp-5.1.3 | |
libffi-3.0.13 | |
libiconv-1.14 | |
libintl-0.14.4-src | |
libtool-2.4-1-mingw32-src (found at http://sourceforge.net/projects/mingw/files/MinGW/Extension/libtool/libtool-2.4-1/) | |
libunistring-0.9.3 | |
readline-6.2 | |
Libtool is not required in its entirety. Only libltdl which is a part of libtool is required. | |
3.) Build libgc-7.2e. When building libgc, do *not* use ./configure. Rather, use the makefile Makefile.direct | |
To properly setup Makefile.direct for cross-builds, make sure you override CC, CXX, AS, HOSTCC, AR and RANLIB. HOSTCC is the | |
native compiler on the system, used for strapping. In CFLAGS, make sure optimizations are on. Here's an example setup for the w64-flavor of MinGW currently available | |
on Ubuntu: | |
//START OF Makefile.direct | |
AS_ABI_FLAG=$(ABI_FLAG) | |
... | |
CC=i686-w64-mingw32-gcc <-- Overridden! | |
CXX=i686-w64-mingw32-g++ <-- Overridden! | |
AS=i686-w64-mingw32-gcc-as <-- Overridden! | |
... | |
AO_SRC_DIR=$(srcdir)/libatomic_ops | |
AO_INSTALL_DIR=$(srcdir)/libatomic_ops-install | |
.. | |
CFLAGS= -O2 -I$(srcdir)/include -I$(AO_INSTALL_DIR)/include -DATOMIC_UNCOLLECTABLE -DNO_EXECUTE_PERMISSION | |
-DALL_INTERIOR_POINTERS <-- Make sure optimizations are enabled! | |
HOSTCC=gcc <-- Overridden! Different from $(CC)! | |
HOSTCFLAGS=$(CFLAGS) | |
.. | |
CXXFLAGS= $(CFLAGS) | |
AR= i686-w64-mingw32-ar <-- Overridden! | |
RANLIB= i686-w64-mingw32-ranlib <-- Overridden! | |
//END OF Makefile.direct | |
In your source directory you should now have a gc.a. Rename it to libgc.a and copy it to your $PREFIX/lib/ directory. Copy everything in ./include to $PREFIX/include/gc/ | |
4.) Now we can build guile/libguile. Use this setup, where $PREFIX is the prefix path to your library dependencies /lib and /include directories. (Don't mistake my definition of $PREFIX with ./configure's --prefix) If your MinGW compiler is different from mine, change --host accordingly: | |
GUILE_FOR_BUILD=/path/to/your/local/guile CFLAGS="-I${PREFIX}/include -DGC_NO_DLL -DGC_WIN32_THREADS" LDFLAGS="-L${PREFIX}/lib" ./configure --host=i686-w64-mingw32 --prefix=/{PREFIX}/deploy --enable-static=yes --enable-shared=no --disable-rpath --enable-debug-malloc --enable-guile-debug --disable-deprecated --with-sysroot=$PREFIX --disable-threads | |
make && make install | |
This will configure, build and install guile without threads, and libguile as a static library. The installed files are found in ./deploy under $PREFIX. To run guile under Windows, you need to set the following environment variables first: | |
set GUILE_LOAD_COMPILED_PATH=C:\guile\lib\guile\2.0\ccache;C:\guile\lib\guile\2.0\site-ccache | |
set GUILE_LOAD_PATH=C:\guile\share\guile\2.0;C:\guile\share\guile\site\2.0;C:\guile\share\guile\site ;C:\guile\share\guile | |
set GUILE_SYSTEM_EXTENSIONS_PATH=C:\guile\lib;C:\guile\lib\guile\2.0\extensions | |
C:\guile is the root directory I use on Windows (the "deploy" directory renamed to "guile"), which contains ./bin, ./include, ./lib and ./share. Change the paths accordingly if you use a different directory. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment