Question

The following cpp code doesn't run on Ubuntu 13.10 using g++-4.8 or g++-4.7. I have no idea how to solve that issue. It seems that on older Ubuntu versions (e.g. 13.04) the code below works fine.

Code

#include <future>
#include <iostream>

int main(int argc, char** argv) 
{
    int step = 0;
    std::cout << "step " << ++step << std::endl;

    std::promise<int> promise;
    std::cout << "step " << ++step << std::endl;

    try
    {
        promise.set_value(42);
        std::cout << "step " << ++step << std::endl;
    }
    catch (const std::system_error& ex)
    {
        std::cout << "Exception: " << ex.what() << "\n";
    }
}

Build And Run

g++ promise_test.cpp -o promise_test -pthread -std=c++11 && ./promise_test

Output

step 1
step 2
Exception: Unknown error -1
Was it helpful?

Solution

The bug report. The work around provided is -Wl,--no-as-needed. See this other question.

OTHER TIPS

As an alternative we fixed it with -static-libstdc++ flag.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top