.so之后是数字,如何在cmake的find_library中将它们匹配?链接作为子依赖关系的共享对象时出错 [英] .so with numerals after that, how to match them in find_library in cmake ? Error in linking shared objects which are found as sub-dependencies
问题描述
给出
ls -lrt / usr / lib / libvpx *
结果
lrwxrwxrwx 1根root 2012年2月15日/usr/lib/libvpx.so.1.0-> libvpx.so.1.0.0
lrwxrwxrwx 1 root root 2012年2月15日/usr/lib/libvpx.so.1-> libvpx.so.1.0.0
-rw-r--r-- 1 root root 646120 2012年2月9日/ usr /lib/libvpx.so.1.0.0
lrwxrwxrwx 1 root root 15 Feb 9 2012 /usr/lib/libvpx.so.1.0 ->libvpx.so.1.0.0
lrwxrwxrwx 1 root root 15 Feb 9 2012 /usr/lib/libvpx.so.1 -> libvpx.so.1.0.0
-rw-r--r-- 1 root root 646120 Feb 9 2012 /usr/lib/libvpx.so.1.0.0
ls -lrt / usr / lib / libschroedinger *
结果
lrwxrwxrwx 1根root 2012年2月8日/usr/lib/libschroedinger-1.0.so.0- > libschroedinger-1.0.so.0.11.0
-rw-r--r-- 1根root 774044 2012年2月8日/usr/lib/libschroedinger-1.0.so.0.11.0
lrwxrwxrwx 1 root root 29 Feb 8 2012 /usr/lib/libschroedinger-1.0.so.0 ->libschroedinger-1.0.so.0.11.0
-rw-r--r-- 1 root root 774044 Feb 8 2012 /usr/lib/libschroedinger-1.0.so.0.11.0
ls -lrt / usr / lib / libgsm *
结果
lrwxrwxrwx 1根root 2009年11月5日/usr/lib/libgsm.so.1-> libgsm.so.1.0.12
-rw-r--r-- 1根root 50680 2009年11月5日/usr/lib/libgsm.so.1.0.12
lrwxrwxrwx 1 root root 16 Nov 5 2009 /usr/lib/libgsm.so.1 -> libgsm.so.1.0.12
-rw-r--r-- 1 root root 50680 Nov 5 2009 /usr/lib/libgsm.so.1.0.12
这是对这个问题。
可能的解决方案
正如我在上级问题中提到的那样,我们可能需要添加三个 find_library()
函数。以下是CMakeLists.txt的内容
Possible Solution
As I mentioned in the parent question, we may need to add three find_library()
functions. Below are contents from CMakeLists.txt
可能的解决方案1a
find_library(VPX_LIBRARIES名称libvpx.so.1路径/ usr / lib /)
find_library(SCHROEDINGER_LIBRARIES名称libschroedinger-1.0.so.0-1.0路径/ usr / lib /)
find_library(GSM_LIBRARIES名称libgsm.so.1路径/ usr / lib /)
find_library(VPX_LIBRARIES NAMES libvpx.so.1 PATHS /usr/lib/ )
find_library(SCHROEDINGER_LIBRARIES NAMES libschroedinger-1.0.so.0-1.0 PATHS /usr/lib/) find_library(GSM_LIBRARIES NAMES libgsm.so.1 PATHS /usr/lib/ )
target_link_libraries(MyLibraryOrMyExecutable $ {VPX_LIBRARIES} $ {SCHROEDINGER_LIBRARIES}} $ {GSM_LIBRARIES p>
target_link_libraries(MyLibraryOrMyExecutable ${VPX_LIBRARIES} ${SCHROEDINGER_LIBRARIES} ${GSM_LIBRARIES} )
可能的解决方案1b
find_library(VPX_LIBRARIES名称vpx路径/ usr / lib /)
find_library(SCHROEDINGER_LIBRARIES名称schroedinger-1.0路径
/ usr / lib /)find_library(GSM_LIBRARIES名称S gsmlib路径/)
find_library(VPX_LIBRARIES NAMES vpx PATHS /usr/lib/)
find_library(SCHROEDINGER_LIBRARIES NAMES schroedinger-1.0 PATHS /usr/lib/) find_library(GSM_LIBRARIES NAMES gsm PATHS /usr/lib/)
target_link_libraries(MyLibraryOrMyExecutable $ {VPX_LIBRARIES} $ {SCHROEDINGER_LIBRARIES} $ {GSM_LIBRARIES})
target_link_libraries(MyLibraryOrMyExecutable ${VPX_LIBRARIES} ${SCHROEDINGER_LIBRARIES} ${GSM_LIBRARIES} )
错误
对于解决方案1a和1b我都得到相同的错误
Error
I get the same error for both the solutions 1a and 1b
CMake错误:此项目中使用了以下变量,但是
它们设置为NOTFOUND。请设置它们或确保它们设置了
并在CMake文件中正确测试:
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:
GSM_LIBRARIES
由目标 MyLibraryOrMyExecutable链接在/ someDirectory目录中
GSM_LIBRARIES
linked by target "MyLibraryOrMyExecutable" in directory /someDirectory
SCHROEDINGER_LIBRARIES
在目录/ someDirectory中由目标 MyLibraryOrMyExecutable链接
SCHROEDINGER_LIBRARIES
linked by target "MyLibraryOrMyExecutable" in directory /someDirectory
VPX_LIBRARIES
由目录/ someDirectory中的目标 MyLibraryOrMyExecutable链接
VPX_LIBRARIES
linked by target "MyLibraryOrMyExecutable" in directory /someDirectory
cmake在查找libvpx.so之后从find_library()中读取NAMES中的vpx,但是找到了一个类似libvpx.so.1的文件,因此我在给出确切名称的地方也使用了1b。
cmake looks for libvpx.so after reading vpx in NAMES from find_library(), but find a different file like libvpx.so.1 hence I used 1b too where I have given the exact names. But still no luck.
Q 如何解决这样的问题,即共享库的名称在扩展名后还包括一个数字,并且确切名称与 find_library()
中给定的名称不匹配。 ?我试图给出确切的名称,但这也不起作用
Q How do one resolve an issue like this where the name of the shared objects also include a number after the extension, and the exact name does not match with the name given in find_library()
. ? I tried to give the exact names, that also does not work
推荐答案
命令 find_library 使用 CMAKE_FIND_LIBRARY_SUFFIXES 和 CMAKE_FIND_LIBRARY_PREFIXES 变量来粘贴真实库名。例如:
Command find_library use CMAKE_FIND_LIBRARY_SUFFIXES and CMAKE_FIND_LIBRARY_PREFIXES variables to glue the real library name. For instance:
> cat CMakeLists.txt
message("suffixes: ${CMAKE_FIND_LIBRARY_SUFFIXES}")
message("prefixes: ${CMAKE_FIND_LIBRARY_PREFIXES}")
> cmake -H. -B_builds
suffixes: .so;.a
prefixes: lib
< href = http://www.cmake.org/cmake/help/v2.8.12/cmake.html#variable%3aCMAKE_FIND_LIBRARY_SUFFIXES rel = nofollow> CMAKE_FIND_LIBRARY_SUFFIXES 是一个列表变量,您可以添加一个新后缀:
CMAKE_FIND_LIBRARY_SUFFIXES is a list variable and you can add a new suffix:
> cat CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .so.17)
find_library(library edata-book-1.2)
message("library: ${library}")
> cmake -H. -B_builds
library: /usr/lib/libedata-book-1.2.so.17
但是,我很确定这里的真实问题是软件包管理器的使用(:通常
lib< name> .so
是 lib< name> .so.NM
文件的符号链接。因此,我建议您检查手册
并将库安装在适当的方式。
But I'm pretty sure that the real problem here is package manager usage (: Usually
lib<name>.so
is a symlink to lib<name>.so.N.M
file. So I recommend you to check manuals
and install your library in an appropriate way.
这篇关于.so之后是数字,如何在cmake的find_library中将它们匹配?链接作为子依赖关系的共享对象时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!