step by step 用mingw 编译 xboot
1. 安装 64bit 编译工具链
sudo apt-get install mingw-w64
sudo apt-get install binutils-mingw-w64
2. 下载编译安装 libiconv:
#wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
#tar xvf libiconv-1.15.tar.gz
#cd libiconv-1.15/
#./configure --host=x86_64-w64-mingw32 --prefix=/usr/x86_64-w64-mingw32/
#make
#sudo make install
3. 下载编译libSDL2 (同上)
4. 下载xboot
#git clone https://github.com/xboot/xboot.git
5. 打补丁
# cd src/arch/x64/mach-sandbox/libsandbox/
# wget https://raw.githubusercontent.com/LuaDist/libarchive/master/libarchive/archive_windows.h
6. 修改 src/arch/x64/mach-sandbox/libsandbox/sandbox-file.c
添加
#include "archive_windows.h"
150行附件
flags = fcntl(fd, F_GETFL);
改为
flags = fcntl(fd, F_GETFL, 0);
7. 修改 src/arch/x64/mach-sandbox/libsandbox/sandbox-stdio.c
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
//#include <termios.h>
#include <sandbox.h>
//static struct termios __term_config;
void sandbox_stdio_init(void)
{
#if 0
struct termios termvi;
tcgetattr(0, &__term_config);
termvi = __term_config;
termvi.c_lflag &= (~ICANON & ~ECHO & ~ISIG);
termvi.c_iflag &= (~IXON & ~ICRNL);
termvi.c_oflag |= (ONLCR);
termvi.c_cc[VMIN] = 1;
termvi.c_cc[VTIME] = 0;
tcsetattr(0, TCSANOW, &termvi);
#endif
}
void sandbox_stdio_exit(void)
{
#if 0
fflush(stdout);
tcsetattr(0, TCSANOW, &__term_config);
#endif
}
ssize_t sandbox_stdio_read(void * buf, size_t count)
{
return 0;
#if 0
return sandbox_file_read_nonblock(fileno(stdin), buf, count);
#endif
}
ssize_t sandbox_stdio_write(void * buf, size_t count)
{
#if 0
return sandbox_file_write(fileno(stdout), buf, count);
#endif
return 0;
}
8. 开始编译
#cd xboot
#CROSS_COMPILE=x86_64-w64-mingw32- PLATFORM=sandbox make
离线
[LD] Linking ../output/xboot
*** Error in `/usr/bin/x86_64-w64-mingw32-ld': free(): invalid pointer: 0x0000000003698818 ***
collect2: error: ld terminated with signal 6 [Aborted], core dumped
make[1]: *** [../output/xboot] Error 1
make[1]: Leaving directory `/disk5/xboot/src'
make: *** [all] Error 2
只有最后一个链接问题, 解决这个问题就可以在windows跑sandbox了
离线