4 4 votes Consider the following statements: S1: When you statically link a file into an executable, the contents of the file are included during link time. S2: When you link dynamically, it is only during run time when a pointer to the file which is linked in is included in the executable and then the contents of said file are loaded. Which of the above statements is/are true? Compiler Design compiler-design linker + – dd 2.2k views answer comment Share Follow Print See 1 comment 1 1 comment reply srestha commented Dec 13, 2016 reply Follow flag what is ans 0 0 replyShare Please log in or register to add a comment.
Best answer 4 4 votes Both correct S1)correct because statically linking done in compile time S2) correct, because dynamically linking done at run time.It linked the file by pointer to heap memory and we can access heap memory at runtime only. It's only include when you later run the executable that these dynamically linked files are bought in and they're only bought into the in-memory copy of the executable, not the one on disk. Statically-linked files are 'locked' to the executable at link time so they never change. A dynamically linked file referenced by an executable can change just by replacing the file on the disk. http://stackoverflow.com/questions/311882/what-do-statically-linked-and-dynamically-linked-mean srestha answered Dec 13, 2016 • selected Dec 13, 2016 by Kapil srestha comment Share Follow See all 2 Comments 2 2 Comments reply dd commented Dec 13, 2016 reply Follow flag because of this line - "it is only during run time when a pointer to the file which is linked in is included in the executable"..I guess ..(2) is wrong 0 0 replyShare reena_kandari commented Sep 17, 2017 reply Follow flag @srestha, plz explain why "Dynamic linking needs no linker"? 0 0 replyShare Please log in or register to add a comment.