交叉编译Mono

来源:互联网 发布:打鸡血网络语言 编辑:程序博客网 时间:2024/06/07 01:56
1. 安装scratchbox

    (1) 添加软件源:
    
        sudo vim /etc/apt/sources.list
        
        最后一行添加
        
        deb http://scratchbox.org/debian/ stable main
    
    (2) 更新软件源
    
        sudo apt-get update
    
    (3) 安装软件包
    
        sudo apt-get install scratchbox-core scratchbox-libs scratchbox-devkit-qemu
    
        sudo apt-get install scratchbox-devkit-debian scratchbox-devkit-perl scratchbox-toolchain-arm-linux-cs2007q3-51sb3
    
        也可在http://www.scratchbox.org/download/files/sbox-releases/stable/tarball/下载其它交叉编译工具包,并
    
        cd /
        tar -zxvf [交叉编译工具包路径] ./
    
    (4) 禁止VDSO
    
        sudo vim /etc/sysctl.conf
    
    最后一行添加
    
        vm.vdso_enabled = 0
        vm.mmap_min_addr = 4096
    
        sudo sysctl -p
    
    (5) 添加scratchbox用户
    
        sudo /scratchbox/sbin/sbox_adduser XX
    
        groups命令查看是否添加进sbox组中
    
    
2. 配置scratchbox

    (1) 登陆scratchbox    
    
        /scratchbox/login
    
    (2) 配置并运行target
    
        输入sb-menu进入配置
    
        a. 选择Setup建立target
    
        b. 创建一个新target
        
        c. 输入target名称
        
        d. 选择compiler交叉编译器
        
        arm-linux-cs2007q3-51sb3
        
        e. 选择devkits开发辅助工具
        
        全选
        
        f. 选择模拟器
        
        qemu-arm-sb
        
        g. 解压rootstraps根目录
        
        将omap配套的rootfs.tar.gz拷贝到/scratchbox/packages/中
        cp ~/Omapl138kbe/rootfs/rootfs.tar.gz /scratchbox/packages/
        
        利用空格键选中rootfs.tar.gz,过程中出现错误也无妨
        
        h. Select target启动target
        
        i. 如果需要scratchbox与linux文件传输,利用/scratchbox/users/XX/home/XX用户主目录进行传输
        
3. 编译Mono

    由于Mono是由C代码和C#代码两部分构成,因此需要交叉编译arm原生代码和宿主机编译托管代码。
    
    (1) 编译托管代码
    
        mkdir mono-host
    
        cd mono-host
    
        tar zvf [mono-xx.tar.gz]
    
        ./configure
        
        make
        
        make install DESTDIR=`pwd`/tmptree
    
    (2) 交叉编译本地代码(在scratchbox的sangbox中)
    
        mkdir cross
        
        cd cross
        
        tar zvf [mono-xx.tar.gz]
    
        ./configure  --host=arm-linux --build=arm-linux --target=arm-linux --with-tls=pthread --disable-mcs-build --with-monotouch=no --without-mcs-docs --disable-mono-debugger CFLAGS=-DARM_FPU_NONE
        
        ./configure  --host=arm-linux --build=arm-linux --target=arm-linux --with-tls=pthread --disable-mcs-build CFLAGS=-DARM_FPU_NONE
        
        make
        
        make install DESTDIR=`pwd`/tmptree
        
    (3)    按顺序分别将托管代码与原生代码复制到/opt/nfs中
        
        cp -r mono-host/tmptree/* /opt/nfs/
        cp -r cross/tmptree/* /opt/nfs/
        
4. 运行控制台程序

    Windows下编译C#控制台程序,将Debug/bin/XX.exe拷贝到/opt/nfs/root/中
    
    arm-linux-mono XX.exe
    
5. 移植GUI (未完,待续)
    Mono中Windows Form API支持的是基于X11图形库的Linux,但Mono提供另外两种图形库的支持:GTK#和Winforms,此外还可以选择MonoMac、Qyoto、Qt4Dotnet以及wxNet作为图形库的支持。(http://www.mono-project.com/Gui_Toolkits)
    Omap-L138的ARM Linux是基于Qtopia图形库的Arago图形界面。
    作为嵌入式Linux,我们可以考虑移植X11,Qt-X11,GTK#,以及Qyoto。其中GTK#也是基于X11的,只有Qyoto是基于Qt的,而移植C#最主要的目的就是直接移植Windows程序到嵌入式Linux上,因此这里采用移植Qt-X11作为嵌入式Linux的GUI。
    

原创粉丝点击