问题描述
第一次尝试
在我的cmake / c ++项目中,编译时出现以下错误:
In my cmake/c++ project I get the following error when compiling:
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库。
So I am missing libusb libraries.
第二次尝试
所以现在我找到了一个libusb_1版本(libusbx-1.0.18-win),其中包括以下文件夹:
So now I have found a version of libusb_1 (libusbx-1.0.18-win) which includes the folders:
- 示例
- include
- MinGW32
- MinGW64
- MS32
- MS64
- examples
- include
- MinGW32
- MinGW64
- MS32
- MS64
我复制了MS64 / dll(Windows 64位)内容,并将其放在此处:
I copied MS64/dll (windows 64-bit) contents and put it here:
C:\local\libs\libusbx
我将此路径添加到PATH变量中,然后尝试再次运行cmake :
I added this path to my PATH variable and then tried to run cmake again:
C:> cd本地\项目ynsynergy-usb\synergy-through-usb-master
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在哪里...
Now I am stuck again. I have no idea what it wants me to do. It knows where libusb is...
编辑
这里是条件(其中的一部分)包含libusb的CMakeLists.txt:
Here is the contects (part of) the CMakeLists.txt that has libusb in it:
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文件:
I added the following lines into the findlibusb-1.0.cmake file:
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
仍然无法建立,但这个特定的库似乎现在可以添加了:)
Still does not build, but this particular library seems to be added ok now :)
推荐答案
synergy具有这样的方法,可以将某些第三方库压缩为zip ext子目录。通过usb的synergy-through-usb虽然保留了重要的方式来指定通过 -DLIBUSB_1_INCLUDE_DIR = ... -DLIBUSB_1_LIBRARY = ...
对于Windows。
synergy had such approach to keep some 3rd party libs compressed in zip in ext subdirectory. synergy-through-usb though kept cmake way to specify include through -DLIBUSB_1_INCLUDE_DIR=... -DLIBUSB_1_LIBRARY=...
for Windows.
因此,您只需要转到 ext目录,并使用gtest,gmock和crypto库解压缩其zip存档。
So you just need go to 'ext' directory and uncompress its zip archives with libraries gtest, gmock and crypto.
这篇关于编译问题:Windows上具有cmake项目的LIBUSB_1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!