如何找到.so文件的库名? [英] How can I find a library name of .so file?

查看:404
本文介绍了如何找到.so文件的库名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我有 libprofiler.so 文件。如何获得这样的共享对象的名称:

For example, I have libprofiler.so file. How can I get name of this shared object like this:

getname /usr/lib/libprofiler.so

我想这样做是因为 CMakeLists.txt 是必需的在

I want to do it because it is required for CMakeLists.txt in

target_link_libraries(MyProject name_of_library)


推荐答案

执行以下步骤将现有库链接到目标:

Do the following steps to link an existing lib to your target:


  1. 通知您您需要哪个库:此处为探查器。

  2. 构建库的名称。 CMake并不需要这个,但是值得一提:Unix / Linux上的示例lib + NAME + [.so | .a] [VERSION]。此处: libprofiler.so

  3. 在您的CMakeLists.txt中:

  1. Inform you which lib do you need: here profiler.
  2. Build the name of the lib. CMake does not really needs this but it is worth to know: Example on Unix/Linux lib + NAME + [.so|.a] [VERSION]. Here: libprofiler.so.
  3. In your CMakeLists.txt:

find_library(LIB_PROFILER NAMES profiler libprofiler.so libprofiler.so.V123)
add_executable(MyApp ${SOURCES})
target_link_libraries(MyApp ${LIB_PROFILER})

上面的代码尝试找到一个lib并检查以下名称分析器 libprofiler.so libprofiler.so.V123 。如果找到,变量 LIB_PROFILER 指向lib文件。
使用变量作为链接到目标的文件之一。

The code above tries to find a lib and checks the following name profiler, libprofiler.so and libprofiler.so.V123. If found, the variable LIB_PROFILER points to the lib file. Use the variable as one of the files linked to your target.

在代码中,您还错过了变量附近的 $ {}

In your code, you also missed the ${} around the variable.

这篇关于如何找到.so文件的库名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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