vs2005 + DDK6001 environment matching and compilation of the whole process ZEALOT

2023-01-23   ES  

Write in the opening: detailed introduction of the use of GCC/G ++ under the one -hal linux, collect it ~~

The text starts @Assassin

  • Pre -processing (Macro replacement)
  • Compilation (generating assembly)
  • assembly (generate machine can identify the code)
  • connection (generate executable file or library file)

  • Format GCC [Options] The file to be compiled [Options] [target file]

  • Preparatory processing: head file expand, macro replacement, annotation remove
    gcc -E hello.c -o hello.i
  • compilation: C file becomes an assembly file
    gcc -S hello.i -o hello.s
  • Compilation: Turn the assembly file into a binary file
    gcc -c hello.s -o hello.o
  • Link: Combining the corresponding code in the function library into the target file
    gcc hello.o -o hello

Note:CorrespondenceCPPIn the compilation, you can replace the GCC with G ++ ~~

  • Pre -processing function mainly includes macro definition, files, conditional compilation, comments, etc.
  • Pre -processing instructions are code -based code.
  • Example: gcc –e hello.c – O hello.i
  • Options “-E”, the role of this option is to allow GCC to stop the compilation process after pre-processing.
  • Options “-O” refers to the target file, and the “. I” file is the original C original program that has been pre-processing.

  • In this stage, GCC must first check the normality of the code, whether there are grammatical errors, etc. to determine the actual work of the code. After checking, the GCC translates the code into an assembly language.
  • Users can use the “-S” option to view. This option is only compiled without assembly, and the assembly code is generated.
  • Example: GCC -S hello.i – O hello.s

    The

  • compilation phase is the “.s” file generated by the compilation stage into a target file
  • Everyone can use the option “-c” here to see that the assembly code has been converted into the binary target code of “o “
  • Example: GCC -C Hello.s – O Hello.o

  • After successful compilation, it entered the link stage.
  • Example: GCC Hello.o – O Hello

  • In our C programs, there is no functional implementation of “Printf”, and only the “stdio.h” contained in the pre -compilation is only the statement of the function, and there is no degrading function implementation. So where is it, where is it? What about the “Printf” function?

    The last answer of

  • is: The system implements these functions in the library file named libc.so.6. When there is no special specification, the GCC will go to the system’s default search path “/usr/lib” Search below, that is, the link is connected to the libc.so.6 library function, so that the function “printf” can be achieved, and this is the role of link.

  • Static library refers to adding the code of the library file to the executable file when compiling the link, so the generated files are relatively large, but the library file is no longer needed at runtime. The essence name is generally “.a”.
  • Dynamic library is the opposite. When compiling the link, the code of the library file is not added to the executable file, but the library is loaded by the runtime link file during the program execution, which can save system overhead. The general suffix of the dynamic library is “.SO”, and the libc.so.6 as mentioned earlier is the dynamic library.
    GCC uses the dynamic library by default during compilation. After completing the link, GCC can generate executable files, as shown below: GCC Hello.o – O Hello.

    The binary program generated by

  • GCC is a dynamic link, which can be verified by the file command.

  • -EOnly activate pre -processing. This does not generate files. You need to redirect it into an output file.
  • -SCompilation to the assembly language does not compile and link.
  • -cCompile to the target code.
  • -oFile output to the file.
  • -staticThis option uses a static link for the generated file.
  • -gGenerate debugging information. The GNU debugger can use this information.
  • -sharedThis option will try to use the dynamic library as much as possible, so the generating files are relatively small, but the system needs to be used by the dynamic library.
  • -O0
  • -O1
  • -O2
  • -O3Optimized options for the compiler, -O0 means that there is no optimization, -O1 is the default value, and -O3 optimization level is the highest.
  • -wNo warning information.
  • Wonly generates information that the compiler thinks it will report an error.
  • Wallgenerate all warning information.
  • -i + pathProvide the header path of the required header during compilation.

My memory skills are: when compiling the option, you can think of on the keyboardESCkey, the exit key in the upper left corner,-E,-S,-c, is it very spiritual [DOGE], and then the files generated in turn can think of the provided by you to download the Linux system.isomirror file, HHH, in turn.i—–.s—–.o. It is estimated that you will forget HH for a while and a half —–

If you have any questions, please be issues ~~, thank you Daga^_^

source

Related Posts

SQL syntax query manual

hibernate.hbm2ddl.auto node configuration

Vue music project singer page rolling and top effect

Protobuf generates the corresponding file

vs2005 + DDK6001 environment matching and compilation of the whole process ZEALOT

Random Posts

[Vulnerability Reap] Moniker disables the vulnerability | OLE logic vulnerability (CVE-2017-8570)

Apache Commons-Codec package

linux shared library: ldlibrarypath and ld.so.conf have loved the Sina blog.

Summary of the combined model of entity recognition and relationship extraction

linux process operation wakeme