boostorg / boostorg/program_options

linking with program_options has unresolved symbols on MSVC

Đang mở
#58 26 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C++
Star
136
Fork
117
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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 x64 from 2015 and 2017 I get two unresolved symbols:

```
LightBISClientCMDLine.cc.obj : error LNK2001: unresolved external symbol "class std::basic_string,class std::allocator > boost::program_options::arg" (?arg@program_options@boost@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)
LightBISClientCMDLine.cc.obj : 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: ​http://data.biodataanalysis.de/tmp/boost_program_options_linker_error_emmenlau.txt

I checked the build log to see that the library was built with `-DBOOST_PROGRAM_OPTIONS_DYN_LINK=1`.

As far as I could see, it's not supported to export STL classes like `std::string` from a DLL with Visual Studio 2015 and 2017 because it seems considered bad practice. 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:
* ​https://social.msdn.microsoft.com/Forums/vstudio/en-US/df99b712-c00b-4af0-82fd-3764c8b6cbec/exporting-stdstring-from-a-dll-does-not-export-stdstringnpos
* ​https://stackoverflow.com/a/13866797/7200132

Here is an example that shows the error. The build is configured with cmake: https://github.com/emmenlau/BDAMinimalTestCase

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Tái hiện lỗi linker với BDAMinimalTestCase được liên kết bằng CMake và MSVC Build Tools 2015 hoặc 2017. Bắt đầu với log linker chi tiết và các export từ program_options.dll, sau đó xác định xem hai symbol chưa được resolve có phải là vấn đề thư viện được hỗ trợ hay không; hoàn tất khi đã xác nhận được nguyên nhân và có giải pháp được lập tài liệu hoặc kiểm chứng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
cmake, cpp
Lĩnh vực
build-system, cli
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.