我用的是https://github.com/AlexeyAB/darknet 中 的build.ps1进行构建的,在仓库的readme文件中也推荐使用powershell 进行构建,但是构建过程中遇到了这个问题 Could NOT find PThreads4W (missing: PThreads4W_LIBRARY)
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Could NOT find PThreads4W (missing: PThreads4W_LIBRARY)
-- PThreads4W_DLL_DIR: F:/YOLO/darknet-yolov4/build_release/vcpkg_installed/x64-windows/include/../bin
-- PThreads4W_DEBUG_DLL_DIR: F:/YOLO/darknet-yolov4/build_release/vcpkg_installed/x64-windows/include/../debug/bin
-- ZED SDK not found
-- The CSharp compiler identification is Microsoft Visual Studio 2019
-- The CSharp compiler version is 2019
-- Check for working C# compiler: D:/Microsoft Visual Studio/2019/Professional/MSBuild/Current/Bin/Roslyn/csc.exe
-- Check for working C# compiler: D:/Microsoft Visual Studio/2019/Professional/MSBuild/Current/Bin/Roslyn/csc.exe - works
-- Configuring done (230.8s)
CMake Error at CMakeLists.txt:527 (target_link_libraries):
Target "uselib_track" links to:
PThreads_windows::PThreads_windows
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
CMake Error at CMakeLists.txt:472 (target_link_libraries):
Target "uselib" links to:
PThreads_windows::PThreads_windows
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
-- Generating done (1.0s)
CMake Generate step failed. Build files cannot be regenerated correctly.
Config failed! Exited with error code 1.
-- Could NOT find PThreads4W (missing: PThreads4W_LIBRARY)
怎么才能得到这个PThreads4W ? 或者如何解决这个问题?
if(MSVC)
target_link_libraries(darknet PRIVATE PThreads4W::PThreads4W)
target_link_libraries(darknet PRIVATE wsock32)
target_link_libraries(dark PUBLIC PThreads4W::PThreads4W)
target_link_libraries(dark PUBLIC wsock32)
target_link_libraries(uselib PRIVATE PThreads4W::PThreads4W)
target_compile_definitions(darknet PRIVATE -D_CRT_RAND_S -DNOMINMAX -D_USE_MATH_DEFINES)
target_compile_definitions(dark PRIVATE -D_CRT_RAND_S -DNOMINMAX -D_USE_MATH_DEFINES)
target_compile_definitions(dark PUBLIC -D_CRT_SECURE_NO_WARNINGS)
target_compile_definitions(uselib PRIVATE -D_CRT_RAND_S -DNOMINMAX -D_USE_MATH_DEFINES)
endif()
不知道这个PThreads4W_LIBRARY怎么整?
PThreads4W是Windows下用于多线程编程的库,似乎在您的系统中缺少或没有正确安装。为了解决这个问题,您可以尝试以下步骤:
安装PThreads4W库:
您可以从以下链接下载PThreads4W库:https://www.sourceware.org/pthreads-win32/,并在您的系统上安装它。安装后,请确保该库已正确安装,其头文件和库文件可在搜索路径中找到。
将PThreads4W添加到系统路径:
如果您已在系统上安装了PThreads4W库,则可能需要将包含PThreads4W.dll文件的目录添加到系统路径中。您可以按照以下步骤操作:
a. 打开控制面板并单击“系统”。
b. 单击“高级系统设置”。
c. 单击“环境变量”。
d. 在“系统变量”部分中,找到“Path”变量并单击“编辑”。
e. 在变量值字段的末尾添加PThreads4W.dll文件的路径(例如C:\ pthreads \ bin),用分号(;)分隔。
f. 单击“确定”关闭所有窗口。
在CMakeLists.txt中设置PThreads4W_LIBRARY变量:
在您的CMakeLists.txt文件中,您可以尝试将PThreads4W_LIBRARY变量设置为PThreads4W库文件的路径。例如:
set(PThreads4W_LIBRARY“C:/ pthreads / lib / pthreadsVC2.lib”)
请确保使用实际在您的系统上找到库文件的路径替换此路径。
应用这些更改后,尝试再次构建项目,看是否解决了问题。
可以! ChatGPT 运用已臻于化境了,很nice!等我测试下ChatGPT有没有撒谎
@echo_lovely: 可