gccx86-64

can i use "gcc -m64" instead of "x86_64-elf-gcc"


i downloaded a small project on internet, the admin of the project uses x86_64-elf-gcc, but i don't have it here, can i use gcc -m64 instead
if not what is the fastest way to install x86_64-elf-gcc, without downloading zip files
Is there an error when replacing it to gcc -m64?
note:
i am using gcc 11 \

ps: i tried gcc -64 and it gives error, how to fix it, or do i have to use cross compiler
the commands i trie:
$ gcc main.c
$ gcc -m32 main.cpp
$ gcc -m64 main.cpp


Solution

  • If your gcc -m64 makes ELF executables, not Windows COFF or MacOS Mach-O64, then yes you can use it.

    gcc -m64 foo.c && file foo.o should print

    foo.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
    

    On a normal x86-64 GNU/Linux or *BSD system, gcc is x86_64-elf-gcc. You'd normally only have it installed with that explicit name if it was a cross compiler, e.g. on a Windows system.

    But if you're on Windows with MSYS or Cygwin (not WSL), then you probably do want to install a cross-compiler, unless you only want to test locally by building Windows executables.