To connect the appropriate version of a shared library from a Yocto recipe, one can:
Include the shared library in the recipe by adding it to the recipe's FILES
variable.
Set the library's version using the PN-${PV}
variable. For example, PN-${PV}.so.1
.
Use the pkg-config
tool to locate and link against the library.
Specify the library's path in the linker flags using the -L
option, and the library's name using the -l
option.
For example, if the shared library is named libfoo.so.1
, and its Yocto recipe installs it to /usr/lib
, one can connect to it by including these flags in a CMake target:
add_executable(my_target my_source.cpp)
target_link_libraries(my_target
-L/usr/lib
-lfoo
)
Asked: 2023-06-19 13:30:02 +0000
Seen: 20 times
Last updated: Jun 19 '23