理解Compiling and Linking in C++

  • 前言

    The compilation is the process which convert the program written in human readable language like C, C++ etc into a machine code, directly understood by the Central Processing Unit.

    There are many stages involved in creating a executable file from the source file. The stages include:

    • Preprocessing
    • Compiling
    • Linking

    This means that even if the program gets compiled, it may result in not running as errors may arise during the linking phase.

  • Preprocessing

    In this pahse the preprocessor changes the Preprocessing program according to the directives mentioned (that starts with # sign).

    The C++ preprocessor takes the program and deals with the # include directives and the resulting program is pure c++ program.

    For example, in c++ program #include<iostream> will tell the preprocessor to read all the contents of the iostream header file and include the contents into the program and generate the separate C++ program file.

    c++ supports many preprocessor directives like #include, #define, #if , #else etc.

  • Compilation

    This phase translates the program into a low level assembly level code.

    The compiler takes the preprocessed file (without any directives) and generates an object file containing assembly level code. The object file created is in the binary form.

    In the object file created, each line deacribes one low level machine level instruction.

    The conversion to assembly language is important as it is common output language for many compilers high-level languages.

  • Assembly

    There is also assembly phase which converts these object files in assmbly code into machine level instructions and the file created is a relocatable object code.

    Hence, the compilation phase generates the relocatable object program and this program can be used in different places without have to compile again.

    But you still can’t run these object files until to convert them into executable file, now here linker comes into play, which links all the object files to generate single executable file.

  • Linking

    Linking as the name suggests, refers to creation of a single execuable file from multiple object files.

    The file created after linking is ready to be loaded into memory and executed by the system.

    There is difference in linking and compilation when it comes to understanding errors. Compiler shows errors in syntax, for example semi-colon not mentioned, data type not defined etc but if there is an error that function has been defined multiple times, then this error is from linker as its indicating that two or more source code files have the same meaning and that is leading to an error.

  • References

  1. cplusplus.com
  2. How does the compilation/linking process work?
  3. COMPILER, ASSEMBLER, LINKER AND LOADER : A BRIEF STORY
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
OpenGL ES 2.0 is the industry's leading software interface and graphics library for rendering sophisticated 3D graphics on handheld and embedded devices. With OpenGL ES 2.0, the full programmability of shaders is now available on small and portable devices-including cell phones, PDAs, consoles, appliances, and vehicles. However, OpenGL ES differs significantly from OpenGL. Graphics programmers and mobile developers have had very little information about it-until now. In the OpenGL(R) ES 2.0 Programming Guide, three leading authorities on the Open GL ES 2.0 interface-including the specification's editor-provide start-to-finish guidance for maximizing the interface's value in a wide range of high-performance applications. The authors cover the entire API, including Khronos-ratified extensions. Using detailed C-based code examples, they demonstrate how to set up and program every aspect of the graphics pipeline. You'll move from introductory techniques all the way to advanced per-pixel lighting, particle systems, and performance optimization. Coverage includes: * Shaders in depth: creating shader objects, compiling shaders, checking for compile errors, attaching shader objects to program objects, and linking final program objects * The OpenGL ES Shading Language: variables, types, constructors, structures, arrays, attributes, uniforms, varyings, precision qualifiers, and invariance * Inputting geometry into the graphics pipeline, and assembling geometry into primitives * Vertex shaders, their special variables, and their use in per-vertex lighting, skinning, and other applications * Using fragment shaders-including examples of multitexturing, fog, alpha test, and user clip planes * Fragment operations: scissor test, stencil test, depth test, multisampling, blending, and dithering * Advanced rendering: per-pixel lighting with normal maps, environment mapping, particle systems, image post-processing, and projective texturing * Real-world programming challenges: platform diversity, C++ portability, OpenKODE, and platform-specific shader binaries
需要先安装Patch1。 Patch 2 for RAD Studio 10.4 now available This patch addresses a number of issues in RAD Studio 10.4, pertaining to Delphi Compiler, the RAD Studio IDE in general and the new LSP-based Code Insight in particular, plus C++ Builder Android exceptions and some debugger issues. The installation of this patch requires a prior installation of Patch #1 (separately available on GetIt and in the download portal). Installing this patch is recommended for all RAD Studio 10.4 customers. Note that this patch is fairly large to download (around 190 MB). The patch includes detailed installation instructions as part of the Readme. Please read the steps carefully (or the corresponding steps in this blog post), as the GetIt download does not install the patch automatically. You must follow the instructions in order to install. Just using GetIt is not enough. List of Customer Reported Issues Addressed in 10.4 Patch 2 RAD Studio 10.4 Patch #2 addresses the following issues reported by customer on Embarcadero Quality Portal (https://quality.embarcadero.com): RSP-29628 VCL Grids bug RSP-29560 [REGRESSION] Misalignment in TStringGrid, StretchDraw method in OnDrawCell RSP-29412 Compiler generates incorrect code for if-then RSP-29402 Delphi 10.4 TStringGrid.OnDrawCell bug RSP-29374 Wrong rect coords in TStringGridDrawCell, so image are drawn at wrong position RSP-29347 [DelphiLSP] IDE Crashes when view form as text is selected and running LSP server RSP-29310 Internal error L891 when linking because of complex types based on records with class var RSP-29299 CODEGEN bug in managed fields initialization, associated with new management operators. RSP-29271 [DelphiLSP] Code Insight adds unneeded () when changing procedures/functions RSP-29256 Compiler generates wrong code for template function RSP-29227 Incorrect property value obtained from the record RSP-29226 Access violation with working code under 10.2 RSP-29218 compiling static library under Android error E4620 processing resource .fmx -2 raised RSP-29172 Access Violation when opening License Manager RSP-29142 GoTo statements not working RSP-29136 Dialog constantly pops up during debugging RSP-29129 iOS App simply crashes with a TWebBrowser on it. RSP-29127 Compiler internal error if you ignore the result of a function that returns a generic record RSP-29124 ICE E1812 RSP-28989 License Manager has access violation error when i click on Workstation Licenses RSP-28887 Space does not finish code completion RSP-28857 Default(T) generates bad code for managed record RSP-28821 [Regression] TStringGrid.OnDrawCell parameter Rect contains wrong values RSP-28808 Project options dialog page "Delphi Compiler" is not populated when opening the dialog RSP-28796 RVO for M-records: initialisation of local variables RSP-28761 [REGRESSION] E2154 Type 'T' needs finalization - not allowed in variant record RSP-28737 Compiler error when inlining new Bit Counting Standard Functions RSP-28735 Managed Records Causing Internal Compiler Error RSP-28717 Delphi Package fails to compile RSP-28701 Bind visually on TDBGRID kills the IDE RSP-28669 [BadCG] Value M-record parameters: improper AddRefRecord RSP-28659 RVO for M-records: assignment to local variables RSP-28616 [BadCG] Operator Assign should not allow non-default calling conventions RSP-28615 [BadCG] In the absence of Initialize, finalisation is not guaranteed for local variables RSP-28552 Poor code generation for local managed record variables RSP-28499 Options - Translation tools - Font - Corrupted? RSP-28476 LSP ErrorInsight in Structure Pane only shows one keystroke after editor RSP-28400 [BadCG] Operator Assign is not always invoked for fields RSP-28372 [Regression] Bad codegen in function returning generic type RSP-27268 C++ Builder 10.3.3 Android Exceptions RSP-27251 Internal error when trying to inline with optimization on RSP-24079 Package version is broken RSP-23403 Build for linux 64 error RSP-23024 Record helper class constructor gives senseless compiler warning RSP-22318 Pointer type check missed when object field is a dynarray RSP-21554 Compiler generates incorrect code for parameterized record type RSP-21248 Const dynamic array unexpectedly contains uninitialized data RSP-20372 A generic "reference to function" will only match the first of several overloaded functions RSP-19714 Win32 compiler - Memory corruption with array helpers RSP-18241 *.c source files, added to C++ project, got added to DeploymentManager file list RSP-18148 AV in TList.Remove (64-bit compiler only)

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值