Static and Dynamic Libraries | Set 1 – GeeksforGeeks<\/a><\/em><\/p>\n\n\ncall_lib.h\n\nint add(int a, int b);\r\n\ncall_lib.c\n#include \"call_lib.h\"\r\n\nint add(int a, int b)\r\n{\r\n\tint ret = 0;\r\n\r\n\tret = a + b;\r\n\r\n\treturn ret;\r\n}\r\n\napplication.c\n\n#include <stdio.h>\r\n#include \"call_lib.h\"\r\n\r\n#define FIRST_NUM 2\r\n#define SECOND_NUM 3\r\n\r\nint main(int argc, char *argv[])\r\n{\r\n\tprintf(\"output is %d\\n\", add(FIRST_NUM , SECOND_NUM));\r\n\r\n\treturn 0;\r\n}\r\n\nto build the library\nar rcs libcall_lib.a call_lib.o\n\nTo build the final library\ngcc -o sample -L . -I . application.c -lcall_lib\n\n<\/code><\/pre>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"
One of the task of the compiler is to invoke the linker to link the libraries to add the code to the main executable program. There are 2 types of libraries. Statically linked libraries vs Dynamically linked libraries. Statically linked libraries can be created as .a(linux) and (.lib) windows. The code and data will be […]<\/p>\n","protected":false},"author":29,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1337],"tags":[1569,1568,1567],"class_list":["post-2187","post","type-post","status-publish","format-standard","hentry","category-my-article","tag-dll","tag-dynamic-library","tag-static-library"],"_links":{"self":[{"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=\/wp\/v2\/posts\/2187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2187"}],"version-history":[{"count":3,"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=\/wp\/v2\/posts\/2187\/revisions"}],"predecessor-version":[{"id":2192,"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=\/wp\/v2\/posts\/2187\/revisions\/2192"}],"wp:attachment":[{"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2187"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}