./speaks:错误而载入共享库:libespeak-ng.so.1:无法打开共享对象文件:没有这

2019-09-29 08:19发布

我已经下载的最新版本espeak-ng从GitHub,并没有./autogen.sh ./configure make make install 。 所以我写了一个测试程序,你可以看到如下:

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

并没有任何错误此命令编译它:

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

但是,当我尝试运行的可执行./speaks ,我得到这个错误信息:

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

有什么问题?

我知道libespeak-ng.so.1是在这里: /usr/local/lib/libespeak-ng.so.1

Answer 1:

我加入这两条线到我的`的/ etc /环境”文件解决了这个问题:

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


Answer 2:

在Ubuntu 18.04这是通过设置在错误的道路的库造成的。

须藤LN -s /usr/local/lib/libespeak-ng.so.1 /usr/lib/libespeak-ng.so.1:您可以通过修复



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