Link Error when use variables_map::contains method
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start with the supplied C++20 reproduction using boost/program_options.hpp, especially the call to variables_map::contains, and reproduce the unresolved external symbol on the stated Windows, Visual Studio, vcpkg, and Boost versions. Compare that call with the working count call and inspect the program_options link configuration; done means the reproduction links successfully or the incompatibility is clearly documented.
Written by the indexing model from the issue text.
Description
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::_Tmap_traits<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class boost::program_options::variable_value,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class boost::program_options::variable_value > >,0> >::contains(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > 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 <cstdlib>
#include <iostream>
#include <boost/program_options.hpp>
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?
- Dominant language
- C++
- Stars
- 136
- Forks
- 117
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/program_options
-
Provide C++20 module Open
Difficulty 5/5 Over a week Newbie friendliness 45/100
boostorg/program_options#160 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
boostorg/program_options#159 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
boostorg/program_options#147 ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
boostorg/program_options#146 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
boostorg/program_options#144 ·
All issues in boostorg/program_options
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
duckdb/duckdb-wasm#2258 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
objectionary/eo-graphs#75 ·
-
Coarray integration tests carry no LABELS, so run_tests.py silently skips them under every backend Opencoarray
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
FISCO-BCOS/FISCO-BCOS#5642 ·