make
在输入编译依赖于 espeak 的项目后,我在链接阶段收到以下错误
`EspeakTTSWorker.cpp:(.text+0x118): undefined reference to `espeak_Initialize'
CMakeFiles/TextReading.dir/EspeakBridge.cpp.o: In function `EspeakBridge::init()':
EspeakBridge.cpp:(.text+0x93): undefined reference to `espeak_Initialize'
EspeakBridge.cpp:(.text+0x9d): undefined reference to `espeak_SetVoiceByName'
EspeakBridge.cpp:(.text+0xa7): undefined reference to `espeak_SetSynthCallback'
CMakeFiles/TextReading.dir/EspeakBridge.cpp.o: In function `EspeakBridge::close()':
EspeakBridge.cpp:(.text+0x173): undefined reference to `espeak_Terminate'
CMakeFiles/TextReading.dir/EspeakBridge.cpp.o: In function `EspeakTTSWorker::setText(std::string const&)':
EspeakBridge.cpp:(.text._ZN15EspeakTTSWorker7setTextERKSs[_ZN15EspeakTTSWorker7setTextERKSs]+0x121): undefined reference to `espeak_Synth'
EspeakBridge.cpp:(.text._ZN15EspeakTTSWorker7setTextERKSs[_ZN15EspeakTTSWorker7setTextERKSs]+0x126): undefined reference to `espeak_Synchronize'
collect2: error: ld returned 1 exit status
make[2]: *** [TextReading] Error 1
make[1]: *** [CMakeFiles/TextReading.dir/all] Error 2
make: *** [all] Error 2`
这是目录
find_package (Espeak)
if (Espeak_FOUND)
include_directories(${Espeak_INCLUDE_DIRS}) #/usr/local/include/espeak
endif(Espeak_FOUND)
if (NOT Espeak_Found)
message(FATAL_ERROR "Package Espeak required, but not found!")
endif(NOT Espeak_Found)
add_executable(TextReading
${DAD_SOURCES}
${DAD_HEADERS}
${MY_UI_HDRS}
${MY_MOC_SRCS}
${MY_CUDA_COMPILED_FILES}
${QEXTSERIALPORT_SOURCES} ${QEXTSERIALPORT_HEADERS}
)
target_link_libraries(TextReading
${OpenGL_LIBS}
${QT_LIBRARIES}
${QGLVIEWER}
${Boost}
${OpenCV_LIBS}
${TESSERACT_LIB}
${FFMPEG_LIBRARIES}
${MathGL_LIB}
# ${Flite_LIBS}
${Espeak_LIBRARIES}
#/usr/lib/x86_64-linux-gnu/libespeak.so.1
#/usr/lib/x86_64-linux-gnu/libespeak.so.1.1.47
${QEXTSERIALPORT_LIBS}
${QTMOBILITY_LIBRARIES}
udev
)
提示:我将FindEspeak.cmake
文件放在 cmake 的模块路径中
答案1
我刚刚编辑了这部分
############ Find ESPEAK TTS ############
find_path(LIBESPEAK_INCLUDE_DIRS
NAMES speak_lib.h
HINTS /usr/include/espeak)
find_library(LIBESPEAK_LIBRARIES
NAMES espeak
HINTS /usr/lib/ /usr/x86_64-linux-gnu/
PATH_SUFFIXES lib)
########################################
add_executable(TextReading
${DAD_SOURCES}
${DAD_HEADERS}
${MY_UI_HDRS}
${MY_MOC_SRCS}
${MY_CUDA_COMPILED_FILES}
${QEXTSERIALPORT_SOURCES} ${QEXTSERIALPORT_HEADERS}
)
target_link_libraries(TextReading
${OpenGL_LIBS}
${QT_LIBRARIES}
${QGLVIEWER}
${Boost}
${OpenCV_LIBS}
${TESSERACT_LIB}
${FFMPEG_LIBRARIES}
${MathGL_LIB}
#${ESPEAK_LIBRARIES}
${LIBESPEAK_LIBRARIES}
${QEXTSERIALPORT_LIBS}
${QTMOBILITY_LIBRARIES}
udev
)