0

When we build a project/solution in VS, WKT the code first compiles & then linking takes place.

I would like to clearly understand in a great depth, that what exactly happens during the linking phase when you compile the code using VS C++ compiler.

Fixing compilation errors are very easy, just remove the syntax errors & you will be done. But the linker errors do create a lot of mess at times because, of lack of knowledge in this area of linking.

Once we know this process of linking in complete depth, it's easy to fight with the very common troublesome errors related to linking.

Few specific questions:

1) How does the linking actually takes place?
2) What all does the linking process need? A *.lib file and a header file ? If yes, can you pleas explain in detail how is this done?

And after having understood the above facts, it would be very easy to figure out solutions to linking problems like below..

error LNK2001: unresolved external symbol "public: long __thiscall
codeLover
  • 3,720
  • 10
  • 65
  • 121
  • The linking process does not need a header file. Header files are used in compilation only. – john Sep 20 '13 at 14:11
  • What @john says, and have a look at this question: http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix – us2012 Sep 20 '13 at 14:12
  • Conceptually linking is very simple. Your program defines a number of symbols (e.g. a function), and it references a number of symbols (e.g. it calls a function). All that is required is that for each symbol referenced there must be exactly one definition. Achieving that is more difficult, but it's not really a matter of undersanding the linking process (which varies in any case for each different platform) but understanding the C++ language. – john Sep 20 '13 at 14:18

0 Answers0