Hedi Ghediri - 2019-01-13

I have a code that works fine under VS 2017 Community. Now I can't use it
any longer and I had to switch to MinGW.
I compiled the boost library with MinGW and then I used the generated
libraries to link my program:

  • Lib/libboost_program_options-mgw81-mt-d-x64-1_69.a (static debug
    library)
  • Lib/libboost_program_options-mgw81-mt-x64-1_69.a (static release
    library)

Here is the command I'm using:

g++.exe -DNDEBUG -DASCII -Wall -std=c++17 -static-libgcc
-static-libstdc++ -L lib -o prog.exe *.o
-lboost_program_options-mgw81-mt-x64-1_69

and this is what I get:

main.o:main.cpp:(.text+0x203): undefined reference to
__imp__ZN5boost15program_optionslsERSoRKNS0_19options_descriptionE' main.o:main.cpp:(.text+0x3f9): undefined reference to__imp__ZN5boost15program_options19options_description21m_default_line_lengthE'
main.o:main.cpp:(.text+0x406): undefined reference to
`__imp__ZN5boost15program_options19options_description21m_default_line_lengthE'
... (more lines like these)

All the undefined reference errors are related only to the
boost::program_options calls (But I'm not using any other boost library).
I have tried:

  • Building Boost source With MinGW and linking to the generated static
    library.
  • Using the boost (.lib and .DLL) that I had on my computer with vcpkg.
    All the tries gave the same errors.
    How can I fix this?

  • Environment
    gcc 8.1.0
    boost 1.69
    Windows 10 17134