Opened 3 months ago

Last modified 3 weeks ago

#13326 new Bugs

linking with program_options has unresolved symbols on MSVC

Reported by: Mario Emmenlauer <mario@…> Owned by: Vladimir Prus
Milestone: To Be Determined Component: program_options
Version: Boost 1.65.0 Severity: Problem
Keywords: Cc:


I'm developing a simple command line client application against boost::program_options. Everything works fine on Linux with gcc-4.8, gcc-5.3 and gcc-6.3, on Darwin with XCode 7 and on Windows with MinGW-w64. But on Windows with MSVC Build Tools 2017 x64 I get two unresolved symbols: : error LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > boost::program_options::arg" (?arg@program_options@boost@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A) : error LNK2001: unresolved external symbol "public: static unsigned int const boost::program_options::options_description::m_default_line_length" (?m_default_line_length@options_description@program_options@boost@@2IB)

I checked program_options.dll and I am under the impression that those two symbols are defined there. I get exact matches for ?arg@program_options@boost@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A and ?m_default_line_length@options_description@program_options@boost@@2IB. Also all other symbols from program_options are resolved correctly. Here is the details build log with a verbose linker message:

I am explictily setting preprocessor defines for debug, and I set to code to build for C++14. Is that possibly related?

Attachments (0)

Change History (5)

comment:1 Changed 3 months ago by Mario Emmenlauer <mario@…>

I investigated a bit and I think I found a new hint. As far as I could see, it's no longer supported to export STL classes from a DLL with Visual Studio 2017. There are various reports that indicate that exporting STL classes can cause issues when mixing different runtimes or compiler versions. Is it possible that Microsoft just disabled that option alltogether?

I found related reports here:

comment:2 Changed 5 weeks ago by Mario Emmenlauer <mario@…>

Is there any progress on this? I understand that it breaks use of program options with MSVC 2017, or am I doing something wrong?

comment:3 Changed 3 weeks ago by Jakub

same problem here

comment:4 Changed 3 weeks ago by Vladimir Prus

Could you provide the minimal example (source, build command) that reproduces this?

comment:5 Changed 3 weeks ago by Mario Emmenlauer <mario@…>

Here is an example that shows the error. The build is configured with cmake.

Modify Ticket

Change Properties
Set your email in Preferences
as new The owner will remain Vladimir Prus.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.