如何安装gcc交叉编译器 [英] How to install gcc cross compiler

查看:225
本文介绍了如何安装gcc交叉编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在Linux下安装交叉编译器时遇到困难. 我下载了似乎还可以的工具链,但下一步是什么?我需要在控制台中键入什么命令才能进行安装?

I'm having difficult while trying to install a cross compiler under linux. I downloaded a toolchain that seems to be ok but what's next ? what orders I need to type in the console to make it to be installed ?

目的是将C代码转换为MIPS(小尾数)代码.

The purpose is to convert a C code to MIPS (little endian) code.

实际上我只需要2个代码一次,所以如果有人只能在MIPS中向我显示这些代码,我会很高兴...

Actually I need it once for only 2 codes, so if someone can only show me those codes in MIPS, I will be more than happy...

第一个代码:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SIZE 128

int main ()

{
    char mychar , string [SIZE];
    int i;
    int count =0 ;  

    printf ("Please enter your string: \n\n");
    fgets (string, SIZE, stdin);

    printf ("Please enter char to find: ");
    mychar = getchar();

    for (i=0 ; string[i] != '\0' ; i++ )
        if ( string[i]  == mychar )
            count++;

    printf ("The char %c appears %d times\n" ,mychar ,count);


    return 0;
}

第二个代码:

#include <stdio.h>
#include <string.h>

void SIFT(int x_arr[ ], int y_arr[]);

int main ()
{
    int x[20] = {0} , y[20] = {0};
    int m=0,temp=0,curr=0,i=0,j=0;

    printf("Please enter your numbers now:\n\n");

    /*enter numbers one by one. if x[i+1] value < x[i] value, err msg.
      when user want to end the series he must enter '0' which means end of string (it wont       included in x[]) */
    while ( (scanf("%d",&temp) ) != 5 )
    {
        if (temp >= curr)
        {
            x[i] = temp;
            curr = temp;
            i++;
        }
        else
        {
            printf("The numbers are not at the right order !\n\nProgram will now terminate...\n\n");
        }
    }

    SIFT(x,y);

    for (i=0 ; y[i]=='0' ; i++) /*strlen(y) without ('0')'s includes*/
        m++;

    /*Prints  m , y's organs*/
    printf("\n\nm = %d",m);
    printf("Y = ");
    while (y[j]!='0')
    {
        printf ("%d ,",y[j]);
        j++;
    }

return 0;
}

void SIFT(int x_arr[ ], int y_arr[])
{
    int i=0,j=0;

    while (x_arr[i] != '0')
    {
        if (x_arr[i] == x_arr[i+1]) /*if current val. equals next val. -> jump dbl at x_arr*/
        {
            y_arr[j] = x_arr[i];
            i+=2;
            j++;
        }
        else
        {
            y_arr[j]=x_arr[i];
            i++;
            j++;
        }
    }    

}

推荐答案

您需要使用工具链来构建自己的版本-它本身不是一个编译器,它将生成一个.请查看 http://www.kegel.com/crosstool/crosstool -0.43/doc/crosstool-howto.html

you need to build you own version with toolchain - it is not a compiler on it's own, it will make one. look at http://www.kegel.com/crosstool/crosstool-0.43/doc/crosstool-howto.html

这篇关于如何安装gcc交叉编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆