gpt4 book ai didi

c++ - 编译问题 : LIBUSB_1 with cmake project on Windows

转载 作者:可可西里 更新时间:2023-11-01 10:34:22 25 4
gpt4 key购买 nike

第一次尝试

在我的 cmake/c++ 项目中,编译时出现以下错误:

C:\local\projects\synergy-usb\synergy-through-usb-master>cmake .
You have called ADD_LIBRARY for library cryptopp without any source files. This typically indicates a problem with your CMakeLists.txt file
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIBUSB_1_INCLUDE_DIR
used as include directory in directory C:/local/projects/synergy-usb/synergy-through-usb-master/src/lib/arch
used as include directory in directory C:/local/projects/synergy-usb/synergy-through-usb-master/src/lib/net
LIBUSB_1_LIBRARY
linked by target "arch" in directory C:/local/projects/synergy-usb/synergy-through-usb-master/src/lib/arch

-- Configuring incomplete, errors occurred!
See also "C:/local/projects/synergy-usb/synergy-through-usb-master/CMakeFiles/CMakeOutput.log".

所以我缺少 libusb 库。

第二次尝试

现在我找到了一个包含以下文件夹的 libusb_1 (libusbx-1.0.18-win) 版本:

  • 例子
  • 包括
  • MinGW32
  • MinGW64
  • MS32
  • MS64

我复制了MS64/dll(windows 64位)的内容放在这里:

C:\local\libs\libusbx

我将此路径添加到我的 PATH 变量中,然后尝试再次运行 cmake:

C:>cd local\projects\synergy-usb\synergy-through-usb-master

C:\local\projects\synergy-usb\synergy-through-usb-master>cmake .
You have called ADD_LIBRARY for library cryptopp without any source files. This typically indicates a problem with your CMakeLists.txt file
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIBUSB_1_LIBRARY
linked by target "arch" in directory C:/local/projects/synergy-usb/synergy-through-usb-master/src/lib/arch

-- Configuring incomplete, errors occurred!
See also "C:/local/projects/synergy-usb/synergy-through-usb-master/CMakeFiles/CMakeOutput.log".

现在我又卡住了。我不知道它要我做什么。它知道 libusb 在哪里...

编辑

这是其中包含 libusb 的 CMakeLists.txt 的内容(部分):

find_package(libusb-1.0 REQUIRED)

set(inc
.
../base
../common
../mt
../platform
../synergy
${LIBUSB_1_INCLUDE_DIRS}
)

if (UNIX)
list(APPEND inc
../../..
../arch
)
endif()

include_directories(${inc})
add_library(arch STATIC ${src})

set(libs
../lib
${LIBUSB_1_LIBRARIES}
)

if (WIN32)
if (GAME_DEVICE_SUPPORT)
list(APPEND libs synxinhk)
endif()
endif()

target_link_libraries(arch ${libs})

编辑2

我在 findlibusb-1.0.cmake 文件中添加了以下行:

set(LIBUSB_1_LIBRARY C:\\local\\libs\\libusbx\\libusb-1.0.dll)
message(STATUS "***********************************> LIBUSB_1_LIBRARY: ${LIBUSB_1_LIBRARY}")

这是输出结果:

C:\local\projects\synergy-usb\synergy-through-usb-master>cmake .
-- ***********************************> LIBUSB_1_LIBRARY: C:\local\libs\libusbx\libusb-1.0.dll
-- Found libusb-1.0:
-- - Includes: C:/local/libs/libusbx
-- - Libraries: C:\local\libs\libusbx\libusb-1.0.dll
You have called ADD_LIBRARY for library cryptopp without any source files. This typically indicates a problem with your CMakeLists.txt file
-- Configuring done
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
-- Generating done
-- Build files have been written to: C:/local/projects/synergy-usb/synergy-through-usb-master

仍然没有构建,但是这个特定的库现在似乎添加好了:)

最佳答案

synergy 有这样的方法来将一些第 3 方库压缩在 ext 子目录中的 zip 中。 synergy-through-usb 虽然保留了通过 -DLIBUSB_1_INCLUDE_DIR=... -DLIBUSB_1_LIBRARY=... 为 Windows 指定包含的方式。

因此,您只需转到“ext”目录并使用库 gtest、gmock 和 crypto 解压缩其 zip 存档。

关于c++ - 编译问题 : LIBUSB_1 with cmake project on Windows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35475866/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com