我一直面临着将cmake链接到libass库的问题。我们的项目目录如下图所示
MainApp ( it contains the CmakeLists.txt)
|
|
|--cmake/libs ( this contains FindLibass.cmake)
|
|
|--src
| |
| |-Decoder ( it contains the Sources.cmake)
| | |--Subtitle.cpp
“FindLibass.cmake”是MainApp的子模块,用于维护Libass外部库和头文件的路径。 “Sources.cmake”是维护解码器特定代码的代码的一部分。
解码器代码已经过修改,可以使用libass头文件,但是在链接到库时。它在代码中失败如下
Subtitle.cpp:(.text+0x68d): undefined reference to `ass_library_init()'
Subtitle.cpp:(.text+0x6fa): undefined reference to `ass_set_message_cb(ass_library*, void (*)(int, char const*, __va_list_tag*, void*), void*)'
Subtitle.cpp:(.text+0x70a): undefined reference to `ass_renderer_init(ass_library*)'
FindLibass.cmake的语法位于
之下set(LIBASS_INCLUDE_DIR ${LIBASS_SEARCH_PATH})
FIND_PATH(LIBASS_INCLUDE
NAMES ass/ass.h
PATHS "${LIBASS_INCLUDE_DIR}/include" NO_DEFAULT_PATH
)
FIND_LIBRARY(LIBASS_LIBRARIES
NAMES "libass.so"
PATHS "${CMAKE_SOURCE_DIR}/contrib/libass/lib" NO_DEFAULT_PATH
)