我该如何为Visual Studio 2005的安装pthread_win32(窗口的pthread / POSIX线程库)? [英] How do I install pthread_win32 (Windows pthread / posix thread library) for Visual Studio 2005?

查看:634
本文介绍了我该如何为Visual Studio 2005的安装pthread_win32(窗口的pthread / POSIX线程库)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是要清楚 - 我已经在网上搜索的深度和背部的信息,如何做到这一点

我在寻找帮助建立pthread_Win32与Visual Studio 2005的工作我在C编程,我有一些多线程分配使用pthreads.h中写的。然而,由于pthread的是原产于UNIX,我必须写我的所有code的,FTP,然后ssh到我的班远程UNIX系统来运行它。它使开发需要长得多,这是令人难以置信的效率低下。我喜欢(比什么都重要),才能得到我的Win32的机器上这方面的工作,这样我就可以在Visual Studio中开发,因为我一直在做了一段时间。

I'm looking for assistance setting up pthread_Win32 to work with Visual Studio 2005. I'm programming in C, and I have a number of multithreaded assignments to write using pthread.h. However, since pthread is native to unix, I have to write all of my code, ftp it, and then ssh to my class' remote unix system to run it. It makes development take so much longer, and it's incredibly inefficient. I'd love (more than anything) to be able to get this working on my win32 machine, so I can develop in visual studio as I've been doing for quite some time.

我已经安装了pthread.lib文件和文件pthread.h的到相应的lib /头目录,在所有其他文件都是。在另一方面的DLL(实际库),我已经放在C:\\ WINDOWS \\ SYSTEM32。我试图将DLL添加作为依赖(右键项目 - >引用 - >添加新的参考),但正如其他人所说,我得到的是没有选择添加任何DLL文件或任何一个空白的对话框。它似乎认识到了头文件,但是当我编译我得到这些错误:

I've installed the pthread.lib file and pthread.h file into the respective lib/header directories, where all of the other files are. The DLL on the other hand (the actual library), I've placed in c:\windows\system32. I've tried to add the DLL as a dependency (right click project -> references -> Add new reference), but as others have stated, all I get is a blank dialogue box with no option to add any DLL files or anything. It seems to recognize the header file, but I get these errors when I compile:

1>链接...

1> main.obj:错误LNK2019:​​解析外部符号_ 小鬼的_pthread_join在函数引用_main

1>main.obj : error LNK2019: unresolved external symbol _imp_pthread_join referenced in function _main

1> main.obj:错误LNK2019:​​解析外部符号_ 小鬼的_pthread_create在函数引用_main

1>main.obj : error LNK2019: unresolved external symbol _imp_pthread_create referenced in function _main

1> main.obj:错误LNK2019:​​解析外部符号_ 小鬼的_pthread_exit在功能上_fcount引用

1>main.obj : error LNK2019: unresolved external symbol _imp_pthread_exit referenced in function _fcount

从我的研究,我确定这是与DLL一个问题,我假设它不能找到我在我的code引用的函数的定义。我已经搜查高和低,我似乎无法找出任何方式来解决这个问题。我添加的lib /头文件的目录,我的链接,以防情况,但没有解决问题。我需要做的事情,在Visual Studio中,指定我需要pthreadVC2.dll为项目依赖关系 - 它似乎在这一点上是不可能的(和非常令人沮丧的)

From my research, I've determined that this is a problem with the DLL, and I'm assuming it can't find the definitions of the functions I've referenced in my code. I've searched high and low and I can't seem to figure out any way to overcome this problem. I've added the directories of the lib/header files to my linker, just in-case, but that didn't solve the issue. I need to do something, in visual studio, to specify that I need pthreadVC2.dll as a project dependency - and it seems to be impossible (and extremely frustrating) at this point.

智慧任何话吗?

非常感谢你。

推荐答案

我经历过这个问题最近。
看来,在 __ __小鬼 preFIX是prepended函数名的情况下的 pthreads.h中的是包含在动态链接模式。
只需添加在 PTW32_STATIC_LIB 定义添加到项目或包括在你的源代码code的 pthreads.h中的应该解决的问题。

I have been through this problem recently. It appears that the __imp__ prefix is prepended to the function name in case pthread.h is included in dynamic linking mode. Simply add the PTW32_STATIC_LIB define to your project or your source code before including pthread.h should solve the issue.

#define PTW32_STATIC_LIB
#include <pthread.h>

虽然,我没有完全结束的Visual Studio中,现在改掉与连结的 _代替[FUNCNAME] [FUNCNAME]

在Visual Studio中,功能似乎被宣布为不同无论您打算将它们静态链接(.LIB)或动态(.dll文件)。

In visual studio, function seems to be declared differently wether you are going to link them statically (.lib) or dynamically (.dll).

要定义一个函数,你会动态链接:

To define a function you will link dynamically :

__declspec (dllimport) int myFunc(int myArgs) ;

要定义要导出的动态链接功能:

To define function you are exporting for dynamic linking :

__declspec (dllexport) int myFunc(int myArgs) ;

而simpliest,定义一个函数,您将静态链接:

And the simpliest, to define a function you will link statically:

int myFunc(int myArgs) ;

我要对我的调查,并通过在MS去帮助中心。
看来,要避免 _ [FUNCNAME] 的效果就需要通过以下定义静态链接库功能:

I am going on my investigations and went through this on MS help center. It seems that to avoid the _[FuncName] effect it is required to define a static linked library function by the following:

int __cdecl myFunc(int MyArgs) ;

这篇关于我该如何为Visual Studio 2005的安装pthread_win32(窗口的pthread / POSIX线程库)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆