gpt4 book ai didi

c - 如何安装gcc交叉编译器

转载 作者:行者123 更新时间:2023-11-30 18:06:19 25 4
gpt4 key购买 nike

我在尝试在 Linux 下安装交叉编译器时遇到困难。我下载了一个工具链,看起来没问题,但下一步是什么?我需要在控制台中输入什么命令才能安装它?

目的是将 C 代码转换为 MIPS(小端)代码。

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

第一个代码:

#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++;
}
}

}

最佳答案

您可能想尝试使用crosstool-NG为您的系统构建并安装工具链。

关于c - 如何安装gcc交叉编译器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5669948/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com