尝试执行已编译的 C++ 时"Operation not permitted"

"Operation not permitted" when trying to execute compiled c++

本文关键字:Operation not permitted C++ 执行 编译      更新时间:2023-10-16

我已经编译了这个websocket++打印服务器示例,执行了它,并通过在我的服务器和浏览器上进行测试来确认它的工作。

现在,我根据作者的建议,使用命令g++ -O3 -o bServer broadcast_server.cpp -I ~/websocketpp-experimental/ -std=c++0x -D_WEBSOCKETPP_CPP11_STL_ -D_WEBSOCKETPP_NO_CPP11_REGEX_ -lboost_regex -lboost_system编译了这个 websocket++ 广播服务器示例。

./bServerOperation not permitted.

ls -l bServer给出了据我所知-rwxr-xr-x 1 root root 574151 Jun 29 22:31 bServer表明它被允许执行。

如何执行此程序?

您的程序正在打印此消息。 查找打印位置并打印更多信息。

> Brian 抓住了问题的核心,以下是整体解决方案:

在broadcast_server.cpp示例中,有

        try {
            m_server.run();
        } catch (const std::exception & e) {
            std::cout << e.what() << std::endl;
        } catch (websocketpp::lib::error_code e) {
            std::cout << e.message() << std::endl;
        } catch (...) {
            std::cout << "other exception" << std::endl;
        }

谷歌搜索std "Operation not permitted"自动完成到std thread operation not permitted,第一个结果是这个问题:C++0x:线程,gcc还是我的错误?

使用 -pthread 标志可以修复它。

相关文章: