Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LNK1104 : Cannot open file pthreadsVC2.lib

Tags:

c++

pthreads

This is the error I get when tying to build a simple code with threads.

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 ==========

I use visual C++ and I followed http://web.cs.du.edu/~sturtevant/pthread.html to include pthreads in it.

Why is the error occurring and what is the solution?

like image 434
Aiyoyo Avatar asked Dec 29 '25 16:12

Aiyoyo


1 Answers

This error is due to file pthreadsVC2.lib not being "visible" to linker. Make sure you specify this file in the list of libraries to link to and also (if needed) the path to that file in the project's settings, so that the linker: 1. "knows" that it needs to link this library in and, 2. can find the file

From your question it sounds like you have "included" the pthreads (as in"included a header file"). This is only enough to make your source file compile, but the linker needs to know where to find the symbols that were included in that header file

like image 127
YePhIcK Avatar answered Jan 01 '26 05:01

YePhIcK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!