Hello Community,
I running Windows 10 Pro. MSYS2 - MinGW64-bit with gcc/g++ 10.2.0.
I have download the 1_77 Version of Boost, compile it with b2 in the
msys2 shell terminal.
I could not replace cxx11 to cxx17.
All options to build.bat, and b2.exe/sh to switch to cxx17 have not
be worked.
I downwrite the simple "Boost.program_options" example.
I could compile it without any errors or warnings.
But I ran into trouble at link stage.
I have tried libs for x32/64, single/multi thread, debug/release,
static/dynamic.
All ends up with the same error of undefined reference explained below.
Here comes the known source code to the problem:
---%<---
# include
# include "common.h"
namespace po = boost::program_options;
int
main(int argc, char *argv[])
{
try {
po::options_description desc("Allowed Options");
desc.add_options()
("help", "shows the help page")
("compression", po::value<int>(), "set compression level")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if (vm.count("help")) {
std::cout << desc << std::endl;
return SUCCESS;
}
if (vm.count("compression")) {
std::cout << "Compression level was set to "
<< vm["compression"].as<int>() << "." << std::endl;
} else {
std::cout << "Compression level was not set." << std::endl;
}
} catch(...) {
std::cerr << "caugth a error.\n";
return FAILURE;
}
return SUCCESS;
}
--->%---
Here is a list of the files that are generated during the build time:
devlab1@rk1700 MINGW64 /e/Projekte/news
$ dir ../boost_1_77_0/stage/lib/
cmake
libboost_atomic-mgw10-mt-d-x32-1_77.a
libboost_atomic-mgw10-mt-d-x64-1_77.a
libboost_atomic-mgw10-mt-s-x64-1_77.a
libboost_atomic-mgw10-mt-x32-1_77.a
libboost_atomic-mgw10-mt-x64-1_77.a
libboost_chrono-mgw10-mt-d-x32-1_77.a
libboost_chrono-mgw10-mt-d-x64-1_77.a
libboost_chrono-mgw10-mt-s-x64-1_77.a
libboost_chrono-mgw10-mt-x32-1_77.a
libboost_chrono-mgw10-mt-x64-1_77.a
libboost_container-mgw10-mt-d-x32-1_77.a
libboost_container-mgw10-mt-d-x64-1_77.a
libboost_container-mgw10-mt-s-x64-1_77.a
libboost_container-mgw10-mt-x32-1_77.a
libboost_container-mgw10-mt-x64-1_77.a
libboost_context-mgw10-mt-d-x32-1_77.a
libboost_context-mgw10-mt-d-x64-1_77.a
libboost_context-mgw10-mt-s-x64-1_77.a
libboost_context-mgw10-mt-x32-1_77.a
libboost_context-mgw10-mt-x64-1_77.a
libboost_contract-mgw10-mt-d-x32-1_77.a
libboost_contract-mgw10-mt-d-x64-1_77.a
libboost_contract-mgw10-mt-s-x64-1_77.a
libboost_contract-mgw10-mt-x32-1_77.a
libboost_contract-mgw10-mt-x64-1_77.a
libboost_coroutine-mgw10-mt-d-x32-1_77.a
libboost_coroutine-mgw10-mt-d-x64-1_77.a
libboost_coroutine-mgw10-mt-s-x64-1_77.a
libboost_coroutine-mgw10-mt-x32-1_77.a
libboost_coroutine-mgw10-mt-x64-1_77.a
libboost_date_time-mgw10-mt-d-x32-1_77.a
libboost_date_time-mgw10-mt-d-x64-1_77.a
libboost_date_time-mgw10-mt-s-x64-1_77.a
libboost_date_time-mgw10-mt-x32-1_77.a
libboost_date_time-mgw10-mt-x64-1_77.a
libboost_exception-mgw10-mt-d-x32-1_77.a
libboost_exception-mgw10-mt-d-x64-1_77.a
libboost_exception-mgw10-mt-s-x64-1_77.a
libboost_exception-mgw10-mt-x32-1_77.a
libboost_exception-mgw10-mt-x64-1_77.a
libboost_fiber-mgw10-mt-d-x64-1_77.a
libboost_fiber-mgw10-mt-s-x64-1_77.a
libboost_fiber-mgw10-mt-x64-1_77.a
libboost_filesystem-mgw10-mt-d-x32-1_77.a
libboost_filesystem-mgw10-mt-d-x64-1_77.a
libboost_filesystem-mgw10-mt-s-x64-1_77.a
libboost_filesystem-mgw10-mt-x32-1_77.a
libboost_filesystem-mgw10-mt-x64-1_77.a
libboost_graph-mgw10-mt-d-x32-1_77.a
libboost_graph-mgw10-mt-d-x64-1_77.a
libboost_graph-mgw10-mt-s-x64-1_77.a
libboost_graph-mgw10-mt-x32-1_77.a
libboost_graph-mgw10-mt-x64-1_77.a
libboost_iostreams-mgw10-mt-d-x32-1_77.a
libboost_iostreams-mgw10-mt-d-x64-1_77.a
libboost_iostreams-mgw10-mt-s-x64-1_77.a
libboost_iostreams-mgw10-mt-x32-1_77.a
libboost_iostreams-mgw10-mt-x64-1_77.a
libboost_json-mgw10-mt-d-x32-1_77.a
libboost_json-mgw10-mt-d-x64-1_77.a
libboost_json-mgw10-mt-s-x64-1_77.a
libboost_json-mgw10-mt-x32-1_77.a
libboost_json-mgw10-mt-x64-1_77.a
libboost_locale-mgw10-mt-d-x32-1_77.a
libboost_locale-mgw10-mt-d-x64-1_77.a
libboost_locale-mgw10-mt-s-x64-1_77.a
libboost_locale-mgw10-mt-x32-1_77.a
libboost_locale-mgw10-mt-x64-1_77.a
libboost_log-mgw10-mt-d-x32-1_77.a
libboost_log-mgw10-mt-d-x64-1_77.a
libboost_log-mgw10-mt-s-x64-1_77.a
libboost_log-mgw10-mt-x32-1_77.a
libboost_log-mgw10-mt-x64-1_77.a
libboost_log_setup-mgw10-mt-d-x32-1_77.a
libboost_log_setup-mgw10-mt-d-x64-1_77.a
libboost_log_setup-mgw10-mt-s-x64-1_77.a
libboost_log_setup-mgw10-mt-x32-1_77.a
libboost_log_setup-mgw10-mt-x64-1_77.a
libboost_math_c99-mgw10-mt-d-x64-1_77.a
libboost_math_c99-mgw10-mt-s-x64-1_77.a
libboost_math_c99-mgw10-mt-x64-1_77.a
libboost_math_c99f-mgw10-mt-d-x64-1_77.a
libboost_math_c99f-mgw10-mt-s-x64-1_77.a
libboost_math_c99f-mgw10-mt-x64-1_77.a
libboost_math_c99l-mgw10-mt-d-x64-1_77.a
libboost_math_c99l-mgw10-mt-s-x64-1_77.a
libboost_math_c99l-mgw10-mt-x64-1_77.a
libboost_math_tr1-mgw10-mt-d-x64-1_77.a
libboost_math_tr1-mgw10-mt-s-x64-1_77.a
libboost_math_tr1-mgw10-mt-x64-1_77.a
libboost_math_tr1f-mgw10-mt-d-x64-1_77.a
libboost_math_tr1f-mgw10-mt-s-x64-1_77.a
libboost_math_tr1f-mgw10-mt-x64-1_77.a
libboost_math_tr1l-mgw10-mt-d-x64-1_77.a
libboost_math_tr1l-mgw10-mt-s-x64-1_77.a
libboost_math_tr1l-mgw10-mt-x64-1_77.a
libboost_nowide-mgw10-mt-d-x32-1_77.a
libboost_nowide-mgw10-mt-d-x64-1_77.a
libboost_nowide-mgw10-mt-s-x64-1_77.a
libboost_nowide-mgw10-mt-x32-1_77.a
libboost_nowide-mgw10-mt-x64-1_77.a
libboost_prg_exec_monitor-mgw10-mt-d-x32-1_77.a
libboost_prg_exec_monitor-mgw10-mt-d-x64-1_77.a
libboost_prg_exec_monitor-mgw10-mt-s-x64-1_77.a
libboost_prg_exec_monitor-mgw10-mt-x32-1_77.a
libboost_prg_exec_monitor-mgw10-mt-x64-1_77.a
libboost_program_options-mgw10-mt-d-x32-1_77.a
libboost_program_options-mgw10-mt-d-x64-1_77.a
libboost_program_options-mgw10-mt-s-x64-1_77.a
libboost_program_options-mgw10-mt-x32-1_77.a
libboost_program_options-mgw10-mt-x64-1_77.a
libboost_python39-mgw10-mt-d-x32-1_77.a
libboost_python39-mgw10-mt-d-x64-1_77.a
libboost_python39-mgw10-mt-x32-1_77.a
libboost_python39-mgw10-mt-x64-1_77.a
libboost_random-mgw10-mt-d-x32-1_77.a
libboost_random-mgw10-mt-d-x64-1_77.a
libboost_random-mgw10-mt-s-x64-1_77.a
libboost_random-mgw10-mt-x32-1_77.a
libboost_random-mgw10-mt-x64-1_77.a
libboost_regex-mgw10-mt-d-x32-1_77.a
libboost_regex-mgw10-mt-d-x64-1_77.a
libboost_regex-mgw10-mt-s-x64-1_77.a
libboost_regex-mgw10-mt-x32-1_77.a
libboost_regex-mgw10-mt-x64-1_77.a
libboost_serialization-mgw10-mt-d-x32-1_77.a
libboost_serialization-mgw10-mt-d-x64-1_77.a
libboost_serialization-mgw10-mt-s-x64-1_77.a
libboost_serialization-mgw10-mt-x32-1_77.a
libboost_serialization-mgw10-mt-x64-1_77.a
libboost_stacktrace_basic-mgw10-mt-d-x32-1_77.a
libboost_stacktrace_basic-mgw10-mt-x32-1_77.a
libboost_stacktrace_noop-mgw10-mt-d-x32-1_77.a
libboost_stacktrace_noop-mgw10-mt-d-x64-1_77.a
libboost_stacktrace_noop-mgw10-mt-s-x64-1_77.a
libboost_stacktrace_noop-mgw10-mt-x32-1_77.a
libboost_stacktrace_noop-mgw10-mt-x64-1_77.a
libboost_stacktrace_windbg-mgw10-mt-d-x64-1_77.a
libboost_stacktrace_windbg-mgw10-mt-s-x64-1_77.a
libboost_stacktrace_windbg-mgw10-mt-x64-1_77.a
libboost_stacktrace_windbg_cached-mgw10-mt-d-x64-1_77.a
libboost_stacktrace_windbg_cached-mgw10-mt-s-x64-1_77.a
libboost_stacktrace_windbg_cached-mgw10-mt-x64-1_77.a
libboost_system-mgw10-mt-d-x32-1_77.a
libboost_system-mgw10-mt-d-x64-1_77.a
libboost_system-mgw10-mt-s-x64-1_77.a
libboost_system-mgw10-mt-x32-1_77.a
libboost_system-mgw10-mt-x64-1_77.a
libboost_test_exec_monitor-mgw10-mt-d-x32-1_77.a
libboost_test_exec_monitor-mgw10-mt-d-x64-1_77.a
libboost_test_exec_monitor-mgw10-mt-s-x64-1_77.a
libboost_test_exec_monitor-mgw10-mt-x32-1_77.a
libboost_test_exec_monitor-mgw10-mt-x64-1_77.a
libboost_thread-mgw10-mt-d-x32-1_77.a
libboost_thread-mgw10-mt-d-x64-1_77.a
libboost_thread-mgw10-mt-s-x64-1_77.a
libboost_thread-mgw10-mt-x32-1_77.a
libboost_thread-mgw10-mt-x64-1_77.a
libboost_timer-mgw10-mt-d-x32-1_77.a
libboost_timer-mgw10-mt-d-x64-1_77.a
libboost_timer-mgw10-mt-s-x64-1_77.a
libboost_timer-mgw10-mt-x32-1_77.a
libboost_timer-mgw10-mt-x64-1_77.a
libboost_type_erasure-mgw10-mt-d-x32-1_77.a
libboost_type_erasure-mgw10-mt-d-x64-1_77.a
libboost_type_erasure-mgw10-mt-s-x64-1_77.a
libboost_type_erasure-mgw10-mt-x32-1_77.a
libboost_type_erasure-mgw10-mt-x64-1_77.a
libboost_unit_test_framework-mgw10-mt-d-x32-1_77.a
libboost_unit_test_framework-mgw10-mt-d-x64-1_77.a
libboost_unit_test_framework-mgw10-mt-s-x64-1_77.a
libboost_unit_test_framework-mgw10-mt-x32-1_77.a
libboost_unit_test_framework-mgw10-mt-x64-1_77.a
libboost_wave-mgw10-mt-d-x32-1_77.a
libboost_wave-mgw10-mt-d-x64-1_77.a
libboost_wave-mgw10-mt-s-x64-1_77.a
libboost_wave-mgw10-mt-x32-1_77.a
libboost_wave-mgw10-mt-x64-1_77.a
libboost_wserialization-mgw10-mt-d-x32-1_77.a
libboost_wserialization-mgw10-mt-d-x64-1_77.a
libboost_wserialization-mgw10-mt-s-x64-1_77.a
libboost_wserialization-mgw10-mt-x32-1_77.a
libboost_wserialization-mgw10-mt-x64-1_77.a
Here comes the command line for compile/link the application
$ /mingw64/bin/x86_64-w64-mingw32-g++ -o winperm.exe ./tmp/main.o
./tmp/network.o
./tmp/threading.o ./tmp/translator.o ./tmp/tv_tui.o ./tmp/permutation.o
-fopenmp
-MD -I/E/Projekte/boost_1_77_0/stage/lib -L../boost_1_77_0/stage/lib
-L../tvision/build -L/mingw64/lib -L/mingw64/x86_64-w64-mingw32/lib
-ltvision -lkernel32 -luser32 -lwinmm -lws2_32 -lintl -lpthread
-lboost_iostreams-mgw10-mt-x64-1_77
-lboost_program_options-mgw10-mt-x64-1_77
And here comes the error output from the linker LD:
E:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32
/bin/ld.exe: ./tmp/main.o:main.cc:
(.text$_ZN5boost15program_options25basic_command_line_parserIcE12extra_parserENS_9
function1ISt4pairISsSsERKSsEE[_ZN5boost15program_options25basic_command_line_parserIcE12
extra_parserENS_9function1ISt4pairISsSsERKSsEE]+0x41): undefined
reference to
`boost::program_options::detail::cmdline::set_additional_parser(boost::function1
, std::string const&>)'
E:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32
/bin/ld.exe: ./tmp/main.o:main.cc:
(.text$_ZN5boost15program_options11to_internalISsEESt6vectorISsSaISsEERKS2_IT_Sa
IS5_EE[_ZN5boost15program_options11to_internalISsEESt6vectorISsSaISsEERKS2_IT_Sa
IS5_EE]+0x48): undefined reference to `boost::program_options::to_internal
(std::string const&)'
E:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-
mingw32/bin/ld.exe: ./tmp/main.o:main.cc:
(.text$_ZN5boost15program_options25basic_command_line_parserIcEC1EiPKPKc
[_ZN5boost15program_options25basic_command_line_parserIcEC1EiPKPKc]+0xaf):
undefined reference to
`boost::program_options::detail::cmdline::cmdline(std::vectorstd::string > const&)'
E:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32
/bin/ld.exe: ./tmp/main.o:main.cc:(.text.startup.main+0xb8): undefined
reference to
`boost::program_options::options_description::options_description(std::string
const&,
unsigned int, unsigned int)'
E:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32
/bin/ld.exe: ./tmp/main.o:main.cc:(.text.startup.main+0x281): undefined
reference to
`boost::program_options::abstract_variables_map::operator[](std::string
const&) const'
E:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32
/bin/ld.exe: ./tmp/main.o:main.cc:
(.text$_ZN5boost15program_options10validators17get_single_stringIcEERKSbIT_St11
char_traitsIS3_ESaIS3_EERKSt6vectorIS7_SaIS7_EEb[_ZN5boost15program_options10validators17
get_single_stringIcEERKSbIT_St11char_traitsIS3_ESaIS3_EERKSt6vectorIS7_SaIS7_EEb]+0xa1):
undefined reference to
`boost::program_options::validation_error::get_template(boost::program_options::
validation_error::kind_t)'
E:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32
/bin/ld.exe: ./tmp/main.o:main.cc:
(.text$_ZN5boost15program_options10validators17get_single_stringIcEERKSbIT_St11
char_traitsIS3_ESaIS3_EERKSt6vectorIS7_SaIS7_EEb[_ZN5boost15program_options10validators17
get_single_stringIcEERKSbIT_St11char_traitsIS3_ESaIS3_EERKSt6vectorIS7_SaIS7_EEb]+0xba):
undefined reference to
`boost::program_options::error_with_option_name::error_with_option_name(std::string
const&, std::string const&, std::string const&, int)'
E:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32
/bin/ld.exe: ./tmp/main.o:main.cc:
(.text$_ZN5boost15program_options10validators17get_single_stringIcEERKSbIT_St11
char_traitsIS3_ESaIS3_EERKSt6vectorIS7_SaIS7_EEb[_ZN5boost15program_options10
validators17get_single_stringIcEERKSbIT_St11char_traitsIS3_ESaIS3_EERKSt6vectorIS7_SaIS
7_EEb]+0x199): undefined reference to
`boost::program_options::validation_error::get_template(boost::program_options::
validation_error::kind_t)'
E:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32
/bin/ld.exe: ./tmp/main.o:main.cc:
(.text$_ZN5boost15program_options10validators17get_single_stringIcEERKSbIT_St11
char_traitsIS3_ESaIS3_EERKSt6vectorIS7_SaIS7_EEb[_ZN5boost15program_options10validators17
get_single_stringIcEERKSbIT_St11char_traitsIS3_ESaIS3_EERKSt6vectorIS7_SaIS7_EEb]+0x1b2):
undefined reference to
`boost::program_options::error_with_option_name::error_with_option_name(std::string
const&, std::string const&, std::string const&, int)'
E:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32
/bin/ld.exe: ./tmp/main.o:main.cc:
(.text$_ZN5boost15program_options8validateIicEEvRNS_3anyERKSt6vectorISbIT0_St11
char_traitsIS5_ESaIS5_EESaIS9_EEPT_l[_ZN5boost15program_options8validateIicEEvRNS_3any
ERKSt6vectorISbIT0_St11char_traitsIS5_ESaIS5_EESaIS9_EEPT_l]+0x5db):
undefined reference
to
`boost::program_options::invalid_option_value::invalid_option_value(std::string
const&)'
E:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32
/bin/ld.exe: ./tmp/main.o:main.cc:
(.rdata$_ZTVN5boost10wrapexceptINS_15program_options20invalid_option_valueEEE[_ZTVN5
boost10wrapexceptINS_15program_options20invalid_option_valueEEE]+0x60):
undefined
reference to
`boost::program_options::error_with_option_name::substitute_placeholders(std::string
const&) const'
E:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32
/bin/ld.exe: ./tmp/main.o:main.cc:
(.rdata$_ZTVN5boost10wrapexceptINS_15program_options16validation_errorEEE[_ZTVN5boost10
wrapexceptINS_15program_options16validation_errorEEE]+0x60): undefined
reference to
`boost::program_options::error_with_option_name::substitute_placeholders(std::string
const&) const'
E:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32
/bin/ld.exe: ./tmp/main.o:main.cc:
(.rdata$_ZTVN5boost15program_options16validation_errorE[_ZTVN5boost15program_options16
validation_errorE]+0x30): undefined reference to
`boost::program_options::error_with_option_name::substitute_placeholders(std::string
const&) const'
E:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32
/bin/ld.exe: ./tmp/main.o:main.cc:
(.rdata$_ZTVN5boost15program_options20invalid_option_valueE[_ZTVN5boost15
program_options20invalid_option_valueE]+0x30): undefined reference to
`boost::program_options::error_with_option_name::substitute_placeholders(std::string
const&) const'
E:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32
/bin/ld.exe: ./tmp/main.o:main.cc:
(.rdata$_ZTVN5boost15program_options11typed_valueIicEE[_ZTVN5boost15
program_options11typed_valueIicEE]+0x38): undefined reference to
`boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&,
std::vectorstd::string > const&, bool) const'
E:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32
/bin/ld.exe: ./tmp/main.o:main.cc:
(.rdata$.refptr._ZN5boost15program_options3argE[.refptr._ZN5boost15program_options3
argE]+0x0): undefined reference to `boost::program_options::arg'
collect2.exe: error: ld returned 1 exit status
Did I miss something ?
The question is now, how can I use boost under msys2 with mingw64 ?
Thanks for helping hands, paule32