We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

c++ thread runtime error relocating (symbol not found)



  • Hello!

    I'm trying to use the thread library from the c++11 std library (#include <thread>) . I am cross compiling on my linux machine which compiles fine with no errors or warnings. Once I transfer it to the Omega2+ (0.2.2 b200), I immediately get a runtime error. Using the ldd command I get this from the cross compiled version:

    root@Omega-####:~/# ldd thread_test_01_CC_OO                                                                                                                                                                                                         
            /lib/ld-musl-mipsel-sf.so.1 (0x55a9e000)                                                                                                                                                                                                             
            libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x77598000)                                                                                                                                                                                               
            libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x77574000)                                                                                                                                                                                                     
            libc.so => /lib/ld-musl-mipsel-sf.so.1 (0x55a9e000)           
            Error relocating thread_test_01_CC_OO: _ZNSt6thread6_StateD2Ev: symbol not found                                                                                                                                                                             
            Error relocating thread_test_01_CC_OO: _ZNSt6thread15_M_start_threadESt10unique_ptrINS_6_StateESt14default_deleteIS1_EEPFvvE: symbol not found                                                                                                               
           Error relocating thread_test_01_CC_OO: _ZTINSt6thread6_StateE: symbol not found                                                                                                                                                                              
           Error relocating thread_test_01_CC_OO: _ZTINSt6thread6_StateE: symbol not found                                                                                                                                                                              
           Error relocating thread_test_01_CC_OO: _ZTINSt6thread6_StateE: symbol not found                                                                                                                                                                              
           Error relocating thread_test_01_CC_OO: _ZTINSt6thread6_StateE: symbol not found  
    

    However, if I compile this code directly on the Omega, the code works completely fine, running the same command (ldd) as above lists the same dependencies except without any errors. I've checked my library versions as best I can, I've even started to copy the libraries from the Omega into my cross-compile staging directory but get the same results. Can anyone point me in the direction of how to solve this issue? Thank you!

    // CPP program to demonstrate multithreading
    // using three different callables.
    #include <iostream>
    #include <thread>
    using namespace std;
    
    // A dummy function
    void foo(int Z)
    {
        for (int i = 0; i < Z; i++) {
            cout << "Thread using function"
                   " pointer as callable\n";
        }
    }
    
    // A callable object
    class thread_obj {
    public:
        void operator()(int x)
        {
            for (int i = 0; i < x; i++)
                cout << "Thread using function"
                      " object as  callable\n";
        }
    };
    
    int main()
    {
        cout << "Threads 1 and 2 and 3 "
             "operating independently" << endl;
    
        // This thread is launched by using
        // function pointer as callable
        thread th1(foo, 3);
    
        // This thread is launched by using
        // function object as callable
        thread th2(thread_obj(), 3);
    
        // Define a Lambda Expression
        auto f = [](int x) {
            for (int i = 0; i < x; i++)
                cout << "Thread using lambda"
                 " expression as callable\n";
        };
    
        // This thread is launched by using
        // lamda expression as callable
        thread th3(f, 3);
    
        // Wait for the threads to finish
        // Wait for thread t1 to finish
        th1.join();
    
        // Wait for thread t2 to finish
        th2.join();
    
        // Wait for thread t3 to finish
        th3.join();
    
        return 0;
    }
    


  • @OSO-Bear my guess would be that you are using dynamic linking and have a version mismatch in your libraries. Try statically linking and if this is successfully take a look at the versions you are compiling and and running against.



Looks like your connection to Community was lost, please wait while we try to reconnect.