Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error : LNK1104 cannot open file 'pthread.lib'

I am trying to compile a native Linux C++ application in Windows using Visual Studio 2017. The app uses WebRtc's Acoustic Echo Cancellation(AEC) APIs to negate echo on wav files. Following is the CmakeLists.txt file:

cmake_minimum_required(VERSION 2.8)
project(wav-aec)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
add_subdirectory(gflags)
add_definitions("-DWEBRTC_NS_FLOAT -DWEBRTC_WIN -DNOMINMAX")

#-DWEBRTC_UNTRUSTED_DELAY -DWEBRTC_LINUX -DWEBRTC_POSIX 

include_directories(
    webrtc
    webrtc/webrtc/common_audio/signal_processing/include
    webrtc/webrtc/modules/audio_coding/codecs/isac/main/include
)

set(WEBRTC_SRC_
    base/buffer.cc
    base/checks.cc
    ...
    ...
    #system_wrappers/source/rw_lock_posix.cc
    system_wrappers/source/trace_impl.cc
    #system_wrappers/source/trace_posix.cc
)

function(prepend_path var prefix)
   set(listVar "")
   foreach(f ${ARGN})
      list(APPEND listVar "${prefix}/${f}")
   endforeach(f)
   set(${var} "${listVar}" PARENT_SCOPE)
endfunction(prepend_path)

prepend_path(WEBRTC_SRC webrtc/webrtc ${WEBRTC_SRC_})

add_executable(webrtc-audioproc webrtc-audioproc.cpp ${WEBRTC_SRC})
target_link_libraries(webrtc-audioproc gflags pthread)

When I try to build it, I get the following errror: Error : LNK1104 cannot open file 'pthread.lib'

Here is the link to the only linux dependent source file(cpp) of the project: https://github.com/lschilli/wav-aec/blob/master/webrtc-audioproc.cpp

What will be the right approach to port the code from Linux to windows? Whats is Windows equivalent of gflags and pthread? And what necessary changes needs to go to CmakeLists.txt?

P.S: I have already added pthread header, dll and libs to Visual Studio directory manually.

like image 378
Kazi Hasan Avatar asked Nov 01 '25 04:11

Kazi Hasan


1 Answers

If 'missing pthread library' is the only error, you can use pthread-w32. We have successfully used it in some of our cross-platform apps requiring pthread.

They have libraries for both 64-bit and 32-bit. You can download and add it into your project. You haven't mentioned your toolset - their libraries are named differently depending on your toolset (MSVC or GNU) so you need to pick the right one. Check out their FAQ.

Hope it helps.

like image 51
mesibo Avatar answered Nov 02 '25 19:11

mesibo



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!