Boost C++ Libraries: Ticket #1904: undefined reference to `boost::program_options::options_description::m_default_line_length' https://svn.boost.org/trac10/ticket/1904 <p> If one uses the boost_program_options, one gets a linker error: undefined reference to `boost::program_options::options_description::m_default_line_length' </p> <p> Cause: boost/program_options/options_description.hpp, line 158 </p> <p> Currently: </p> <blockquote> <p> static const unsigned m_default_line_length; </p> </blockquote> <p> Should be: </p> <blockquote> <p> static const unsigned m_default_line_length = 80; </p> </blockquote> <p> The constant without assigneed value seems to become optimized out by the compiler. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1904 Trac 1.4.3 Vladimir Prus Sat, 17 May 2008 06:18:38 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/1904#comment:1 https://svn.boost.org/trac10/ticket/1904#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> The current behaviour is as designed -- options_description.hpp declares m_default_line_length. options_description.cpp has the definition. The error most likely means that you did not link your application to the program_options library. </p> Ticket Mon, 03 Nov 2008 14:20:34 GMT milestone deleted https://svn.boost.org/trac10/ticket/1904#comment:2 https://svn.boost.org/trac10/ticket/1904#comment:2 <ul> <li><strong>milestone</strong> <span class="trac-field-deleted">Boost 1.35.1</span> </li> </ul> <p> Milestone Boost 1.35.1 deleted </p> Ticket patbob@… Mon, 17 Nov 2008 19:59:58 GMT <link>https://svn.boost.org/trac10/ticket/1904#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1904#comment:3</guid> <description> <p> I get this bug on Windows (VC++ 7.0 (2005)), boost 1.37.0. I am linking with program_options library. Perhaps this global is getting defined in some random boost library, but it certainly isn't in program_options lib where it belongs. </p> <p> The value is declared, but not defined.. at least, not in the program_options library where it belongs. </p> <p> If you get this error, provide an explicit line length to the options_description constructor so it doesn't try to use m_default_line_length. Like this: </p> <p> po::options_description desc("Options", 1024); </p> <p> I'm leaving this bug closed since it probably isn't a proiblem for most users... just windows users :) </p> </description> <category>Ticket</category> </item> <item> <author>patbob@…</author> <pubDate>Mon, 17 Nov 2008 21:54:40 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1904#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1904#comment:4</guid> <description> <p> Problem "solved" -- for me, this issue was related to bug <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2506" title="#2506: Bugs: program_options::arg undefined. Win DLL (closed: fixed)">#2506</a> (program_options::arg undefined. Win DLL). </p> <p> Need to define BOOST_PROGRAM_OPTIONS_DYN_LINK when using program options on windows in a DLL. </p> </description> <category>Ticket</category> </item> <item> <author>okobyzev@…</author> <pubDate>Wed, 11 Jan 2012 12:42:41 GMT</pubDate> <title>milestone set https://svn.boost.org/trac10/ticket/1904#comment:5 https://svn.boost.org/trac10/ticket/1904#comment:5 <ul> <li><strong>milestone</strong> → <span class="trac-field-new">To Be Determined</span> </li> </ul> <p> it does not work on fresh GCC compilers also gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.6/lto-wrapper Target: x86_64-suse-linux </p> <blockquote> <p> so I think it need to be fixed </p> </blockquote> Ticket anonymous Thu, 02 Feb 2012 15:16:37 GMT <link>https://svn.boost.org/trac10/ticket/1904#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1904#comment:6</guid> <description> <p> I can confirm this bug with the newest version of gcc (i.e. 4.6) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 07 Nov 2013 09:58:34 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1904#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1904#comment:7</guid> <description> <p> I got the same problem when I come to make gearmand1.1.11, I try to fix the /usr/local/boost/include/boost/program_options/options_description.hpp on line 175 static const unsigned m_default_line_length but it does not work for me , my god </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Raffi Enficiaud</dc:creator> <pubDate>Fri, 30 May 2014 14:38:09 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1904#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1904#comment:8</guid> <description> <p> I have the same problem. I use program_option through cmake, using the following define: </p> <blockquote> <p> BOOST_ALL_NO_LIB </p> </blockquote> <p> since I do not want autolink feature. </p> <p> The two variables mentioned in this thread are not found at link time unless I define explicitely </p> <blockquote> <p> BOOST_ALL_DYN_LINK </p> </blockquote> <p> I do not have this problem with boost.system, boost.thread, boost.test and boost.chrono for instance. Looking at the config.h file, every define look fine (boost.program_options and boost.system). It looks like an incoherence in cmake find_boost module: the link is against the dynamic variants if Boost_USE_STATIC_LIBS is set to OFF, but the BOOST_ALL_DYN_LINK is not defined in Boost and should be defined manually. </p> </description> <category>Ticket</category> </item> </channel> </rss>