Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can gcc -o and -S be used together

Tags:

c

gcc

Can I use for example

gcc -o -S output.s abs.c

to generate an assembly file with name output.s? It seems like I can't. When I try to do that, I got following error message.

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

I do not intend to use the linker, just try to examine the assembly code.

like image 766
BVBC Avatar asked Apr 30 '15 14:04

BVBC


People also ask

Is GCC only for C?

GCC is an integrated collection of compilers for several major programming languages, which as of this writing are C, C++, Objective-C, Java, FORTRAN, and Ada.

Is G ++ and GCC the same?

“GCC” is a common shorthand term for the GNU Compiler Collection. This is both the most general name for the compiler, and the name used when the emphasis is on compiling C programs (as the abbreviation formerly stood for “GNU C Compiler”). When referring to C++ compilation, it is usual to call the compiler “G++”.

Do I need GCC for C?

Linux is a set of open-source UNIX-like operating systems, and Ubuntu is a Linux-based operating system commonly used to run Linux-based applications. To install C on Linux and to build and run our C program file on Ubuntu, we need to install the GCC Compiler.

Is GCC a compiler or interpreter?

GCC was originally written as the compiler for the GNU operating system.


1 Answers

-o must be followed by the name of the output file. So, this would work:

gcc -S abc.c -o output.s
like image 192
juanchopanza Avatar answered Oct 30 '22 17:10

juanchopanza