0

after typing make to compile a project that is depends on espeak i got the following error at linking stage

     `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`

and here is cmakelisits

    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

)

hint:i put FindEspeak.cmake file in the Module path of cmake

4
  • No espeak development files ? ... sudo apt-get install libespeak-dev Jul 12 '16 at 17:46
  • i have installed libespeak-dev but still the previous error Jul 12 '16 at 22:08
  • Run it like that to see the actual linker command: make VERBOSE=1. Then take that linker command and execute it separately and try to change it to make it work. That will give a clue about what to change in the CMakeLists.txt. To check that the symbols are actually present in the libespeak, use objdump -tT /usr/lib/x86_64-linux-gnu/libespeak.so.1.1.47 (read about the "-t" option in the man objdump to understand what the output means).
    – Velkan
    Jul 17 '16 at 7:47
  • thanks a lot i have tried the following answer and it works Jul 17 '16 at 12:37
0

I just edited this part

############ 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 

) 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.