这是我在使用线程构建简单代码时遇到的错误。
1>------ Rebuild All started: Project: Sample_with_Threads, Configuration: Debug Win32 ------
1> source.cpp
1>c:\users\documents\visual studio 2010\projects\sample_with_threads\source.cpp(39): warning C4715: 'set_cur_avg' : not all control paths return a value
1>LINK : fatal error LNK1104: cannot open file 'pthreadsVC2.lib'
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
我使用 visual C++ 并遵循了 http://web.cs.du.edu/~sturtevant/pthread.html在其中包含 pthreads。
为什么会出现错误,如何解决?
最佳答案
此错误是由于文件 pthreadsVC2.lib
对链接器不“可见”。确保在要链接的库列表中指定此文件,并且(如果需要)在项目设置中指定该文件的路径,以便链接器:
1.“知道”它需要链接这个库,
2.可以找到文件
从你的问题来看,听起来你已经“包含”了 pthreads(如“包含头文件”)。这仅足以编译您的源文件,但链接器需要知道在哪里可以找到包含在该头文件中的符号
关于c++ - LNK1104 : Cannot open file pthreadsVC2. 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24451015/