成功实现在VS2017下编译含<pthread.h>的代码:
其他
2018-05-08 17:30:21
阅读次数: 8
- VS2017配置使用#<pthread.h> https://blog.csdn.net/cry1994/article/details/79115394(原来SystemWow64里面存储的是32的文件.)
- 配置后遇到的错误及解决方法:
- pthread.h中报错:C2011 “timespec”:“struct”类型重定义
- 解决方法: 在 #if !defined( PTHREAD_H ) #define PTHREAD_H 下面加上 define HAVE_STRUCT_TIMESPEC 这将告诉pthreads的,Win32头,你已经有一个适当的timespec,并会让你的代码编译正常。
- obj错误: 无法解析的外部符号 __imp__pthread_create,该符号在函数 _main 中被引用
- 解决方法: 在.cpp文件 #include <iostream> #include <pthread.h> using namespace std; 下边加上 #pragma comment(lib, "pthreadVC2.lib")//表示链接pthreadVC2.lib这个库。 和在工程设置里写上链入Ws2_32.lib的效果一样, 不过这种方法写的 程序别人在使用你的代码的时候就不用再设置工程settings了
转载自www.cnblogs.com/Stephen-Qin/p/9009592.html