I successfully installed the OpenAL the with the following command:
yum install freealut freealut-devel
But the problem after this I add some c++ codes to work with this libraries as below:
#include <AL/al.h>
#include <AL/alc.h>
#include <AL/alut.h>
void init_al()
{
ALCdevice *dev = NULL;
ALCcontext *ctx = NULL;
const char *defname = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
std::cout << "Default device: " << defname << std::endl;
dev = alcOpenDevice(defname);
ctx = alcCreateContext(dev, NULL);
alcMakeContextCurrent(ctx);
alGenBuffers(1, &buf);
/* Fill buffer with Sine-Wave */
freq = 1440.f;
seconds = 0.2;
sample_rate = 22050;
buf_size = 6000;
samples = new short[buf_size];
for(int i=0; i<buf_size; ++i) {
samples[i] = 32760 * sin( (2.f*float(M_PI)*freq)/sample_rate * i );
}
/* Download buffer to OpenAL */
alBufferData(buf, AL_FORMAT_MONO16, samples, buf_size, sample_rate);
/* Set-up sound source and play buffer */
src = 0;
alGenSources(1, &src);
alSourcei(src, AL_BUFFER, buf);
alGenBuffers(1, &buf);
/* Fill buffer with Sine-Wave */
freq = 1000.f;
seconds = 0.2;
sample_rate = 22050;
buf_size = 12000;
samples = new short[buf_size];
float add=1;
for(int i=0; i<buf_size; ++i) {
samples[i] = 32760 * sin( (2.f*float(M_PI)*freq)/sample_rate * i );
}
/* Download buffer to OpenAL */
alBufferData(buf, AL_FORMAT_MONO16, samples, buf_size, sample_rate);
/* Set-up sound source and play buffer */
src2 = 0;
alGenSources(1, &src2);
alSourcei(src2, AL_BUFFER, buf);
}
I think my problem is on the linkers that can be added to the Eclipse project proprieties I include a linker alut but it also indicates an error. what could be my problem?