./speaks:加载共享库时出错:libespeak-ng.so.1:无法打开共享对象文件:没有这样的文件或目录
问题描述:
我从github下载了`espeak-ng`的最新版本,并且`./autogen.sh ./configure make make install`。
所以我写了一个测试程序,如下所示:
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();
return 0;
}
并通过此命令编译它没有任何错误:
And compiled it by this command without any errors:
g++ -W -o speaks espeak.cpp -lespeak-ng
但是当我尝试运行可执行文件时` ./ speaks`,我收到此错误消息:
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
有什么问题?
我尝试了什么:
我知道`libespeak-ng.so.1`在这里:
What's the problem?
What I have tried:
I know `libespeak-ng.so.1` is here:
/usr/local/lib/libespeak-ng.so.1
答
要搜索的库应添加到 LD_LIBRARY_PATH
变量。
The libraries to search should be added to the LD_LIBRARY_PATH
variable.