Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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


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?

What I have tried:

I know `libespeak-ng.so.1` is here:
/usr/local/lib/libespeak-ng.so.1
Posted
Updated 21-Nov-17 8:59am
v5
Comments
Richard MacCutchan 21-Nov-17 14:01pm    
Have you included /usr/local/lib in your LIB environment variable?
Member 13376650 21-Nov-17 14:34pm    
I did add it to my '/etc/environment` file and now it has this content:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/lib:/usr/local/games"

But it doesn't work yet! even after reboot

Then
Richard MacCutchan 21-Nov-17 14:59pm    
See below.

1 solution

The libraries to search should be added to the LD_LIBRARY_PATH variable.
 
Share this answer
 
Comments
Member 13376650 22-Nov-17 3:07am    
How can I do it?
Richard MacCutchan 22-Nov-17 3:23am    
Whichever way is required by your shell.
Member 13376650 22-Nov-17 3:15am    
Should I add these to line to my /etc/environment file?
LD_LIBRARY_PATH=/usr/local/lib
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
Richard MacCutchan 22-Nov-17 3:23am    
Why not try it and see?
Member 13376650 22-Nov-17 3:30am    
I asked because I wanted to be sure what I am doing is the best thing! I did it myself before I ask and it worked.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900