【问题标题】:Error in Vs code Insider 'undefined symbol for architecture arm64'Vs 代码内部错误“架构 arm64 的未定义符号”
【发布时间】:2021-09-21 06:25:00
【问题描述】:

我只是在 CPP 中的 Mac m1 上运行一个基本程序。这是代码:

#include <stdio.h>
int main({
int i, n, num, pos, arr[10];
printf("\n Enter the number of elements in the array");
scanf("%d", &n);
printf("\n arr[%d] = ", I);
scanf("%d", &arr[i]);}
printf("\n Enter the number to be inserted : ");
scanf("%d", &num);
printf("\n Enter the position at which the number has to be added : ");
scanf("%d", &pos);
for(i=n-1;i>=pos;i--)
arr[i+1] = arr[i];
arr[pos] = num;
n = n+1;
printf("\n The array after insertion of %d is : ",num);
for(i=0;i<n;i++)
printf("\n arr[%d] =%d", i, arr[i]);}

每次运行此代码时都会出现此错误:

[Running] cd "/Users/siddhpurohit/Documents/vs code/DSU/" && gcc Exp1.c -o Exp1 && "/Users/siddhpurohit/Documents/vs code/DSU/"Exp1
Undefined symbols for architecture arm64:


"_main", referenced from:
 implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

[Done] exited with code=1 in 0.227 seconds

如果您知道如何纠正此错误,请告诉我。我是新手,对编码了解不多……但我希望学习。

【问题讨论】:

  • int main({??这真的是你的代码的样子吗?应该是int main(int argc, char **argv) { ...}int main(void) { .. }
  • AFAIK 在 gcc 中还没有对 M1 arm 构建的官方支持。这里有工作正在进行中:github.com/iains/gcc-darwin-arm64。您也许可以使用 Rosetta 运行 x86 二进制文件,但我不是这方面的专家,因此无法提供有关这些方面的任何进一步信息。
  • 请缩进你的代码

标签: arrays c visual-studio-code


【解决方案1】:
#include<stdio.h>
int main(){
int i,n,num,pos,arr[10];
printf("\n enter the number of elements in the array");
scanf("%d",&n);
printf("\n arr[%d] = ",i);
printf("\n enter the number to be inserted: ");
scanf("%d",&num);
printf("\n enter the position at which the number has to be added :");
scanf("%d",&pos);
for(i=n-1;i>=pos;i--)
arr[i+1]=arr[i];
arr[pos]=num;
n=n+1;
printf("\n the array after insertion of %d is : ",num);
for(i=0;i<n;i++)
printf("\n arr[%d] =%d",i,arr[i]);}

【讨论】:

  • 现在这个可以正常工作了
  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 2015-11-18
  • 2014-01-22
  • 2016-09-08
  • 1970-01-01
  • 1970-01-01
  • 2013-10-13
相关资源
最近更新 更多