sdl_mixer是sdl中关于音频播放的扩展库,我基于sdl_mixer写了个程序,程序试过了,是没有问题的。我在虚拟机linux下重新安装sdl_mixer,希望把它这个软件包编译成纯静态的。然后再编译我的程序,结果就出问题了。步骤如下:
1、从网下下载SDL_mixer-1.2.8.tar.tar包。
2、解压后,在SDL_mixer-1.2.8/目录下,./configure --prefix=/usr/local --enable-shared=no --enable-static=yes,然后make clean ,然后make,再然后make install。此时在/usr/local/lib目录下产生了该软件包的静态库。
/usr/local/lib # ls
directfb-1.0-0 libdirect.a libdirect.la libfusion.a libiconv.la libSDL_image.la libSDL_mixer.a preloadable_libiconv.so libcharset.a libdirectfb.a libfreetype.a libfusion.la libSDL.a libSDL.la libSDL_mixer.la libcharset.la libdirectfb.la libfreetype.la libiconv.a libSDL_image.a libSDLmain.a pkgconfig
3、回到我程序的主目录,编译我的程序,结果出了一堆错误:
# make
g++ -Wl,-rpath,/usr/local/Trolltech/Qt-4.3.2/lib -o qt_sdl_music main.o QMusicpl ayer.o QPlaythread.o moc_QMusicplayer.o moc_QPlaythread.o -L/usr/local/Trollt ech/Qt-4.3.2/lib -L/usr/local/lib -lSDL -lSDLmain -lGL -lSDL_mixer -lQtGui -L/us r/local/Trolltech/Qt-4.3.2/lib -L/usr/X11R6/lib -lpng -lSM -lICE -lXi -lXrender -lXrandr -lXfixes -lXcursor -lXinerama -lfreetype -lfontconfig -lXext -lX11 -lQt Core -lz -lm -lrt -ldl -lpthread
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `mix_channels':
mixer.c:(.text+0x18b): undefined reference to `SDL_GetTicks'
mixer.c:(.text+0x624): undefined reference to `SDL_MixAudio'
mixer.c:(.text+0x80d): undefined reference to `SDL_MixAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_OpenAudio':
mixer.c:(.text+0xb15): undefined reference to `SDL_OpenAudio'
mixer.c:(.text+0xb3a): undefined reference to `SDL_CloseAudio'
mixer.c:(.text+0xd1e): undefined reference to `SDL_PauseAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_AllocateChannels':
mixer.c:(.text+0xd88): undefined reference to `SDL_LockAudio'
mixer.c:(.text+0xf51): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_LoadWAV_RW':
mixer.c:(.text+0x1064): undefined reference to `SDL_ReadLE32'
mixer.c:(.text+0x1100): undefined reference to `SDL_LoadWAV_RW'
mixer.c:(.text+0x11f5): undefined reference to `SDL_BuildAudioCVT'
mixer.c:(.text+0x1207): undefined reference to `SDL_FreeWAV'
mixer.c:(.text+0x128c): undefined reference to `SDL_FreeWAV'
mixer.c:(.text+0x12ca): undefined reference to `SDL_FreeWAV'
mixer.c:(.text+0x12d8): undefined reference to `SDL_ConvertAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_FreeChunk':
mixer.c:(.text+0x14ef): undefined reference to `SDL_LockAudio'
mixer.c:(.text+0x155c): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_SetPostMix':
mixer.c:(.text+0x158b): undefined reference to `SDL_LockAudio'
mixer.c:(.text+0x15a0): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_HookMusic':
mixer.c:(.text+0x15ad): undefined reference to `SDL_LockAudio'
mixer.c:(.text+0x15de): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_ChannelFinished':
mixer.c:(.text+0x15f5): undefined reference to `SDL_LockAudio'
mixer.c:(.text+0x1602): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_PlayChannelTimed':
mixer.c:(.text+0x16e6): undefined reference to `SDL_LockAudio'
mixer.c:(.text+0x175c): undefined reference to `SDL_GetTicks'
mixer.c:(.text+0x18b7): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_ExpireChannel':
mixer.c:(.text+0x1912): undefined reference to `SDL_LockAudio'
mixer.c:(.text+0x193c): undefined reference to `SDL_GetTicks'
mixer.c:(.text+0x195d): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_FadeInChannelTimed':
mixer.c:(.text+0x19aa): undefined reference to `SDL_LockAudio'
mixer.c:(.text+0x1a14): undefined reference to `SDL_GetTicks'
mixer.c:(.text+0x1c18): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_HaltChannel':
mixer.c:(.text+0x1d49): undefined reference to `SDL_LockAudio'
mixer.c:(.text+0x1e4d): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_FadeOutChannel':
mixer.c:(.text+0x1eff): undefined reference to `SDL_LockAudio'
mixer.c:(.text+0x2020): undefined reference to `SDL_GetTicks'
mixer.c:(.text+0x202c): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_CloseAudio':
mixer.c:(.text+0x222c): undefined reference to `SDL_CloseAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_Pause':
mixer.c:(.text+0x225d): undefined reference to `SDL_GetTicks'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_Resume':
mixer.c:(.text+0x2319): undefined reference to `SDL_GetTicks'
mixer.c:(.text+0x2321): undefined reference to `SDL_LockAudio'
mixer.c:(.text+0x2507): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_GroupChannel':
mixer.c:(.text+0x25ce): undefined reference to `SDL_LockAudio'
mixer.c:(.text+0x25f5): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_GroupOldest':
mixer.c:(.text+0x2720): undefined reference to `SDL_GetTicks'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_RegisterEffect':
mixer.c:(.text+0x2b44): undefined reference to `SDL_LockAudio'
mixer.c:(.text+0x2b6c): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_UnregisterEffect':
mixer.c:(.text+0x2be0): undefined reference to `SDL_LockAudio'
mixer.c:(.text+0x2c01): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(mixer.o): In function `Mix_UnregisterAllEffects':
mixer.c:(.text+0x2c75): undefined reference to `SDL_LockAudio'
mixer.c:(.text+0x2c8f): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(music.o): In function `Mix_HookMusicFinished':
music.c:(.text+0x7): undefined reference to `SDL_LockAudio'
music.c:(.text+0x14): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(music.o): In function `Mix_FreeMusic':
music.c:(.text+0xc80): undefined reference to `SDL_LockAudio'
music.c:(.text+0xc91): undefined reference to `SDL_UnlockAudio'
music.c:(.text+0xc9d): undefined reference to `SDL_Delay'
music.c:(.text+0xca2): undefined reference to `SDL_LockAudio'
music.c:(.text+0xcc1): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(music.o): In function `Mix_GetMusicType':
music.c:(.text+0xd61): undefined reference to `SDL_LockAudio'
music.c:(.text+0xd79): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(music.o): In function `Mix_FadeInMusicPos':
music.c:(.text+0xf14): undefined reference to `SDL_LockAudio'
music.c:(.text+0xf1b): undefined reference to `SDL_UnlockAudio'
music.c:(.text+0xf27): undefined reference to `SDL_Delay'
music.c:(.text+0xf2c): undefined reference to `SDL_LockAudio'
music.c:(.text+0xf6e): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(music.o): In function `Mix_SetMusicPosition':
music.c:(.text+0x103b): undefined reference to `SDL_LockAudio'
music.c:(.text+0x107e): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(music.o): In function `Mix_VolumeMusic':
music.c:(.text+0x115c): undefined reference to `SDL_LockAudio'
music.c:(.text+0x1177): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(music.o): In function `Mix_HaltMusic':
music.c:(.text+0x1205): undefined reference to `SDL_LockAudio'
music.c:(.text+0x1218): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(music.o): In function `Mix_FadeOutMusic':
music.c:(.text+0x1248): undefined reference to `SDL_LockAudio'
music.c:(.text+0x1301): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(music.o): In function `Mix_FadingMusic':
music.c:(.text+0x131e): undefined reference to `SDL_LockAudio'
music.c:(.text+0x1337): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(music.o): In function `Mix_PlayingMusic':
music.c:(.text+0x1431): undefined reference to `SDL_LockAudio'
music.c:(.text+0x1447): undefined reference to `SDL_UnlockAudio'
/usr/local/lib/libSDL_mixer.a(wavestream.o): In function `WAVStream_LoadSong':
wavestream.c:(.text+0x1f3): undefined reference to `SDL_BuildAudioCVT'
/usr/local/lib/libSDL_mixer.a(wavestream.o): In function `WAVStream_PlaySome':
wavestream.c:(.text+0x39a): undefined reference to `SDL_ConvertAudio'
wavestream.c:(.text+0x3c9): undefined reference to `SDL_MixAudio'
wavestream.c:(.text+0x466): undefined reference to `SDL_MixAudio'
/usr/local/lib/libSDL_mixer.a(wavestream.o): In function `ReadChunk':
wavestream.c:(.text+0x511): undefined reference to `SDL_ReadLE32'
wavestream.c:(.text+0x523): undefined reference to `SDL_ReadLE32'
/usr/local/lib/libSDL_mixer.a(wavestream.o): In function `LoadWAVStream':
wavestream.c:(.text+0x635): undefined reference to `SDL_RWFromFP'
wavestream.c:(.text+0x655): undefined reference to `SDL_ReadLE32'
wavestream.c:(.text+0x663): undefined reference to `SDL_ReadLE32'
wavestream.c:(.text+0x671): undefined reference to `SDL_ReadLE32'
/usr/local/lib/libSDL_mixer.a(wavestream.o): In function `LoadAIFFStream':
wavestream.c:(.text+0x9e8): undefined reference to `SDL_RWFromFP'
wavestream.c:(.text+0xa08): undefined reference to `SDL_ReadLE32'
wavestream.c:(.text+0xa16): undefined reference to `SDL_ReadBE32'
wavestream.c:(.text+0xa24): undefined reference to `SDL_ReadLE32'
wavestream.c:(.text+0xa6a): undefined reference to `SDL_ReadLE32'
wavestream.c:(.text+0xa78): undefined reference to `SDL_ReadBE32'
wavestream.c:(.text+0xad7): undefined reference to `SDL_ReadBE32'
wavestream.c:(.text+0xae5): undefined reference to `SDL_ReadBE32'
wavestream.c:(.text+0xb23): undefined reference to `SDL_ReadBE16'
wavestream.c:(.text+0xb32): undefined reference to `SDL_ReadBE32'
wavestream.c:(.text+0xb40): undefined reference to `SDL_ReadBE16'
/usr/local/lib/libSDL_mixer.a(playmidi.o): In function `Timidity_LoadSong':
playmidi.c:(.text+0x4224): undefined reference to `SDL_RWFromFile'
/usr/local/lib/libSDL_mixer.a(load_aiff.o): In function `Mix_LoadAIFF_RW':
load_aiff.c:(.text+0xf6): undefined reference to `SDL_ReadLE32'
load_aiff.c:(.text+0x104): undefined reference to `SDL_ReadBE32'
load_aiff.c:(.text+0x130): undefined reference to `SDL_ReadLE32'
load_aiff.c:(.text+0x18d): undefined reference to `SDL_ReadLE32'
load_aiff.c:(.text+0x19b): undefined reference to `SDL_ReadBE32'
load_aiff.c:(.text+0x226): undefined reference to `SDL_ReadBE32'
load_aiff.c:(.text+0x234): undefined reference to `SDL_ReadBE32'
load_aiff.c:(.text+0x271): undefined reference to `SDL_ReadBE16'
load_aiff.c:(.text+0x280): undefined reference to `SDL_ReadBE32'
load_aiff.c:(.text+0x28e): undefined reference to `SDL_ReadBE16'
load_aiff.c:(.text+0x2f9): undefined reference to `SDL_ReadBE32'
load_aiff.c:(.text+0x304): undefined reference to `SDL_ReadBE32'
load_aiff.c:(.text+0x30f): undefined reference to `SDL_ReadBE32'
load_aiff.c:(.text+0x31a): undefined reference to `SDL_ReadBE16'
collect2: ld returned 1 exit status
make: *** [qt_sdl_music] 错误 1