How do I install pthread_win32 (Windows pthread / posix thread library) for Visual Studio 2005?

前端 未结 3 1780
-上瘾入骨i
-上瘾入骨i 2020-12-22 12:01

Just to be clear - I have searched the depths of the internet and back for information on how to do this

I\'m looking for assistance setting up pthr

相关标签:
3条回答
  • 2020-12-22 12:12

    Have you added pthreadVC.lib (or whichever particular lib you need) to the project property:

    Linker/Input/Additional Dependencies
    

    It's not enough to just have the lib file in a particular directory, the linker needs to be told to use it as an input.

    0 讨论(0)
  • 2020-12-22 12:18

    Just adding pthreadVC2.lib to linker list is not suffiecient. You also have to add addtional lib like pthreadVCE2.lib and pthreadVSE2.lib.

    I am facing same issue but then I resolved it through adding these files.

    0 讨论(0)
  • 2020-12-22 12:28

    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>
    

    Although, I am not completely over as Visual Studio now trys to link with the _[FuncName] instead of [FuncName]

    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) ;
    

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

    int myFunc(int myArgs) ;
    

    [EDIT]

    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) ;
    
    0 讨论(0)
提交回复
热议问题