c++ - LNK1104 : Cannot open file pthreadsVC2. 库

标签 c++ pthreads

这是我在使用线程构建简单代码时遇到的错误。

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/

相关文章:

c++ - gcc >=10.1 和 clang 不检测未使用但设置 lambda

c++ - 如何将范围映射到值?

c++ - 使用 QTextCursor 选择一段文本

c++ - "Dividing"一个整数分成几 block (对某些收入阈值征收不同的税 - C++)

c++ - 如果 pthread_cond_wait 本身锁定和解锁互斥体,那么锁定和解锁互斥体有什么意义呢?

c - Linux 中的线程同步?

javaout 类型映射不适用于 std::vector

调用 C 中的特定线程

c - C语言多线程服务器设计

C++ : fork/exec or pthread?