Thread: strange linker error with minGW and boost

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    519

    strange linker error with minGW and boost

    Hello,

    I run into following problems compiling a programm what uses
    Code:
    boost::program_options
    under gcc version 3.4.2 / mingw:


    Code:
    g++ -mthreads src/entity/EntityManager.o src/entity/TestJob.o lib/Sched.lib  
    lib/Timer.lib /C/workspace-eclipse/ReflectiveMemory.Linux/lib/mingw/debug/libsw_rm.dll /mingw/lib/libwsock32.a 
    ../../src/common/lib/libpthreadGC2.a /mingw/lib/libwinmm.a 
    /C/workspace-eclipse/libs/boost_1_33_1.mingw_precompiled/lib/libboost_filesystem-mgw.lib /C/workspace-eclipse/libs/boost_1_33_1.mingw_precompiled/lib/boost_date_time-mgw.lib /C/workspace-eclipse/libs/boost_1_33_1.mingw_precompiled/lib/boost_program_options-mgw.lib -o  
    bin/EntityManager.exe 
    Info: resolving vtable for boost::program_options::variables_mapby linking to  
    __imp___ZTVN5boost15program_options13variables_mapE (auto-import) 
    Info: resolving vtable for  
    boost::program_options::value_semantic_codecvt_helper<char>by linking to  
    __imp___ZTVN5boost15program_options29value_semantic_codecvt_helperIcEE  
    (auto-import) 
    Info: resolving boost::program_options::arg by linking to  
    __imp___ZN5boost15program_options3argE (auto-import) 
    Info: resolving vtable for boost::program_options::validation_errorby linking  
    to __imp___ZTVN5boost15program_options16validation_errorE (auto-import) 
    src/entity/EntityManager.o: In function  
    `basic_command_line_parser':c:/workspace-eclipse/libs/boost_1_33_1.mingw_precompiled/include/boost-1_33_1/boost/program_options/detail/parsers.hpp:42:  
    undefined reference to  
    `boost::program_options::detail::cmdline::cmdline(std::vector<std::string,  
    std::allocator<std::string> > const&)' 
    src/entity/EntityManager.o:c:/workspace-eclipse/libs/boost_1_33_1.mingw_precompiled/include/boost-1_33_1/boost/program_options/detail/parsers.hpp:49:  
    undefined reference to  
    `boost::program_options::detail::cmdline::set_options_description(boost::program_options::options_description  
    const&)' 
    src/entity/EntityManager.o:c:/workspace-eclipse/libs/boost_1_33_1.mingw_precompiled/include/boost-1_33_1/boost/program_options/detail/parsers.hpp:67:  
    undefined reference to `boost::program_options::detail::cmdline::style(int)' 
    src/entity/EntityManager.o:c:/workspace-eclipse/libs/boost_1_33_1.mingw_precompiled/include/boost-1_33_1/boost/program_options/detail/parsers.hpp:75:  
    undefined reference to  
    `boost::program_options::detail::cmdline::set_additional_parser(boost::function1<std::pair<std::string,  
    std::string>, std::string const&, std::allocator<boost::function_base> >)' 
    src/entity/EntityManager.o:c:/workspace-eclipse/libs/boost_1_33_1.mingw_precompiled/include/boost-1_33_1/boost/program_options/detail/parsers.hpp:102:  
    undefined reference to `boost::program_options::detail::cmdline::run()' 
    collect2: ld returned 1 exit status 
    make[1]: *** [bin/EntityManager.exe] Error 1 
    make[1]: Leaving directory `/c/workspace-eclipse/SimulationEngine/mingw/debug' 
    make: *** [Tests] Error 2


    here is the fragment that causes that behavior:



    Code:
    // Declare the supported options. 
    po::options_description desc("Allowed options"); 
    desc.add_options() 
    ("help", "produce help message") 
    ("client_id", po::value<int>(&mClientId), 
    "set em's client id.") 
    ("srv_ip", po::value<string>(&mSrvIp), 
    "set SWRM server ip adress. Default is 127.0.0.1") 
    ("srv_port", po::value<int>(&mSrvPort), 
    "set SWRM server port number. Default is 8011") 
    ; 
     
    po::variables_map vm; 
     
    // trouble starts with commenting in the following line(s): 
     
    // po::store(po::parse_command_line(globalArgc, globalArgv, desc), 
    // vm); 
    // po::notify(vm);  
    //  
    // if (vm.count("help")) 
    // { 
    // cout << desc << "\n"; 
    // exit(EXIT_SUCCESS); 
    // } 
    //  
    // if (0 == mClientId) 
    // { 
    // cout << "No client_id set. Exiting...\n"; 
    // exit(EXIT_FAILURE); 
    // } 
    // if( 2 > mClientId ) 
    // { 
    // cout << "Client_id has to be greater than 1." 
    // << " 1 is reserved for SWRM server. Exiting...\n"; 
    // exit(EXIT_FAILURE); 
    // }else 
    // { 
    // cout << "client_id of this EM was set to " 
    // << mClientId << "\n"; 
    // } 
    //  
    // if (vm.count("srv_ip")) 
    // { 
    // cout << "SWRM server ip set to " << mSrvIp << "\n"; 
    // }else 
    // { 
    // cout << "SWRM server ip set to " << mSrvIp << "\n"; 
    // } 
    //  
    // if (vm.count("srv_port")) 
    // { 
    // cout << "SWRM server port set to " << mSrvPort << "\n"; 
    // }else 
    // { 
    // cout << "SWRM server port set to " << mSrvPort << "\n"; 
    // }

    All does compile fine under linux. And also the other boost libs I'm using
    (filesystem and date_time) behave well.

    What I'm doing wrong?

    Thank you in advance!
    Last edited by pheres; 07-03-2007 at 06:26 AM.

  2. #2
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    you have to link to the boost program options library.
    Kurt

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    sorry the lines wasn't broken. if you scroll right you see the lib

    Code:
    g++ -mthreads src/entity/EntityManager.o src/entity/TestJob.o lib/Sched.lib  
    lib/Timer.lib /C/workspace-eclipse/ReflectiveMemory.Linux/lib/mingw/debug/libsw_rm.dll /mingw/lib/libwsock32.a 
    ../../src/common/lib/libpthreadGC2.a /mingw/lib/libwinmm.a 
    /C/workspace-eclipse/libs/boost_1_33_1.mingw_precompiled/lib/libboost_filesystem-mgw.lib /C/workspace-eclipse/libs/boost_1_33_1.mingw_precompiled/lib/boost_date_time-mgw.lib 
    /C/workspace-eclipse/libs/boost_1_33_1.mingw_precompiled/lib/boost_program_options-mgw.lib -o  
    bin/EntityManager.exe

  4. #4
    Registered User
    Join Date
    Feb 2009
    Posts
    1

    Ever find a solution?

    Did you ever find a solution to this? I'm running into the same message atop 1.37.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Boost for MinGW?
    By sh3rpa in forum C++ Programming
    Replies: 1
    Last Post: 11-13-2007, 09:57 AM