zoukankan      html  css  js  c++  java
  • g++编C++11/C++0x遇到的问题

    在看《Cplusplus Concurrency In Action Practical Multithreading》当遇到第一个样品:

    #include<iostream>
    #include<thread>
    void hello()
    {
    	std::cout<<"hello concurrent world
    ";
    }
    int main()
    {
    	std::thread t(hello);
    	t.join();
    }

    我安装了g++-4.8版本号编译器,支持C++11。使用命令行g++-4.8 -std=c++11 -lpthread *.cpp编译后,得到的可执行文件在执行时遇到错误:

    terminate called after throwing an instance of 'std::system_error'

      what():  Enable multithreading to use std::thread: Operation not permitted

    Aborted (core dumped)

    在查了好久才发现问题,是编译器的问题,编译时要加上选项

    -Wl,--no-as-needed
    这里引用:http://stackoverflow.com/questions/19463602/compiling-multithread-code-with-g

  • 相关阅读:
    工具类-vim在shell中卡死的情况
    tomcat日志分类
    逻辑运算
    牛客练习赛29 F 算式子
    牛客练习赛29 B
    查询
    hdu 5984
    zoj 4057
    zoj 4056
    zoj 4054
  • 原文地址:https://www.cnblogs.com/lcchuguo/p/4601435.html
Copyright © 2011-2022 走看看