Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-03

A linking error in a SDL example

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

luciano de souza

Hell all,

A friend ask me about the audio playing with SDL. I tried to do an example.

As I use Linux, with the following command, I consider all packages neeeded would be installed, but it seems that I am wrong: sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev

The source was compiled, but a link.res was generated as output.

According to the link.res, the executable coud not be built becose of the lack of lsmpeg.

I don't know how to install lsmpeg.

Since my code compiles, I think is not a problem with the code. What do you suppose is wrong?

Regards,

Luciano de Souza
luciano de souza
to Yann Mérignac

It works! Thank you very much. The reason was the lacking library.

This code plays a mp3 file.

program test;
uses
sounds;
begin
PlaySound('guitar.wav');
end.
unit sounds;
interface
uses
sdl, sdl_mixer, strings;
procedure PlaySound(filename: string);
implementation
procedure PlaySound(filename: string);
var
VFilename: pchar;
VChunk: pmix_chunk;
begin
VFilename := strAlloc(length(filename) + 1);
StrPCopy(VFilename, filename);
VChunk := mix_loadWav(VFilename);
if VChunk = nil then
writeln('O arquivo não pôde ser carregado');
if mix_PlayChannel(-1, VChunk, 0) < 0 then
exit;
while mix_Playing(0) = 1 do SDL_Delay(10);
StrDispose(VFilename);
end;
initialization
sdl_init(SDL_INIT_AUDIO);
mix_OpenAudio(44100, mix_Default_format, 2, 4096);
finalization
Mix_CloseAudio;
sdl_quit;
end.

2014-03-04 5:35 GMT-03:00, Yann Mérignac :

Show quoted text 5 lines
Probably your missing the libsmpeg library. On debian it's provided by the libsmpeg0 package. https://packages.debian.org/wheezy/libsmpeg0
Luciano de Souza