{"id":323,"date":"2011-01-11T10:55:03","date_gmt":"2011-01-11T15:55:03","guid":{"rendered":"http:\/\/jaewon.hwang.info\/jaewon\/?p=323"},"modified":"2011-02-08T10:26:01","modified_gmt":"2011-02-08T15:26:01","slug":"stdstringnpos-lnk2001-in-vs2010-when-inheriting-a-dll-class-from-stdstring","status":"publish","type":"post","link":"https:\/\/jaewon.hwang.info\/jaewon\/2011\/01\/stdstringnpos-lnk2001-in-vs2010-when-inheriting-a-dll-class-from-stdstring\/","title":{"rendered":"std::string::npos LNK2001 in VS2010 when inheriting a dll class from std::string"},"content":{"rendered":"<p>The following two posts are discussing how to deal with a link error you see when you try to export a string class inherited from std::string. In the second post, some workarounds are also suggested.<\/p>\n<ol>\n<li><del><a href=\"http:\/\/social.msdn.microsoft.com\/Forums\/en\/vcpluslanguage\/thread\/4238e162-21d2-46f6-a8f1-e1191cf1b200\" target=\"_blank\">http:\/\/social.msdn.microsoft.com\/Forums\/en\/vcpluslanguage\/thread\/4238e162-21d2-46f6-a8f1-e1191cf1b200<\/a><\/del> \u2192 This page suddenly disappeared. I attached here <a href=\"\/jaewon\/wp-content\/uploads\/2011\/01\/LNK2001-for-std_string_npos-error-when-inheriting-from-std_wstring.pdf\">its cache from Google<\/a>.<\/li>\n<li><a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/562448\/std-string-npos-lnk2001-when-inheriting-a-dll-class-from-std-string?wa=wsignin1.0\" target=\"_blank\">https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/562448\/std-string-npos-lnk2001-when-inheriting-a-dll-class-from-std-string?wa=wsignin1.0<\/a><\/li>\n<\/ol>\n<p><del>If those workarounds do not work for you, you can try to link your binary to old libraries. Open the <strong>General Property Page<\/strong> of the project and set <strong>Platform Toolset<\/strong> to <strong>v90<\/strong>, instead of v100.<\/del> \u2192 This works only if you installed Visual Studio 2008 as well.<\/p>\n<p>I did some more experiments and found that the order of header files in the include statements do something with this. Sometimes the error disappears by just rearranging the order of headers. If it doesn&#8217;t work, try turning off the precompiled header option in the library exporting the string class.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following two posts are discussing how to deal with a link error you see when you try to export a string class inherited from std::string. In the second post, some workarounds are also suggested. http:\/\/social.msdn.microsoft.com\/Forums\/en\/vcpluslanguage\/thread\/4238e162-21d2-46f6-a8f1-e1191cf1b200 \u2192 This page suddenly disappeared. I attached here its cache from Google. https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/562448\/std-string-npos-lnk2001-when-inheriting-a-dll-class-from-std-string?wa=wsignin1.0 If those workarounds do not work [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[28],"class_list":["post-323","post","type-post","status-publish","format-standard","hentry","category-computer","tag-visual-studio"],"_links":{"self":[{"href":"https:\/\/jaewon.hwang.info\/jaewon\/wp-json\/wp\/v2\/posts\/323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jaewon.hwang.info\/jaewon\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jaewon.hwang.info\/jaewon\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jaewon.hwang.info\/jaewon\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jaewon.hwang.info\/jaewon\/wp-json\/wp\/v2\/comments?post=323"}],"version-history":[{"count":0,"href":"https:\/\/jaewon.hwang.info\/jaewon\/wp-json\/wp\/v2\/posts\/323\/revisions"}],"wp:attachment":[{"href":"https:\/\/jaewon.hwang.info\/jaewon\/wp-json\/wp\/v2\/media?parent=323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jaewon.hwang.info\/jaewon\/wp-json\/wp\/v2\/categories?post=323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jaewon.hwang.info\/jaewon\/wp-json\/wp\/v2\/tags?post=323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}