错误:LNK1104无法打开文件"pthread.lib" [英] Error : LNK1104 cannot open file 'pthread.lib'

查看:1217
本文介绍了错误:LNK1104无法打开文件"pthread.lib"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Visual Studio 2017在Windows中编译本机Linux C ++应用程序.该应用程序使用WebRtc的声学回声消除(AEC)API来消除wav文件上的回声.以下是CmakeLists.txt文件:

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)

当我尝试构建它时,出现以下错误:错误:LNK1104无法打开文件'pthread.lib'

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

这里是项目的唯一依赖于Linux的源文件(cpp)的链接: https://github.com/lschilli/wav-aec/blob/master/webrtc-audioproc.cpp

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

将代码从Linux移植到Windows的正确方法是什么?Windows相当于gflags和pthread是什么?以及需要对CmakeLists.txt进行哪些必要的更改?

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:我已经将pthread标头,dll和libs手动添加到Visual Studio目录中.

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

推荐答案

您需要我们提供实际的lib文件,该文件通常不是"pthread.lib".最有可能是"pthreadVC3.lib".或"pthreadVC2.lib".通过在源软件包的lib目录中查找实际名称.您可能会在其中看到其他lib文件,例如"pthreadVCE3.lib".和"pthreadVSE3.lib",但您要链接"pthreadVC3.lib".

You need to us the actual lib file which is typically not "pthread.lib". It's most likely "pthreadVC3.lib" or "pthreadVC2.lib". Find the actual name by looking in the lib directory of your source package. You might see other lib files in there like "pthreadVCE3.lib" and "pthreadVSE3.lib", but you want to link "pthreadVC3.lib".

您可以在项目设置中添加此代码,也可以添加以下代码:

You can either add this in the project settings, or add the following code:

#pragma comment(lib,"pthreadVC3.lib")

要将其添加到项目设置中:

To add it to the project settings:

  • 转到项目属性->配置属性->链接器->常规,然后将您的库路径添加到其他库目录中
  • 转到项目属性->配置属性->链接器->输入,然后将lib文件(例如"pthreadVC3.lib")添加到其他依赖项中

确保您具有正确的pthread版本以匹配您的编译设置,即x86/x64.

Make sure you have the correct version of pthread to match your compile settings, ie x86/x64.

就我而言,我使用VCPkg进行软件包管理,并使用以下命令安装了pthread:

In my case, I am using VCPkg for package management and I installed pthreads using the following commands:

vcpkg install pthread:x86-windows
vcpkg install pthread:x64-windows

我的软件包库目录为"C:\ vcpkg \ installed \ x64-windows \ lib".我还必须将以下内容添加到我的项目设置中,因为vcpkg不会自动集成:

And my package lib directory is "C:\vcpkg\installed\x64-windows\lib" I additionally had to add the following to my project settings as vcpkg wasn't integrating automatically:

  • 转到项目属性"->配置属性"->"VC ++目录",然后添加"C:\ vcpkg \ installed \ x64-windows \ include"包括目录
  • 转到项目属性->配置属性-> VC ++目录,然后添加"C:\ vcpkg \ installed \ x64-windows \ lib"到图书馆目录

这篇关于错误:LNK1104无法打开文件"pthread.lib"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆