What does gcc -E mean? [duplicate] - c

This question already has answers here:
Preprocessor output
(6 answers)
Closed 5 years ago.
I came across this option of -E while navigating and searching for where the file descriptors of stdio.h is stored in the machine? But I am not sure what exactly this command gcc -E do? Can it be used to view the file descriptor of the stdio.h fie stored in /usr/include/ directory?

It tells GCC to stop after the preprocessing stage. Details in the link.
https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#Overall-Options

It will show the output the compiler produces after expanding all macros.

Related

how to compile a program with a given file.a [duplicate]

This question already has answers here:
CMake link to external library
(6 answers)
Closed 1 year ago.
I did a program that need some functions from a file that the staff gives us.
the file is libmap.a.
I developed some modules that use functions from the libmap file.
how can I compile it?
Some friends said me that I need to change something to the Cmake file.
is someone know what I need to change?
You do not compile, only link with the library file.
for gcc you need to use -l option in your case -lmap and if needed set the path using -L option.
in Cmake you need to set your library search path:
LINK_DIRECTORIES(your_target "directory")
and the add the library
TARGET_LINK_LIBRARIES(your_target map)

How to access all the files before compilation? [duplicate]

This question already has an answer here:
How do I save preprocessor output using the Dev-C++ IDE?
(1 answer)
Closed 2 years ago.
There are several steps involved from the stage of writing a C program to the stage of getting it executed.
when I compile the code I only get an .exe file. But I want to get all the files which are being made before the compilation (preprocess ones), an intermediate code file
where all those macros with are replaced with their actual values and preprocessor are replaced with their actual header files.
in general can we get all those files (preprocess one, compile one and linker one) separately?
To access all the intermediate files use the command (Ubuntu):
gcc –Wall –save-temps filename.c –o filename. This command generates all the intermediate files in current working directory.

What are .o files and to open them on windows? [duplicate]

This question already has answers here:
What's an object file in C?
(5 answers)
Closed 3 years ago.
I'm a beginner in programming, I wonder what is inside the .o files and want to see it, but can't open the files in windows because they give some output with unrecognized symbols. Please suggest something !
They are object files, produced by the compiler, which the linker will combine into an executable.
They are not intended to be human readable.

assembly-c from windows 10 command prompt [duplicate]

This question already has answers here:
How do you get assembler output from C/C++ source in GCC?
(17 answers)
How to remove "noise" from GCC/clang assembly output?
(3 answers)
Closed 4 years ago.
I'm trying learning assembly language and i need to know how to read the assembly varsion of a c program from the windows 10 command prompt.
I've tried using C:\users\prete\Desktop\booksrc$ gcc -g firstprog.c but it doesn't work
please help me
thank you!
I am not sure about windows, but as far as I know, the assembly output is gained by the -S option for gcc.
Try gcc -S firstprog.c
The output will be firstprog.s in AT&T syntax. If you want it in the intel syntax (might be rather helpful if you use NASM/MASM/YASM and such for assembling), try:
gcc -S -masm=intel firstprog.c

fatal error: sndfile.h.in: No such file or directory [duplicate]

This question already has answers here:
What mean file with extension "h.in"?
(3 answers)
Closed 8 years ago.
I was compiling with gcc on Linux
Because sndfile.h was not there but sndfile.h.in was found, I just tried with sndfile.h.in - which is in the same directory as the *.C file.
But I got the error even though it is in the same directory. Its been a while since I programmed in Linux that these little things are bothering me - appreciate if u could help me started. Thanks
I think you are using the angular brackets for the including the file.If you place < >. It will search in /usr/include. You have to use the double quotes for including the file in the current directory. And be sure that file is available.
Like this.
#include "sndfile.h.in"

Resources