./speaks: error while loading shared libraries: libespeak-ng.so.1: cannot open shared object file: No such file or directory

99封情书 提交于 2019-12-11 05:08:52

问题


I have downloaded the last version of espeak-ng from github, and did ./autogen.sh ./configure make make install. so I wrote a test program as you can see below:

#include <string.h>
#include <vector> 
#include </usr/local/include/espeak-ng/speak_lib.h> 

int samplerate; // determined by espeak, will be in Hertz (Hz)
const int buflength = 200; // passed to espeak, in milliseconds (ms)

std::vector<short> sounddata;

int SynthCallback(short *wav, int numsamples, espeak_EVENT *events) {
    if (wav == NULL)
        return 1; // NULL means done.

    /* process your samples here, let's just gather them */
    sounddata.insert(sounddata.end(), wav, wav + numsamples);
    return 0; // 0 continues synthesis, 1 aborts 
}

int main(int argc, char* argv[] ) {
    char text[] = {"my name is espeak"};
    samplerate = espeak_Initialize(AUDIO_OUTPUT_RETRIEVAL, buflength, NULL, 0);
    espeak_SetSynthCallback(&SynthCallback);
    espeak_SetVoiceByName("en"); 
    unsigned int flags=espeakCHARS_AUTO | espeakENDPAUSE;
    size_t size = strlen(text); 
    espeak_Synth(text, size + 1, 0, POS_CHARACTER, 0, flags, NULL, NULL); 
    espeak_Synchronize();

    /* in theory sounddata holds your samples now... */

    return 0; 
}

And compiled it by this command without any errors:

g++ -W -o speaks espeak.cpp -lespeak-ng

But when I try to run the executable by ./speaks , I get this error message:

./speaks: error while loading shared libraries: libespeak-ng.so.1: cannot open shared object file: No such file or directory

What's the problem?

I know libespeak-ng.so.1 is here: /usr/local/lib/libespeak-ng.so.1


回答1:


I solved the problem by adding these two lines to my `/etc/environment' file:

LD_LIBRARY_PATH=/usr/local/lib
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig



回答2:


On Ubuntu 18.04 this is caused by setting the wrong path for the library.

You can fix it by: sudo ln -s /usr/local/lib/libespeak-ng.so.1 /usr/lib/libespeak-ng.so.1



来源:https://stackoverflow.com/questions/47400061/speaks-error-while-loading-shared-libraries-libespeak-ng-so-1-cannot-open-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!