{"id":1122,"date":"2022-08-30T15:12:45","date_gmt":"2022-08-30T15:12:45","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/inline-methods-not-available-as-symbols-of-shared-library-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:12:45","modified_gmt":"2022-08-30T15:12:45","slug":"inline-methods-not-available-as-symbols-of-shared-library-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/inline-methods-not-available-as-symbols-of-shared-library-collection-of-common-programming-errors\/","title":{"rendered":"inline methods not available as symbols of shared library-Collection of common programming errors"},"content":{"rendered":"<p>If I have a class which will be compiled to a shared object. The class is declared in a .h file and implemented in a .cpp file.<\/p>\n<p>This class contains a couple of <strong>inline methods<\/strong>.<\/p>\n<p>If I write some program that links with this shared library and includes the .h file, I will get <em>undefined reference<\/em> errors when linking it.<\/p>\n<p>Is that because there are no symbols exported for inline methods ?<\/p>\n<p>Am I understanding this correctly ?<\/p>\n<p><strong>UPDATE:<\/strong> some example code below<\/p>\n<p>somelib.h<\/p>\n<pre><code>#ifndef __ABC_LIB_H\n#define __ABC_LIB_H\n#include \nclass ABC {\n    ABC();\n    ~ABC();\n    inline void not_callable_outside_library();\n    void callable_outside_library();\n};\n#endif\n<\/code><\/pre>\n<p>somelib.cpp<\/p>\n<pre><code>#include \"somelib.h\"\nABC::ABC() {}\nABC::~ABC() {}\nvoid ABC::not_callable_outside_library(){ std::cout<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2013-11-09 23:30:35. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>If I have a class which will be compiled to a shared object. The class is declared in a .h file and implemented in a .cpp file. This class contains a couple of inline methods. If I write some program that links with this shared library and includes the .h file, I will get 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-1122","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1122","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=1122"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1122\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}