linking with program_options has unresolved symbols on MSVC
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- cmake, cpp
- 領域
- build-system, cli
調査の方向性
CMake と MSVC Build Tools 2015 または 2017 を使用して、リンクされている BDAMinimalTestCase でリンカーの失敗を再現します。まず詳細なリンカー・ログと program_options.dll のエクスポートを確認し、次に未解決の 2 つのシンボルがサポート対象のライブラリの問題によるものかどうかを判断します。確認済みの原因と、文書化または検証済みの解決策が得られれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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<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)
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
- 主要言語
- C++
- スター
- 136
- フォーク
- 117
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
boostorg/program_options のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
boostorg/program_options#147 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
boostorg/program_options#146 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
boostorg/program_options#144 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
boostorg/program_options#142 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 30/100
boostorg/program_options#139 ·
boostorg/program_options の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
AXERA-TECH/ax-llm#77 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
games-on-whales/wolf#509 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
bug-unconfirmed
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
NVIDIA/cuda-samples#453 ·