{"id":819,"date":"2022-08-30T15:07:42","date_gmt":"2022-08-30T15:07:42","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/gcc-linking-shared-libraries-with-dependent-libraries-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:07:42","modified_gmt":"2022-08-30T15:07:42","slug":"gcc-linking-shared-libraries-with-dependent-libraries-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/gcc-linking-shared-libraries-with-dependent-libraries-collection-of-common-programming-errors\/","title":{"rendered":"gcc linking shared libraries with dependent libraries-Collection of common programming errors"},"content":{"rendered":"<p>I have a complicated project with multiple executable targets and multiple shared libraries. The shared libraries currently don&#8217;t have their dependent shared libraries linked in, and the result is that linker arguments to build the executables are hideously long and hard to maintain. I&#8217;d like to add in the dependencies so the Makefiles become much cleaner.<\/p>\n<p>I want to add the following (example):<\/p>\n<pre><code>gcc -shared -o libshared.so -lshared_dependent1 -lshared_dependent2 objfile1.o objfile2.o\n<\/code><\/pre>\n<p>Is there a way to test if all the symbols in libshared.so will resolve based on that line? Is there a way to print out if any of the shared_dependent libraries specified were unnecessary?<\/p>\n<p>Thanks in advance.<\/p>\n<ol>\n<li>\n<p>I know how to force no undefined symbols:<\/p>\n<pre><code>-Wl,--no-undefined\n<\/code><\/pre>\n<p>As autotools often complains about this missing on Windows.<\/p>\n<p>I do not know if it is possible to check if there are any unused libraries, other than leaving them out one by one.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 22:47:24. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I have a complicated project with multiple executable targets and multiple shared libraries. The shared libraries currently don&#8217;t have their dependent shared libraries linked in, and the result is that linker arguments to build the executables are hideously long and hard to maintain. I&#8217;d like to add in the dependencies so the Makefiles become much [&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-819","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/819","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=819"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/819\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}