{"id":817,"date":"2022-08-30T15:07:40","date_gmt":"2022-08-30T15:07:40","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/undefined-reference-while-linking-with-a-shared-object-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:07:40","modified_gmt":"2022-08-30T15:07:40","slug":"undefined-reference-while-linking-with-a-shared-object-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/undefined-reference-while-linking-with-a-shared-object-collection-of-common-programming-errors\/","title":{"rendered":"undefined reference while linking with a shared object-Collection of common programming errors"},"content":{"rendered":"<p>Your question suffers lack of information, but I can suggest you at first try<\/p>\n<pre><code>gcc main.c .\/libfile.so -Wl,-rpath . -o test\n<\/code><\/pre>\n<p>If this will fail, you have something wrong with your sources. If everything is ok at this point, then try<\/p>\n<pre><code>gcc main.c -L . -lfile -Wl,-rpath . -o test\n<\/code><\/pre>\n<p>If this will output undefined reference, then probably you already have something like libfile.a without my_putstr(may be from previous experiments) in your lib path.<\/p>\n<p>If everything is ok with it, then your linker is sensible to order in which libraries is supplied to command string, and you must remember, then library always comes after object, that uses this library.<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-09 22:47:18. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Your question suffers lack of information, but I can suggest you at first try gcc main.c .\/libfile.so -Wl,-rpath . -o test If this will fail, you have something wrong with your sources. If everything is ok at this point, then try gcc main.c -L . -lfile -Wl,-rpath . -o test If this will output undefined [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-817","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=817"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/817\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}