C++中使用pthread.h头文件报错 - 无法解析的外部符号 __imp__pthread_create,该符号在函数 _main 中被引用
2017-09-07 17:24
6649 查看
C++ 中使用pthread.h头文件的方法
下载 pthreads-w32-2-7-0-release.exe, 下载链接: 链接:http://pan.baidu.com/s/1kUYs2FX 密码:mcw2
下载后运行会解压生成三个文件夹 Pre-built.2、pthreads.2、QueueUserAPCEx
打开Pre-built.2文件夹,分别复制include文件夹和lib文件夹中的文件到
VS安装目录下的\VC\include文件夹和\VC\lib文件夹中 或者
VC6.0安装目录下的\VC98\include文件夹和\VC 98\lib文件夹中
包含头文件pthread.h后,运行可能会提示错误
错误 1 error LNK2019: 无法解析的外部符号 __imp__pthread_create,该符号在函数 _main 中被引用
此时需要在代码中加入
运行即可通过。
pthread.h头文件简单使用:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
下载 pthreads-w32-2-7-0-release.exe, 下载链接: 链接:http://pan.baidu.com/s/1kUYs2FX 密码:mcw2
下载后运行会解压生成三个文件夹 Pre-built.2、pthreads.2、QueueUserAPCEx
打开Pre-built.2文件夹,分别复制include文件夹和lib文件夹中的文件到
VS安装目录下的\VC\include文件夹和\VC\lib文件夹中 或者
VC6.0安装目录下的\VC98\include文件夹和\VC 98\lib文件夹中
包含头文件pthread.h后,运行可能会提示错误
错误 1 error LNK2019: 无法解析的外部符号 __imp__pthread_create,该符号在函数 _main 中被引用
此时需要在代码中加入
#pragma comment(lib, "pthreadVC2.lib")1
运行即可通过。
pthread.h头文件简单使用:
#include <iostream> #include <pthread.h> using namespace std; #pragma comment(lib, "pthreadVC2.lib") void * thread(void * a) { for (int i = 0; i < 30; i++) { printf("线程执行第 %d 次\n", i+1); } return NULL; } void main() { pthread_t id; int ret = pthread_create(&id,NULL, thread, NULL); if (ret != 0) { cout << "线程创建错误!" << endl; exit(-1); } for (int i = 0; i < 30; i++) { printf("main函数执行第 %d 次\n", i+1); } pthread_join(id, NULL); }1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
相关文章推荐
- C++中使用pthread.h头文件报错 - 无法解析的外部符号 __imp__pthread_create,该符号在函数 _main 中被引用
- C++中使用pthread.h头文件报错 - 无法解析的外部符号 __imp__pthread_create,该符号在函数 _main 中被引用
- 错误 1 error LNK2019: 无法解析的外部符号 __imp__pthread_create,该符号在函数 _main 中被引用 解决方法
- OpenGL error LNK2019: 无法解析的外部符号 __imp__glewInit@0,该符号在函数 _main 中被引用
- 使用SDL2出现 “error LNK2019: 无法解析的外部符号 _SDL_main,该符号在函数 _main 中被引用” 时的可能错误记录
- C++使用static的错误:无法解析的外部符号、“static”不应在文件范围内定义的成员函数上使用 .
- C++使用static的错误:无法解析的外部符号、“static”不应在文件范围内定义的成员函数上使用
- QTCreater编程错误:LNK2019: 无法解析的外部符号 __imp__ShellExecuteW@24,该符号在函数 _main 中被引用 的 错误处理 及 添加外部库与头文件 的方法
- error LNK2019: 无法解析的外部符号 __imp__InternetGetCookieA@16,该符号在函数 _main 中被引用
- C++使用static的错误:无法解析的外部符号、“static”不应在文件范围内定义的成员函数上使用
- C++——错误 error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用
- 关于编译eMule0.48a 提示: zlib.lib(gzio.obj) : error LNK2019: 无法解析的外部符号 __imp__strerror ,该符号在函数 _gzerror 中被引用
- error LNK2019: 无法解析的外部符号 __imp__GetStockObject@4该符号在函数_WinMain@16 中被引用
- vs2005连接时出错拉 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用
- error LNK2019: 无法解析的外部符号__imp__ChooseFontA@4,该符号在函数 _ChooseNewFont@0 中被引用
- MSVCRTD.lib(crtexe.obj) : error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用
- 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用
- SDL项目常见问题( error LNK2019: 无法解析的外部符号 _main ,该符号在函数 _mainCRTStartup 中被引用)
- error LNK2019: 无法解析的外部符号_imp__MessageBoxA@16,该符号在函数 _WinMain@16 中被引用
- error LNK2019: 无法解析的外部符号 __imp__CommandLineToArgvW@8,该符号在函数 _WinMain@16 中被引用