boostorg / boostorg/program_options

Link Error when use variables_map::contains method

オープン
#117 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
C++
スター
136
フォーク
117
PR マージ指標
30日以内にマージされた PR はありません

説明

Env: `Windows 10 19044.1826`
Library Config: `vcpkg`, all ports are updated to date.
IDE: `Visual Studio 2022 17.2.6`
Boost Version: `1.79.0`
C++ Version: `C++20`

When i use `program_options` library in my program, i got a link error as follows.
```
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __cdecl std::_Tree,class std::allocator >,class boost::program_options::variable_value,struct std::less,class std::allocator > >,class std::allocator,class std::allocator > const ,class boost::program_options::variable_value > >,0> >::contains(class std::basic_string,class std::allocator > const &)const " (__imp_?contains@?$_Tree@ V?$_Tmap_traits@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Vvariable_value@program_options@boost@@U?$less@V?$basic_string@ DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@ std@@V?$allocator@D@2@@std@@Vvariable_value@program_options@boost@@@std @@@2@$0A@@std@@@std@@QEBA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z), function "__cdecl This is referenced in exec(class boost::program_options::options_description const &,class boost::program_options::variables_map const &)" (?exec@@YA@AEBVoptions_description@program_options@boost@@AEBVvariables_map@23@@Z) symbol
```

Other boost libraries are work well with my vcpkg and VS env.

The reproduce code:
```
#include
#include
#include

namespace po = boost::program_options;

auto initDesc(po::options_description& desc) {

desc.add_options()
("--help", "Produce help message")
;

}

auto exec(const po::options_description& desc, const po::variables_map& vm) {
// contains method will cause a link error
// but count method will perform normal
// Code is compiled with an 'std=c++20' option
if (vm.contains("--help")) {
std::cout << desc << std::endl;
return EXIT_FAILURE;
}

return EXIT_SUCCESS;

}

int main(int argc, char* argv[]) {

try {

po::options_description opts{ "All Supported Options" };
po::variables_map vm;

initDesc(opts);

po::store(po::parse_command_line(argc, argv, opts), vm);
po::notify(vm);

return exec(opts, vm);

}
catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
}

return EXIT_SUCCESS;

}

```

I noticed that `variables_map` are inherited from `std::map`, is something wrong with here?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

提供された boost/program_options.hpp を使用する C++20 の再現コードから始め、特に variables_map::contains の呼び出しに注目し、指定された Windows、Visual Studio、vcpkg、Boost のバージョンで未解決の外部シンボルを再現してください。その呼び出しを動作する count の呼び出しと比較し、program_options のリンク設定を調査してください。完了条件は、再現コードのリンクに成功するか、非互換性が明確に文書化されていることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
cpp
領域
cli
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。