1

Is there any way to run gcc with the following flags on an apple M1 chip?

gcc -m32 -o test test.c

It outputs the following error:

ld: unknown/unsupported architecture name for: -arch armv4t
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Frant
  • 5,382
  • 1
  • 16
  • 22
philipmrz
  • 31
  • 6
  • The `-m32` option is normally used for x86. If this is a reasonably portable C program you're trying to compile, just omit that option. If it's code specific to x86-32, then this becomes a very different question. – Nate Eldredge Nov 30 '21 at 02:13

2 Answers2

0

You may not run 32-bit applications on macos Catalina or newer. The oldest version of macOS supported on any Apple Silicon (M1/M2) systems is Big Sur, which is the release after Catalina.

So use of -m32 on gcc or any other compiler on macOS is a not supported. Well, I suppose you could use a cross compiler to target a different operating system than the machine you are running the compiler.

Fix:
Remove -m32 and fix any issues with the code.

James Risner
  • 5,451
  • 11
  • 25
  • 47
-1

you can try using an IDE like Xcode or CLion as a workaround while they update GCC.

Garrampa
  • 9
  • 1
  • how does that work? – philipmrz Nov 29 '21 at 13:27
  • What do you mean? – Garrampa Nov 29 '21 at 16:26
  • An IDE is a software that includes multiple tools like debugger, code editor, build automation, compiler.... You can use Xcode, CLion, Eclipse.... (Check compatible versions with Apple M1). In case you don't want to use an IDE you can try to use [clang](https://clang.llvm.org/get_started.html) compiler instead off gcc. – Garrampa Nov 29 '21 at 16:40