I heard that Nuget builds project easier without any configuration.
So, I am trying to add pthreads in my project from Nuget
(Actually I am using windows 10 x64 Visual studio 2017, C language, and my friends use linux OS)
I just search pthreads in Nuget package, click "install" button
But, my project compiles well but fatal error LNK1120
called.
Is there any more configuration after install pthreads from nuget?
Using Nuget format to install pthread
into C++ projects is quite simple and will not manually configure include Directories
and additional Dependencies
address any more.
But pthread nuget package in VS has a drawback that it does not fully inherit pthread
class library. It lost a file called pthreadvc2.lib
. You can try my following suggestions to configure it without any settings in project properties
.
Solution
1) download pthread-w32-2-9-1-release.zip
from this link.
2) unpack this file and then copy pthreadVC2.lib
from the file(pthreads-w32-2-9-1-release\Pre-built.2\lib\x86 or x64
) into
C:\Program Files (x86)\Microsoft Visual Studio\2017\xxxxx\VC\Tools\MSVC\xxxx.xx.xxxx\lib\x86 or x64
.
Note that you should copy the related lib into the related folder, x86 pthreadVC2.lib
into x86
folder, x64 pthreadVC2.lib
into x64
folder.
3) then add this into your cpp file:
#pragma comment(lib,"pthreadVC2.lib")
Then it will work as expected without any errors.