zoukankan      html  css  js  c++  java
  • Windows系统下pthread环境配置

    记录下win7系统,vc6.0++编译器下配置POSIX多线程环境的步骤。

    配置

    1. 下载地址 ftp://sourceware.org/pub/pthreads-win32/
      我下载的版本是 fpthreads-w32-2-1-0-release.exe 2005/3/16
      运行后点Exract,解压完成后再点Done,可以看到三个文件夹,但只需要用到Pre-built.2文件夹。

    2. Pre-built.2/include中的三个头文件复制到vc的Include文件夹内

    3. Pre-built.2/lib中的8个文件复制到vc的Bin文件夹内(不知道需不需要,反正移就完事了)

    4. Pre-built.2/lib中的pthreadVC2.libpthreadVSE2.lib复制到vc的Lib文件夹里(否则会出现链接错误LNK1104:cannot open file "pthreadVC2.lib"

    5. Pre-built.2/lib中的pthreadVC2.dll文件复制到C:Windowssystem里面(我的电脑中有system和system32两个文件夹,试了下发现应该放在system中)

    6. 配置完成,编程的时候需要包含pthread.h头文件,并且要加上一句#pragma comment(lib, "pthreadVC2.lib") (否则会出现链接错误)

    测试

    #include <cstdio>
    #include <pthread.h>
    #pragma comment(lib, "pthreadVC2.lib")
    
    void * fun(void * arg) {
        printf("Hello, %s
    ", (char *) arg);
    
        return NULL;
    }
    
    int main(void) {
        pthread_t t1, t2;
    
        pthread_create(&t1, NULL, fun, "thread1");
        pthread_create(&t2, NULL, fun, "thread2");
        pthread_join(t1, NULL);
        pthread_join(t2, NULL);
    
        return 0;
    }

    输出结果

    Hello, thread1
    Hello, thread2
  • 相关阅读:
    preflight
    vs调试的时候,加载dll非常慢的解决方法
    chrome blink render engine and the render mechanism
    Cache-control demestified
    IE文档模式和兼容模式
    canvas和SVG分析比较
    打败 IE 的葵花宝典:CSS Bug Table
    vi 编辑器
    JS高级 1
    特效四大家族
  • 原文地址:https://www.cnblogs.com/zhayujie/p/12941576.html
Copyright © 2011-2022 走看看