(gelöst) Linkererrors bei Boost



  • Hallo

    ich hab ein Problem mit boost. Immer wenn ich mit boost::mutex::scoped_lock verwende bekomme ich diese Linkermeldungen: 😕

    [Linker error] undefined reference to `boost::lock_error::what() const' 
      [Linker error] undefined reference to `boost::thread_exception::~thread_exception()' 
      [Linker error] undefined reference to `boost::thread_exception::~thread_exception()'
    

    Hoffentlich wird jemand daraus schlau. Und ich hab die boost_thread-mgw-mt-1_31.lib
    gelinkt.

    Ich hab mal ein example aus boost kompiliert, gleiche Meldung:

    #include <boost/thread/mutex.hpp>
    #include <boost/thread/thread.hpp>
    #include <iostream>
    
    boost::mutex mutex;
    int counter=0;
    
    void change_count()
    {
        boost::mutex::scoped_lock lock(mutex);
        int i = ++counter;
        std::cout << "count == " << i << std::endl;
    }
    
    int main()
    {
        const int num_threads = 4;
        boost::thread_group thrds;
        for (int i=0; i < num_threads; ++i)
            thrds.create_thread(&change_count);
        thrds.join_all();
    }
    

    Danke im voraus

    YASC



  • Hat sich erledigt. Man muss
    libboost_thread-mgw-mt-s-1_32.lib
    linken


Anmelden zum Antworten