[fpc-pascal] A linking error in a SDL example

luciano de souza luchyanus at gmail.com
Tue Mar 4 14:26:07 CET 2014


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 <yann.merignac at gmail.com>:
> Probably your missing the libsmpeg library. On debian it's provided by the
> libsmpeg0 package.
>
> https://packages.debian.org/wheezy/libsmpeg0
>


-- 
Luciano de Souza



More information about the fpc-pascal mailing list